Panda3D
|
Defines a particular DistributedClass as read from an input .dc file. More...
#include "dcClass.h"
Public Member Functions | |
DCClass (DCFile *dc_file, const string &name, bool is_struct, bool bogus_class) | |
bool | add_field (DCField *field) |
Adds the newly-allocated field to the class. More... | |
void | add_parent (DCClass *parent) |
Adds a new parent to the inheritance hierarchy of the class. More... | |
virtual DCClass * | as_class () |
virtual const DCClass * | as_class () const |
void | clear_inherited_fields () |
Empties the list of inherited fields for the class, so that it may be rebuilt. More... | |
void | generate_hash (HashGenerator &hashgen) const |
Accumulates the properties of this class into the hash. More... | |
DCField * | get_constructor () const |
Returns the constructor method for this class if it is defined, or NULL if the class uses the default constructor. More... | |
DCFile * | get_dc_file () const |
Returns the DCFile object that contains the class. More... | |
DCField * | get_field (int n) const |
Returns the nth field in the class. More... | |
DCField * | get_field_by_index (int index_number) const |
Returns a pointer to the DCField that has the indicated index number. More... | |
DCField * | get_field_by_name (const string &name) const |
Returns a pointer to the DCField that shares the indicated name. More... | |
DCField * | get_inherited_field (int n) const |
Returns the nth field field in the class and all of its ancestors. More... | |
const string & | get_name () const |
Returns the name of this class. More... | |
int | get_num_fields () const |
Returns the number of fields defined directly in this class, ignoring inheritance. More... | |
int | get_num_inherited_fields () const |
Returns the total number of field fields defined in this class and all ancestor classes. More... | |
int | get_num_parents () const |
Returns the number of base classes this class inherits from. More... | |
int | get_number () const |
Returns a unique index number associated with this class. More... | |
DCClass * | get_parent (int n) const |
Returns the nth parent class this class inherits from. More... | |
bool | has_constructor () const |
Returns true if this class has a constructor method, false if it just uses the default constructor. More... | |
bool | inherits_from_bogus_class () const |
Returns true if this class, or any class in the inheritance heirarchy for this class, is a "bogus" class–a forward reference to an as-yet-undefined class. More... | |
bool | is_bogus_class () const |
Returns true if the class has been flagged as a bogus class. More... | |
bool | is_struct () const |
Returns true if the class has been identified with the "struct" keyword in the dc file, false if it was declared with "dclass". More... | |
virtual void | output (ostream &out) const |
Write a string representation of this instance to <out>. More... | |
virtual void | output (ostream &out, bool brief) const |
Write a string representation of this instance to <out>. More... | |
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. More... | |
void | rebuild_inherited_fields () |
Recomputes the list of inherited fields for the class. More... | |
void | set_number (int number) |
Assigns the unique number to this class. More... | |
void | start_generate () |
Starts the PStats timer going on the "generate" task, that is, marks the beginning of the process of generating a new object, for the purposes of timing this process. More... | |
void | stop_generate () |
Stops the PStats timer on the "generate" task. More... | |
virtual void | write (ostream &out, bool brief, int indent_level) const |
Generates a parseable description of the object to the indicated output stream. More... | |
![]() | |
virtual DCSwitch * | as_switch () |
virtual const DCSwitch * | as_switch () const |
void | write (ostream &out, int indent_level) const |
Write a string representation of this instance to <out>. More... | |
Friends | |
class | DCField |
Defines a particular DistributedClass as read from an input .dc file.
bool DCClass::add_field | ( | DCField * | field | ) |
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 field is successfully added, or false if there was a name conflict or some other problem.
Definition at line 1471 of file dcClass.cxx.
References add_parent(), DCField::as_atomic_field(), DCField::get_class(), DCPackerInterface::get_name(), DCField::get_number(), DCField::set_class(), and DCField::set_number().
Referenced by DCSimpleParameter::generate_hash(), and rebuild_inherited_fields().
void DCClass::add_parent | ( | DCClass * | parent | ) |
Adds a new parent to the inheritance hierarchy of the class.
This is normally called only during parsing.
Definition at line 1529 of file dcClass.cxx.
References set_number().
Referenced by add_field().
void DCClass::clear_inherited_fields | ( | ) |
Empties the list of inherited fields for the class, so that it may be rebuilt.
This is normally only called by DCFile::rebuild_inherited_fields().
Definition at line 1368 of file dcClass.cxx.
References rebuild_inherited_fields().
Referenced by generate_hash().
void DCClass::generate_hash | ( | HashGenerator & | hashgen | ) | const |
Accumulates the properties of this class into the hash.
Definition at line 1336 of file dcClass.cxx.
References HashGenerator::add_int(), HashGenerator::add_string(), and clear_inherited_fields().
Referenced by output_instance().
DCField * DCClass::get_constructor | ( | ) | const |
Returns the constructor method for this class if it is defined, or NULL if the class uses the default constructor.
Definition at line 178 of file dcClass.cxx.
References get_num_fields().
Referenced by has_constructor(), and DCPacker::output_hex_string().
|
inline |
Returns the DCFile object that contains the class.
Definition at line 22 of file dcClass.I.
References get_name().
DCField * DCClass::get_field | ( | int | n | ) | const |
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.
Definition at line 202 of file dcClass.cxx.
References get_field_by_name().
Referenced by get_num_fields().
DCField * DCClass::get_field_by_index | ( | int | index_number | ) | const |
Returns a pointer to the DCField that has the indicated index number.
If the numbered 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.
Definition at line 257 of file dcClass.cxx.
References get_num_inherited_fields().
Referenced by get_field_by_name(), and CConnectionRepository::shutdown().
DCField * DCClass::get_field_by_name | ( | const string & | name | ) | const |
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 field within this class. Returns NULL if there is no such field defined.
Definition at line 226 of file dcClass.cxx.
References get_field_by_index().
Referenced by CDistributedSmoothNodeBase::broadcast_pos_hpr_xy(), and get_field().
DCField * DCClass::get_inherited_field | ( | int | n | ) | const |
Returns the nth field field in the class and all of its ancestors.
This *used* to be the same thing as get_field_by_index(), back when the fields were numbered sequentially within a class's inheritance hierarchy. Now that fields have a globally unique index number, this is no longer true.
Definition at line 324 of file dcClass.cxx.
References inherits_from_bogus_class().
Referenced by get_num_inherited_fields(), and rebuild_inherited_fields().
|
inline |
Returns the name of this class.
Definition at line 32 of file dcClass.I.
References get_number().
Referenced by DCFile::add_class(), get_dc_file(), CConnectionRepository::shutdown(), and DCPacker::unpack_skip().
int DCClass::get_num_fields | ( | ) | const |
Returns the number of fields defined directly in this class, ignoring inheritance.
Definition at line 189 of file dcClass.cxx.
References get_field().
Referenced by get_constructor().
int DCClass::get_num_inherited_fields | ( | ) | const |
Returns the total number of field fields defined in this class and all ancestor classes.
Definition at line 286 of file dcClass.cxx.
References get_inherited_field().
Referenced by get_field_by_index(), and rebuild_inherited_fields().
int DCClass::get_num_parents | ( | ) | const |
Returns the number of base classes this class inherits from.
Definition at line 143 of file dcClass.cxx.
References get_parent().
|
inline |
Returns a unique index number associated with this class.
This is defined implicitly when the .dc file(s) are read.
Definition at line 44 of file dcClass.I.
References is_struct().
Referenced by get_name().
DCClass * DCClass::get_parent | ( | int | n | ) | const |
Returns the nth parent class this class inherits from.
Definition at line 154 of file dcClass.cxx.
References has_constructor().
Referenced by get_num_parents().
bool DCClass::has_constructor | ( | ) | const |
Returns true if this class has a constructor method, false if it just uses the default constructor.
Definition at line 166 of file dcClass.cxx.
References get_constructor().
Referenced by get_parent(), and DCPacker::output_hex_string().
bool DCClass::inherits_from_bogus_class | ( | ) | const |
Returns true if this class, or any class in the inheritance heirarchy for this class, is a "bogus" class–a forward reference to an as-yet-undefined class.
Definition at line 358 of file dcClass.cxx.
References output().
Referenced by get_inherited_field().
|
inline |
Returns true if the class has been flagged as a bogus class.
This is set for classes that are generated by the parser as placeholder for missing classes, as when reading a partial file; it should not occur in a normal valid dc file.
Definition at line 70 of file dcClass.I.
References start_generate().
Referenced by DCFile::add_class(), and is_struct().
|
inline |
Returns true if the class has been identified with the "struct" keyword in the dc file, false if it was declared with "dclass".
Definition at line 56 of file dcClass.I.
References is_bogus_class().
Referenced by DCFile::add_class(), and get_number().
|
virtual |
Write a string representation of this instance to <out>.
Reimplemented from DCDeclaration.
Definition at line 380 of file dcClass.cxx.
References Datagram::append_data(), DCField::as_atomic_field(), DCField::as_molecular_field(), DCPacker::begin_pack(), DCPacker::begin_unpack(), DCPacker::end_pack(), DCPacker::end_unpack(), DatagramIterator::get_current_index(), Datagram::get_data(), DCPacker::get_data(), DatagramIterator::get_datagram(), DCPacker::get_length(), Datagram::get_message(), DCPackerInterface::get_name(), DCAtomicField::get_num_elements(), DCPacker::get_num_unpacked_bytes(), DCField::get_number(), DatagramIterator::get_remaining_size(), DatagramIterator::get_uint16(), DCField::has_default_value(), DCField::is_broadcast(), DCField::is_ownrecv(), DCField::is_required(), DCPacker::pack_default_value(), DCPacker::raw_pack_uint16(), DCPacker::raw_pack_uint32(), DCPacker::raw_pack_uint8(), DCPacker::raw_unpack_uint16(), DCPacker::set_unpack_data(), DatagramIterator::skip_bytes(), and DCPacker::unpack_skip().
Referenced by inherits_from_bogus_class().
|
virtual |
Write a string representation of this instance to <out>.
Implements DCDeclaration.
Definition at line 1214 of file dcClass.cxx.
References write().
void DCClass::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.
Definition at line 1287 of file dcClass.cxx.
References generate_hash().
Referenced by write().
void DCClass::rebuild_inherited_fields | ( | ) |
Recomputes the list of inherited fields for the class.
Definition at line 1378 of file dcClass.cxx.
References add_field(), get_inherited_field(), DCPackerInterface::get_name(), and get_num_inherited_fields().
Referenced by clear_inherited_fields().
void DCClass::set_number | ( | int | number | ) |
Assigns the unique number to this class.
This is normally called only by the DCFile interface as the class is added.
Definition at line 1542 of file dcClass.cxx.
Referenced by DCFile::add_class(), and add_parent().
|
inline |
Starts the PStats timer going on the "generate" task, that is, marks the beginning of the process of generating a new object, for the purposes of timing this process.
This should balance with a corresponding call to stop_generate().
Definition at line 86 of file dcClass.I.
References stop_generate().
Referenced by is_bogus_class().
|
inline |
Stops the PStats timer on the "generate" task.
This should balance with a preceding call to start_generate().
Definition at line 100 of file dcClass.I.
Referenced by start_generate().
|
virtual |
Generates a parseable description of the object to the indicated output stream.
Implements DCDeclaration.
Definition at line 1225 of file dcClass.cxx.
References output_instance().
Referenced by output().