|
@@ -55,181 +55,92 @@ get_parent() const {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: DCClass::get_num_atomics
|
|
|
|
|
|
|
+// Function: DCClass::get_num_fields
|
|
|
// Access: Public
|
|
// Access: Public
|
|
|
-// Description: Returns the number of atomic fields defined directly
|
|
|
|
|
-// in this class, ignoring inheritance.
|
|
|
|
|
|
|
+// Description: Returns the number of fields defined directly in this
|
|
|
|
|
+// class, ignoring inheritance.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
int DCClass::
|
|
int DCClass::
|
|
|
-get_num_atomics() {
|
|
|
|
|
- return _atomic_fields.size();
|
|
|
|
|
|
|
+get_num_fields() {
|
|
|
|
|
+ return _fields.size();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: DCClass::get_atomic
|
|
|
|
|
|
|
+// Function: DCClass::get_field
|
|
|
// Access: Public
|
|
// Access: Public
|
|
|
-// Description: Returns the nth atomic field in the class. This is
|
|
|
|
|
-// not necessarily the field with index n; this is the
|
|
|
|
|
-// nth field defined in the class directly, ignoring
|
|
|
|
|
|
|
+// Description: Returns the nth field in the class. This is not
|
|
|
|
|
+// necessarily the field with index n; this is the nth
|
|
|
|
|
+// field defined in the class directly, ignoring
|
|
|
// inheritance.
|
|
// inheritance.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-DCAtomicField *DCClass::
|
|
|
|
|
-get_atomic(int n) {
|
|
|
|
|
- assert(n >= 0 && n < (int)_atomic_fields.size());
|
|
|
|
|
- return _atomic_fields[n];
|
|
|
|
|
|
|
+DCField *DCClass::
|
|
|
|
|
+get_field(int n) {
|
|
|
|
|
+ assert(n >= 0 && n < (int)_fields.size());
|
|
|
|
|
+ return _fields[n];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: DCClass::get_atomic_by_name
|
|
|
|
|
|
|
+// Function: DCClass::get_field_by_name
|
|
|
// Access: Public
|
|
// Access: Public
|
|
|
-// Description: Returns a pointer to the DCAtomicField that shares
|
|
|
|
|
-// the indicated name. If the named field is not found
|
|
|
|
|
-// in the current class, the parent classes will be
|
|
|
|
|
|
|
+// Description: Returns a pointer to the DCField that shares the
|
|
|
|
|
+// indicated name. If the named field is not found in
|
|
|
|
|
+// the current class, the parent classes will be
|
|
|
// searched, so the value returned may not actually be a
|
|
// searched, so the value returned may not actually be a
|
|
|
// field within this class. Returns NULL if there is no
|
|
// field within this class. Returns NULL if there is no
|
|
|
// such field defined.
|
|
// such field defined.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-DCAtomicField *DCClass::
|
|
|
|
|
-get_atomic_by_name(const string &name) {
|
|
|
|
|
- AtomicsByName::const_iterator ni;
|
|
|
|
|
- ni = _atomics_by_name.find(name);
|
|
|
|
|
- if (ni != _atomics_by_name.end()) {
|
|
|
|
|
|
|
+DCField *DCClass::
|
|
|
|
|
+get_field_by_name(const string &name) {
|
|
|
|
|
+ FieldsByName::const_iterator ni;
|
|
|
|
|
+ ni = _fields_by_name.find(name);
|
|
|
|
|
+ if (ni != _fields_by_name.end()) {
|
|
|
return (*ni).second;
|
|
return (*ni).second;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// We didn't have such a field, so check our parents.
|
|
// We didn't have such a field, so check our parents.
|
|
|
Parents::iterator pi;
|
|
Parents::iterator pi;
|
|
|
for (pi = _parents.begin(); pi != _parents.end(); ++pi) {
|
|
for (pi = _parents.begin(); pi != _parents.end(); ++pi) {
|
|
|
- DCAtomicField *result = (*pi)->get_atomic_by_name(name);
|
|
|
|
|
- if (result != (DCAtomicField *)NULL) {
|
|
|
|
|
|
|
+ DCField *result = (*pi)->get_field_by_name(name);
|
|
|
|
|
+ if (result != (DCField *)NULL) {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Nobody knew what this field is.
|
|
// Nobody knew what this field is.
|
|
|
- return (DCAtomicField *)NULL;
|
|
|
|
|
|
|
+ return (DCField *)NULL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: DCClass::get_num_inherited_atomics
|
|
|
|
|
|
|
+// Function: DCClass::get_num_inherited_fields
|
|
|
// Access: Public
|
|
// Access: Public
|
|
|
-// Description: Returns the total number of atomic fields defined in
|
|
|
|
|
|
|
+// Description: Returns the total number of field fields defined in
|
|
|
// this class and all ancestor classes.
|
|
// this class and all ancestor classes.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
int DCClass::
|
|
int DCClass::
|
|
|
-get_num_inherited_atomics() {
|
|
|
|
|
|
|
+get_num_inherited_fields() {
|
|
|
if (!_parents.empty()) {
|
|
if (!_parents.empty()) {
|
|
|
// This won't work for multiple dclass inheritance.
|
|
// This won't work for multiple dclass inheritance.
|
|
|
- return _parents.front()->get_num_atomics() + get_num_atomics();
|
|
|
|
|
|
|
+ return _parents.front()->get_num_fields() + get_num_fields();
|
|
|
}
|
|
}
|
|
|
- return get_num_atomics();
|
|
|
|
|
|
|
+ return get_num_fields();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: DCClass::get_inherited_atomic
|
|
|
|
|
|
|
+// Function: DCClass::get_inherited_field
|
|
|
// Access: Public
|
|
// Access: Public
|
|
|
-// Description: Returns the nth atomic field in the class and all of
|
|
|
|
|
|
|
+// Description: Returns the nth field field in the class and all of
|
|
|
// its ancestors. This *is* the field corresponding to
|
|
// its ancestors. This *is* the field corresponding to
|
|
|
// the given index number, since the fields are ordered
|
|
// the given index number, since the fields are ordered
|
|
|
// consecutively beginning at the earliest inherited
|
|
// consecutively beginning at the earliest inherited
|
|
|
// fields.
|
|
// fields.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-DCAtomicField *DCClass::
|
|
|
|
|
-get_inherited_atomic(int n) {
|
|
|
|
|
|
|
+DCField *DCClass::
|
|
|
|
|
+get_inherited_field(int n) {
|
|
|
if (!_parents.empty()) {
|
|
if (!_parents.empty()) {
|
|
|
// This won't work for multiple dclass inheritance.
|
|
// This won't work for multiple dclass inheritance.
|
|
|
- n -= _parents.front()->get_num_inherited_atomics();
|
|
|
|
|
|
|
+ n -= _parents.front()->get_num_inherited_fields();
|
|
|
}
|
|
}
|
|
|
- return get_atomic(n);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: DCClass::get_num_moleculars
|
|
|
|
|
-// Access: Public
|
|
|
|
|
-// Description: Returns the number of molecular fields defined directly
|
|
|
|
|
-// in this class, ignoring inheritance.
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-int DCClass::
|
|
|
|
|
-get_num_moleculars() {
|
|
|
|
|
- return _molecular_fields.size();
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: DCClass::get_molecular
|
|
|
|
|
-// Access: Public
|
|
|
|
|
-// Description: Returns the nth molecular field in the class. This is
|
|
|
|
|
-// not necessarily the field with index n; this is the
|
|
|
|
|
-// nth field defined in the class directly, ignoring
|
|
|
|
|
-// inheritance.
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-DCMolecularField *DCClass::
|
|
|
|
|
-get_molecular(int n) {
|
|
|
|
|
- assert(n >= 0 && n < (int)_molecular_fields.size());
|
|
|
|
|
- return _molecular_fields[n];
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: DCClass::get_molecular_by_name
|
|
|
|
|
-// Access: Public
|
|
|
|
|
-// Description: Returns a pointer to the DCMolecularField that shares
|
|
|
|
|
-// the indicated name. If the named field is not found
|
|
|
|
|
-// in the current class, the parent classes will be
|
|
|
|
|
-// searched, so the value returned may not actually be a
|
|
|
|
|
-// field within this class. Returns NULL if there is no
|
|
|
|
|
-// such field defined.
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-DCMolecularField *DCClass::
|
|
|
|
|
-get_molecular_by_name(const string &name) {
|
|
|
|
|
- MolecularsByName::const_iterator ni;
|
|
|
|
|
- ni = _moleculars_by_name.find(name);
|
|
|
|
|
- if (ni != _moleculars_by_name.end()) {
|
|
|
|
|
- return (*ni).second;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // We didn't have such a field, so check our parents.
|
|
|
|
|
- Parents::iterator pi;
|
|
|
|
|
- for (pi = _parents.begin(); pi != _parents.end(); ++pi) {
|
|
|
|
|
- DCMolecularField *result = (*pi)->get_molecular_by_name(name);
|
|
|
|
|
- if (result != (DCMolecularField *)NULL) {
|
|
|
|
|
- return result;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Nobody knew what this field is.
|
|
|
|
|
- return (DCMolecularField *)NULL;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: DCClass::get_num_inherited_moleculars
|
|
|
|
|
-// Access: Public
|
|
|
|
|
-// Description: Returns the total number of molecular fields defined in
|
|
|
|
|
-// this class and all ancestor classes.
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-int DCClass::
|
|
|
|
|
-get_num_inherited_moleculars() {
|
|
|
|
|
- if (!_parents.empty()) {
|
|
|
|
|
- // This won't work for multiple dclass inheritance.
|
|
|
|
|
- return _parents.front()->get_num_moleculars() + get_num_moleculars();
|
|
|
|
|
- }
|
|
|
|
|
- return get_num_moleculars();
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: DCClass::get_inherited_molecular
|
|
|
|
|
-// Access: Public
|
|
|
|
|
-// Description: Returns the nth molecular field in the class and all of
|
|
|
|
|
-// its ancestors. This *is* the field corresponding to
|
|
|
|
|
-// the given index number, since the fields are ordered
|
|
|
|
|
-// consecutively beginning at the earliest inherited
|
|
|
|
|
-// fields.
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-DCMolecularField *DCClass::
|
|
|
|
|
-get_inherited_molecular(int n) {
|
|
|
|
|
- if (!_parents.empty()) {
|
|
|
|
|
- // This won't work for multiple dclass inheritance.
|
|
|
|
|
- n -= _parents.front()->get_num_inherited_moleculars();
|
|
|
|
|
- }
|
|
|
|
|
- return get_molecular(n);
|
|
|
|
|
|
|
+ return get_field(n);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
@@ -248,14 +159,10 @@ DCClass() {
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
DCClass::
|
|
DCClass::
|
|
|
~DCClass() {
|
|
~DCClass() {
|
|
|
- AtomicFields::iterator ai;
|
|
|
|
|
- for (ai = _atomic_fields.begin(); ai != _atomic_fields.end(); ++ai) {
|
|
|
|
|
|
|
+ Fields::iterator ai;
|
|
|
|
|
+ for (ai = _fields.begin(); ai != _fields.end(); ++ai) {
|
|
|
delete (*ai);
|
|
delete (*ai);
|
|
|
}
|
|
}
|
|
|
- MolecularFields::iterator mi;
|
|
|
|
|
- for (mi = _molecular_fields.begin(); mi != _molecular_fields.end(); ++mi) {
|
|
|
|
|
- delete (*mi);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
@@ -280,61 +187,33 @@ write(ostream &out, int indent_level) const {
|
|
|
}
|
|
}
|
|
|
out << " { // index " << _number << "\n";
|
|
out << " { // index " << _number << "\n";
|
|
|
|
|
|
|
|
- AtomicFields::const_iterator ai;
|
|
|
|
|
- for (ai = _atomic_fields.begin(); ai != _atomic_fields.end(); ++ai) {
|
|
|
|
|
|
|
+ Fields::const_iterator ai;
|
|
|
|
|
+ for (ai = _fields.begin(); ai != _fields.end(); ++ai) {
|
|
|
(*ai)->write(out, indent_level + 2);
|
|
(*ai)->write(out, indent_level + 2);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- MolecularFields::const_iterator mi;
|
|
|
|
|
- for (mi = _molecular_fields.begin(); mi != _molecular_fields.end(); ++mi) {
|
|
|
|
|
- (*mi)->write(out, indent_level + 2);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
indent(out, indent_level) << "};\n";
|
|
indent(out, indent_level) << "};\n";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: DCClass::add_field
|
|
// Function: DCClass::add_field
|
|
|
// Access: Public
|
|
// Access: Public
|
|
|
-// Description: Adds the newly-allocated atomic field to the class.
|
|
|
|
|
-// The class becomes the owner of the pointer and will
|
|
|
|
|
-// delete it when it destructs. Returns true if the
|
|
|
|
|
-// field is successfully added, or false if there was a
|
|
|
|
|
-// name conflict.
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-bool DCClass::
|
|
|
|
|
-add_field(DCAtomicField *field) {
|
|
|
|
|
- bool inserted = _atomics_by_name.insert
|
|
|
|
|
- (AtomicsByName::value_type(field->_name, field)).second;
|
|
|
|
|
-
|
|
|
|
|
- if (!inserted) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- field->_number = get_num_inherited_atomics();
|
|
|
|
|
- _atomic_fields.push_back(field);
|
|
|
|
|
- return true;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: DCClass::add_field
|
|
|
|
|
-// Access: Public
|
|
|
|
|
-// Description: Adds the newly-allocated molecular field to the class.
|
|
|
|
|
-// The class becomes the owner of the pointer and will
|
|
|
|
|
|
|
+// Description: Adds the newly-allocated field to the class. The
|
|
|
|
|
+// class becomes the owner of the pointer and will
|
|
|
// delete it when it destructs. Returns true if the
|
|
// delete it when it destructs. Returns true if the
|
|
|
// field is successfully added, or false if there was a
|
|
// field is successfully added, or false if there was a
|
|
|
// name conflict.
|
|
// name conflict.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
bool DCClass::
|
|
bool DCClass::
|
|
|
-add_field(DCMolecularField *field) {
|
|
|
|
|
- bool inserted = _moleculars_by_name.insert
|
|
|
|
|
- (MolecularsByName::value_type(field->_name, field)).second;
|
|
|
|
|
|
|
+add_field(DCField *field) {
|
|
|
|
|
+ bool inserted = _fields_by_name.insert
|
|
|
|
|
+ (FieldsByName::value_type(field->_name, field)).second;
|
|
|
|
|
|
|
|
if (!inserted) {
|
|
if (!inserted) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- field->_number = get_num_inherited_moleculars();
|
|
|
|
|
- _molecular_fields.push_back(field);
|
|
|
|
|
|
|
+ field->_number = get_num_inherited_fields();
|
|
|
|
|
+ _fields.push_back(field);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|