Panda3D

Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
DCClass Class Reference

Defines a particular DistributedClass as read from an input .dc file. More...

`#include "dcClass.h"`

Inheritance diagram for DCClass:

## Public Member Functions
| DCClass (DCFile *dc_file, const std::string &name, bool is_struct, bool bogus_class)
bool | add_field (DCField *field)
| Adds the newly-allocated field to the class.
void | add_parent (DCClass *parent)
| Adds a new parent to the inheritance hierarchy of the class.
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.
void | generate_hash (HashGenerator &hashgen) const
| Accumulates the properties of this class into the hash.
DCField * | get_constructor () const
| Returns the constructor method for this class if it is defined, or NULL if the class uses the default constructor.
DCFile * | get_dc_file () const
| Returns the DCFile object that contains the class.
DCField * | get_field (int n) const
| Returns the nth field in the class.
DCField * | get_field_by_index (int index_number) const
| Returns a pointer to the DCField that has the indicated index number.
DCField * | get_field_by_name (const std::string &name) const
| Returns a pointer to the DCField that shares the indicated name.
DCField * | get_inherited_field (int n) const
| Returns the nth field field in the class and all of its ancestors.
const std::string & | get_name () const
| Returns the name of this class.
int | get_num_fields () const
| Returns the number of fields defined directly in this class, ignoring inheritance.
int | get_num_inherited_fields () const
| Returns the total number of field fields defined in this class and all ancestor classes.
int | get_num_parents () const
| Returns the number of base classes this class inherits from.
int | get_number () const
| Returns a unique index number associated with this class.
DCClass * | get_parent (int n) const
| Returns the nth parent class this class inherits from.
bool | has_constructor () const
| Returns true if this class has a constructor method, false if it just uses the default constructor.
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.
bool | is_bogus_class () const
| Returns true if the class has been flagged as a bogus class.
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".
virtual void | output (std::ostream &out) const
| Write a string representation of this instance to <out>.
virtual void | output (std::ostream &out, bool brief) const
| Write a string representation of this instance to <out>.
void | output_instance (std::ostream &out, bool brief, const std::string &prename, const std::string &name, const std::string &postname) const
| Generates a parseable description of the object to the indicated output stream.
void | rebuild_inherited_fields ()
| Recomputes the list of inherited fields for the class.
void | set_number (int number)
| Assigns the unique number to this class.
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.
void | stop_generate ()
| Stops the PStats timer on the "generate" task.
virtual void | write (std::ostream &out, bool brief, int indent_level) const
| Generates a parseable description of the object to the indicated output stream.
Public Member Functions inherited from DCDeclaration
virtual DCSwitch * | as_switch ()
virtual const DCSwitch * | as_switch () const
void | write (std::ostream &out, int indent_level) const
| Write a string representation of this instance to <out>.

## Friends
class | DCField

## Detailed Description

Defines a particular DistributedClass as read from an input .dc file.

Definition at line 44 of file dcClass.h.

## Constructor & Destructor Documentation

## ◆ DCClass()

DCClass::DCClass | ( | DCFile * | dc_file,
|  | const std::string & | name,
|  | bool | is_struct,
|  | bool | bogus_class )

Definition at line 75 of file dcClass.cxx.

## ◆ ~DCClass()

DCClass::~DCClass | ( |  | ) |

Definition at line 98 of file dcClass.cxx.

## Member Function Documentation

## ◆ add_field()

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 1259 of file dcClass.cxx.

References DCField::as_atomic_field(), DCField::get_class(), DCPackerInterface::get_name(), get_num_inherited_fields(), DCField::get_number(), is_struct(), DCField::set_class(), and DCField::set_number().

## ◆ add_parent()

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 1315 of file dcClass.cxx.

## ◆ as_class() [1/2]

DCClass * DCClass::as_class | ( |  | ) |
| virtual

Reimplemented from DCDeclaration.

Definition at line 118 of file dcClass.cxx.

## ◆ as_class() [2/2]

const DCClass * DCClass::as_class | ( |  | ) | const
| virtual

Reimplemented from DCDeclaration.

Definition at line 126 of file dcClass.cxx.

## ◆ clear_inherited_fields()

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 1164 of file dcClass.cxx.

## ◆ generate_hash()

void DCClass::generate_hash | ( | HashGenerator & | hashgen | ) | const

Accumulates the properties of this class into the hash.

Definition at line 1134 of file dcClass.cxx.

References HashGenerator::add_int(), HashGenerator::add_string(), and is_struct().

## ◆ get_constructor()

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 161 of file dcClass.cxx.

## ◆ get_dc_file()

DCFile * DCClass::get_dc_file | ( |  | ) | const
| inline

Returns the DCFile object that contains the class.

Definition at line 17 of file dcClass.I.

## ◆ get_field()

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 180 of file dcClass.cxx.

Referenced by get_inherited_field().

## ◆ get_field_by_index()

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 227 of file dcClass.cxx.

## ◆ get_field_by_name()

DCField * DCClass::get_field_by_name | ( | const std::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 200 of file dcClass.cxx.

## ◆ get_inherited_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 287 of file dcClass.cxx.

References get_field().

Referenced by rebuild_inherited_fields().

## ◆ get_name()

const std::string & DCClass::get_name | ( |  | ) | const
| inline

Returns the name of this class.

Definition at line 25 of file dcClass.I.

Referenced by DCFile::add_class().

## ◆ get_num_fields()

int DCClass::get_num_fields | ( |  | ) | const

Returns the number of fields defined directly in this class, ignoring inheritance.

Definition at line 170 of file dcClass.cxx.

Referenced by get_num_inherited_fields().

## ◆ get_num_inherited_fields()

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 254 of file dcClass.cxx.

References get_num_fields().

Referenced by add_field(), and rebuild_inherited_fields().

## ◆ get_num_parents()

int DCClass::get_num_parents | ( |  | ) | const

Returns the number of base classes this class inherits from.

Definition at line 134 of file dcClass.cxx.

## ◆ get_number()

int DCClass::get_number | ( |  | ) | const
| inline

Returns a unique index number associated with this class.

This is defined implicitly when the .dc file(s) are read.

Definition at line 34 of file dcClass.I.

## ◆ get_parent()

DCClass * DCClass::get_parent | ( | int | n | ) | const

Returns the nth parent class this class inherits from.

Definition at line 142 of file dcClass.cxx.

## ◆ has_constructor()

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 152 of file dcClass.cxx.

## ◆ inherits_from_bogus_class()

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 318 of file dcClass.cxx.

References is_bogus_class().

## ◆ is_bogus_class()

bool DCClass::is_bogus_class | ( |  | ) | const
| 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 54 of file dcClass.I.

Referenced by DCFile::add_class(), and inherits_from_bogus_class().

## ◆ is_struct()

bool DCClass::is_struct | ( |  | ) | const
| 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 43 of file dcClass.I.

Referenced by DCFile::add_class(), add_field(), and generate_hash().

## ◆ output() [1/2]

void DCClass::output | ( | std::ostream & | out | ) | const
| virtual

Write a string representation of this instance to <out>.

Reimplemented from DCDeclaration.

Definition at line 337 of file dcClass.cxx.

## ◆ output() [2/2]

void DCClass::output | ( | std::ostream & | out,
|  | bool | brief ) const
| virtual

Write a string representation of this instance to <out>.

Implements DCDeclaration.

Definition at line 1019 of file dcClass.cxx.

References output_instance().

## ◆ output_instance()

void DCClass::output_instance | ( | std::ostream & | out,
|  | bool | brief,
|  | const std::string & | prename,
|  | const std::string & | name,
|  | const std::string & | postname ) const

Generates a parseable description of the object to the indicated output stream.

Definition at line 1088 of file dcClass.cxx.

Referenced by output().

## ◆ rebuild_inherited_fields()

void DCClass::rebuild_inherited_fields | ( |  | ) |

Recomputes the list of inherited fields for the class.

Definition at line 1172 of file dcClass.cxx.

References get_inherited_field(), DCPackerInterface::get_name(), and get_num_inherited_fields().

## ◆ set_number()

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 1325 of file dcClass.cxx.

Referenced by DCFile::add_class().

## ◆ start_generate()

void DCClass::start_generate | ( |  | ) |
| 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 66 of file dcClass.I.

## ◆ stop_generate()

void DCClass::stop_generate | ( |  | ) |
| inline

Stops the PStats timer on the "generate" task.

This should balance with a preceding call to start_generate().

Definition at line 77 of file dcClass.I.

## ◆ write()

void DCClass::write | ( | std::ostream & | out,
|  | bool | brief,
|  | int | indent_level ) const
| virtual

Generates a parseable description of the object to the indicated output stream.

Implements DCDeclaration.

Definition at line 1028 of file dcClass.cxx.

References indent().

## Friends And Related Symbol Documentation

## ◆ DCField

friend class DCField
| friend

Definition at line 171 of file dcClass.h.

The documentation for this class was generated from the following files:

- direct/src/dcparser/dcClass.h
- direct/src/dcparser/dcClass.cxx
- direct/src/dcparser/dcClass.I