25 DCMolecularField(
const std::string &name,
DCClass *dclass) :
DCField(name, dclass) {
26 _got_keywords =
false;
52 return _fields.size();
62 nassertr(n >= 0 && n < (
int)_fields.size(),
nullptr);
82 _fields.push_back(atomic);
85 for (
int i = 0; i < num_atomic_fields; i++) {
89 _num_nested_fields = _nested_fields.size();
92 if (_has_fixed_byte_size) {
96 if (_has_fixed_structure) {
99 if (!_has_range_limits) {
102 if (!_has_default_value) {
105 _default_value_stale =
true;
111 void DCMolecularField::
112 output(std::ostream &out,
bool brief)
const {
115 if (!_fields.empty()) {
116 Fields::const_iterator fi = _fields.begin();
117 out <<
" : " << (*fi)->get_name();
119 while (fi != _fields.end()) {
120 out <<
", " << (*fi)->get_name();
133 write(std::ostream &out,
bool brief,
int indent_level)
const {
134 indent(out, indent_level);
137 out <<
" // field " << _number;
150 hashgen.
add_int(_fields.size());
151 Fields::const_iterator fi;
152 for (fi = _fields.begin(); fi != _fields.end(); ++fi) {
153 (*fi)->generate_hash(hashgen);
164 nassertr(n >= 0 && n < (
int)_nested_fields.size(),
nullptr);
165 return _nested_fields[n];
173 bool DCMolecularField::
182 bool DCMolecularField::
184 if (_nested_fields.size() != other->_nested_fields.size()) {
187 for (
size_t i = 0; i < _nested_fields.size(); i++) {
188 if (!_nested_fields[i]->
check_match(other->_nested_fields[i])) {
void add_atomic(DCAtomicField *atomic)
Adds the indicated atomic field to the end of the list of atomic fields that make up the molecular fi...
virtual DCMolecularField * as_molecular_field()
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular...
bool has_fixed_structure() const
Returns true if this field type always has the same structure regardless of the data in the stream,...
void add_int(int num)
Adds another integer to the hash so far.
A single field of a Distributed Class, either atomic or molecular.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool has_fixed_byte_size() const
Returns true if this field type always packs to the same number of bytes, false if it is variable.
int get_num_nested_fields() const
Returns the number of nested fields required by this field type.
Defines a particular DistributedClass as read from an input .dc file.
int get_num_atomics() const
Returns the number of atomic fields that make up this molecular field.
A single atomic field of a Distributed Class, as read from a .dc file.
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this field into the hash.
size_t get_fixed_byte_size() const
If has_fixed_byte_size() returns true, this returns the number of bytes this field type will use.
virtual void write(std::ostream &out, bool brief, int indent_level) const
Generates a parseable description of the object to the indicated output stream.
bool has_range_limits() const
Returns true if this field, or any sub-field of this field, has a limit imposed in the DC file on its...
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
bool check_match(const DCPackerInterface *other) const
Returns true if the other interface is bitwise the same as this oneāthat is, a uint32 only matches a ...
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
bool has_default_value() const
Returns true if a default value has been explicitly established for this field, false otherwise.
This class generates an arbitrary hash number from a sequence of ints.
void copy_keywords(const DCKeywordList &other)
Replaces this keyword list with those from the other list.
virtual bool do_check_match_molecular_field(const DCMolecularField *other) const
Returns true if this field matches the indicated molecular field, false otherwise.
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this field into the hash.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_bogus_field() const
Returns true if the field has been flagged as a bogus field.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A single molecular field of a Distributed Class, as read from a .dc file.
This defines the internal interface for packing values into a DCField.
DCAtomicField * get_atomic(int n) const
Returns the nth atomic field that makes up this molecular field.
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.