28DCAtomicField(
const string &name,
DCClass *dclass,
32 _bogus_field = bogus_field;
40 Elements::iterator ei;
41 for (ei = _elements.begin(); ei != _elements.end(); ++ei) {
70 return _elements.size();
78 nassertr(n >= 0 && n < (
int)_elements.size(),
nullptr);
95 nassertr(n >= 0 && n < (
int)_elements.size(), vector_uchar());
96 return _elements[n]->get_default_value();
107 nassertr(n >= 0 && n < (
int)_elements.size(),
false);
108 return _elements[n]->has_default_value();
120 nassertr(n >= 0 && n < (
int)_elements.size(),
string());
121 return _elements[n]->get_name();
130 nassertr(n >= 0 && n < (
int)_elements.size(), ST_invalid);
132 nassertr(simple_parameter !=
nullptr, ST_invalid);
133 return simple_parameter->
get_type();
146 nassertr(n >= 0 && n < (
int)_elements.size(), 1);
148 nassertr(simple_parameter !=
nullptr, 1);
156output(std::ostream &out,
bool brief)
const {
159 if (!_elements.empty()) {
160 Elements::const_iterator ei = _elements.begin();
161 output_element(out, brief, *ei);
163 while (ei != _elements.end()) {
165 output_element(out, brief, *ei);
171 output_keywords(out);
179write(std::ostream &out,
bool brief,
int indent_level)
const {
180 indent(out, indent_level);
183 if (!brief && _number >= 0) {
184 out <<
" // field " << _number;
196 hashgen.
add_int(_elements.size());
197 Elements::const_iterator ei;
198 for (ei = _elements.begin(); ei != _elements.end(); ++ei) {
199 (*ei)->generate_hash(hashgen);
212 nassertr(n >= 0 && n < (
int)_elements.size(),
nullptr);
223 _elements.push_back(element);
224 _num_nested_fields = (int)_elements.size();
227 if (_has_fixed_byte_size) {
231 if (_has_fixed_structure) {
234 if (!_has_range_limits) {
237 if (!_has_default_value) {
240 _default_value_stale =
true;
258do_check_match_atomic_field(
const DCAtomicField *other)
const {
259 if (_elements.size() != other->_elements.size()) {
262 for (
size_t i = 0; i < _elements.size(); i++) {
263 if (!_elements[i]->
check_match(other->_elements[i])) {
275output_element(std::ostream &out,
bool brief,
DCParameter *element)
const {
276 element->output(out, brief);
A single atomic field of a Distributed Class, as read from a .dc file.
bool has_element_default(int n) const
Returns true if the nth element of the field has a default value specified, false otherwise.
int get_element_divisor(int n) const
Returns the divisor associated with the nth element of the field.
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
void add_element(DCParameter *element)
Adds a new element (parameter) to the field.
int get_num_elements() const
Returns the number of elements (parameters) of the atomic field.
std::string get_element_name(int n) const
Returns the name of the nth element of the field.
virtual void write(std::ostream &out, bool brief, int indent_level) const
Generates a parseable description of the object to the indicated output stream.
virtual DCAtomicField * as_atomic_field()
Returns the same field pointer converted to an atomic field pointer, if this is in fact an atomic fie...
DCSubatomicType get_element_type(int n) const
Returns the numeric type of the nth element of the field.
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this field into the hash.
DCParameter * get_element(int n) const
Returns the parameter object describing the nth element.
std::vector< unsigned char > get_element_default(int n) const
Returns the pre-formatted default value associated with the nth element of the field.
Defines a particular DistributedClass as read from an input .dc file.
A single field of a Distributed Class, either atomic or molecular.
bool has_default_value() const
Returns true if a default value has been explicitly established for this field, false otherwise.
const std::vector< unsigned char > & get_default_value() const
Returns the default value for this field.
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this field into the hash.
void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of these keywords into the hash.
This defines the internal interface for packing values into a DCField.
bool has_fixed_structure() const
Returns true if this field type always has the same structure regardless of the data in the stream,...
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.
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.
virtual bool do_check_match_atomic_field(const DCAtomicField *other) const
Returns true if this field matches the indicated atomic field, false otherwise.
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 ...
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...
This class can be used for packing a series of numeric and string data into a binary stream,...
void begin_unpack(const DCPackerInterface *root)
Begins an unpacking session.
bool end_unpack()
Finishes the unpacking session.
void set_unpack_data(const std::vector< unsigned char > &data)
Sets up the unpack_data pointer.
std::string unpack_and_format(bool show_field_names=true)
Unpacks an object and formats its value into a syntax suitable for parsing in the dc file (e....
Represents the type specification for a single parameter within a field specification.
This is the most fundamental kind of parameter type: a single number or string, one of the DCSubatomi...
DCSubatomicType get_type() const
Returns the particular subatomic type represented by this instance.
int get_divisor() const
Returns the divisor associated with this type.
This class generates an arbitrary hash number from a sequence of ints.
void add_int(int num)
Adds another integer to the hash so far.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
DCSubatomicType
This defines the numeric type of each element of a DCAtomicField; that is, the particular values that...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.