15 #include "dcClassParameter.h"
17 #include "dcArrayParameter.h"
18 #include "hashGenerator.h"
26 DCClassParameter(
const DCClass *dclass) :
31 int num_fields = _dclass->get_num_inherited_fields();
33 _has_nested_fields =
true;
34 _pack_type = PT_class;
36 if (_dclass->has_constructor()) {
37 DCField *field = _dclass->get_constructor();
38 _nested_fields.push_back(field);
42 for (i = 0 ; i < num_fields; i++) {
43 DCField *field = _dclass->get_inherited_field(i);
45 _nested_fields.push_back(field);
49 _num_nested_fields = _nested_fields.size();
54 _has_fixed_byte_size =
true;
56 _has_fixed_structure =
true;
57 for (i = 0; i < _num_nested_fields; i++) {
75 _nested_fields(copy._nested_fields),
86 as_class_parameter() {
96 as_class_parameter()
const {
142 nassertr(n >= 0 && n < (
int)_nested_fields.size(), NULL);
143 return _nested_fields[n];
154 const string &name,
const string &postname)
const {
183 bool DCClassParameter::
194 bool DCClassParameter::
196 if (_nested_fields.size() != other->_nested_fields.size()) {
199 for (
size_t i = 0; i < _nested_fields.size(); i++) {
200 if (!_nested_fields[i]->
check_match(other->_nested_fields[i])) {
214 bool DCClassParameter::
223 for (
size_t i = 0; i < _nested_fields.size(); i++) {
224 if (!_nested_fields[i]->
check_match(element_type)) {
virtual bool do_check_match_class_parameter(const DCClassParameter *other) const
Returns true if this field matches the indicated class parameter, false otherwise.
This represents a single typedef declaration in the dc file.
void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this class into the hash.
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
const string & get_name() const
Returns the name of this class.
void output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const
Generates a parseable description of the object to the indicated output stream.
This represents a class (or struct) object used as a parameter itself.
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...
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...
Defines a particular DistributedClass as read from an input .dc file.
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 void output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const
Formats the parameter in the C++-like dc syntax as a typename and identifier.
virtual DCMolecularField * as_molecular_field()
Returns the same field pointer converted to a molecular field pointer, if this is in fact a molecular...
const DCTypedef * get_typedef() const
If this type has been referenced from a typedef, returns the DCTypedef instance, or NULL if the type ...
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this type into the hash.
Represents the type specification for a single parameter within a field specification.
This represents an array of some other kind of object, meaning this parameter type accepts an arbitra...
virtual DCPackerInterface * get_nested_field(int n) const
Returns the DCPackerInterface object that represents the nth nested field.
virtual void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of this type into the hash.
This class generates an arbitrary hash number from a sequence of ints.
bool has_fixed_structure() const
Returns true if this field type always has the same structure regardless of the data in the stream...
virtual bool is_valid() const
Returns false if the type is an invalid type (e.g.
void output_typedef_name(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const
Formats the instance like output_instance, but uses the typedef name instead.
bool is_bogus_class() const
Returns true if the class has been flagged as a bogus class.
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 ...
virtual void set_name(const string &name)
Sets the name of this field.
const DCClass * get_class() const
Returns the class object this parameter represents.
DCParameter * get_element_type() const
Returns the type of the individual elements of this array.
int get_array_size() const
Returns the fixed number of elements in this array, or -1 if the array may contain a variable number ...
This defines the internal interface for packing values into a DCField.
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...