Panda3D

Classes | Public Member Functions | List of all members
DCFile Class Reference

Represents the complete list of Distributed Class descriptions as read from a .dc file. More...

`#include "dcFile.h"`

## Public Member Functions
bool | add_class (DCClass *dclass)
| Adds the newly-allocated distributed class definition to the file. More...
void | add_import_module (const std::string &import_module)
| Adds a new name to the list of names of Python modules that are to be imported by the client or AI to define the code that is associated with the class interfaces named within the .dc file. More...
void | add_import_symbol (const std::string &import_symbol)
| Adds a new name to the list of symbols that are to be explicitly imported from the most-recently added module, e.g. More...
bool | add_keyword (const std::string &name)
| Adds the indicated keyword string to the list of keywords known to the DCFile. More...
bool | add_switch (DCSwitch *dswitch)
| Adds the newly-allocated switch definition to the file. More...
void | add_thing_to_delete (DCDeclaration *decl)
| Adds the indicated declaration to the list of declarations that are not reported with the file, but will be deleted when the DCFile object destructs. More...
bool | add_typedef (DCTypedef *dtypedef)
| Adds the newly-allocated distributed typedef definition to the file. More...
bool | all_objects_valid () const
| Returns true if all of the classes read from the DC file were defined and valid, or false if any of them were undefined ("bogus classes"). More...
void | check_inherited_fields ()
| Rebuilds all of the inherited fields tables, if necessary. More...
void | clear ()
| Removes all of the classes defined within the DCFile and prepares it for reading a new file. More...
void | generate_hash (HashGenerator &hashgen) const
| Accumulates the properties of this file into the hash. More...
DCClass * | get_class (int n) const
| Returns the nth class read from the .dc file(s). More...
DCClass * | get_class_by_name (const std::string &name) const
| Returns the class that has the indicated name, or NULL if there is no such class. More...
DCField * | get_field_by_index (int index_number) const
| Returns a pointer to the one DCField that has the indicated index number, of all the DCFields across all classes in the file. More...
unsigned long | get_hash () const
| Returns a 32-bit hash index associated with this file. More...
std::string | get_import_module (int n) const
| Returns the module named by the nth import line read from the .dc file(s). More...
std::string | get_import_symbol (int n, int i) const
| Returns the ith symbol named by the nth import line read from the .dc file(s). More...
const DCKeyword * | get_keyword (int n) const
| Returns the nth keyword read from the .dc file(s). More...
const DCKeyword * | get_keyword_by_name (const std::string &name) const
| Returns the keyword that has the indicated name, or NULL if there is no such keyword name. More...
int | get_num_classes () const
| Returns the number of classes read from the .dc file(s). More...
int | get_num_import_modules () const
| Returns the number of import lines read from the .dc file(s). More...
int | get_num_import_symbols (int n) const
| Returns the number of symbols explicitly imported by the nth import line. More...
int | get_num_keywords () const
| Returns the number of keywords read from the .dc file(s). More...
int | get_num_typedefs () const
| Returns the number of typedefs read from the .dc file(s). More...
DCSwitch * | get_switch_by_name (const std::string &name) const
| Returns the switch that has the indicated name, or NULL if there is no such switch. More...
DCTypedef * | get_typedef (int n) const
| Returns the nth typedef read from the .dc file(s). More...
DCTypedef * | get_typedef_by_name (const std::string &name) const
| Returns the typedef that has the indicated name, or NULL if there is no such typedef name. More...
void | mark_inherited_fields_stale ()
| Indicates that something has changed in one or more of the inheritance chains or the set of fields; the next time check_inherited_fields() is called, the inherited fields tables of all classes will be rebuilt. More...
bool | read (Filename filename)
| Opens and reads the indicated .dc file by name. More...
bool | read (std::istream &in, const std::string &filename=std::string())
| Parses the already-opened input stream for distributed class descriptions. More...
void | set_new_index_number (DCField *field)
| Sets the next sequential available index number on the indicated field. More...
bool | write (Filename filename, bool brief) const
| Opens the indicated filename for output and writes a parseable description of all the known distributed classes to the file. More...
bool | write (std::ostream &out, bool brief) const
| Writes a parseable description of all the known distributed classes to the stream. More...

## Detailed Description

Represents the complete list of Distributed Class descriptions as read from a .dc file.

Definition at line 32 of file dcFile.h.

## Member Function Documentation

## ◆ add_class()

bool DCFile::add_class | ( | DCClass * | dclass | ) |

Adds the newly-allocated distributed class definition to the file.

The DCFile becomes the owner of the pointer and will delete it when it destructs. Returns true if the class is successfully added, or false if there was a name conflict.

Definition at line 452 of file dcFile.cxx.

References DCClass::get_name(), get_num_classes(), DCClass::is_bogus_class(), DCClass::is_struct(), and DCClass::set_number().

## ◆ add_import_module()

void DCFile::add_import_module | ( | const std::string & | import_module | ) |

Adds a new name to the list of names of Python modules that are to be imported by the client or AI to define the code that is associated with the class interfaces named within the .dc file.

Definition at line 508 of file dcFile.cxx.

## ◆ add_import_symbol()

void DCFile::add_import_symbol | ( | const std::string & | import_symbol | ) |

Adds a new name to the list of symbols that are to be explicitly imported from the most-recently added module, e.g.

"from module_name import symbol". If the list of symbols is empty, the syntax is taken to be "import module_name".

Definition at line 521 of file dcFile.cxx.

## ◆ add_keyword()

bool DCFile::add_keyword | ( | const std::string & | name | ) |

Adds the indicated keyword string to the list of keywords known to the DCFile.

These keywords may then be added to DCFields. It is not an error to add a particular keyword more than once.

Definition at line 563 of file dcFile.cxx.

References DCKeywordList::add_keyword().

## ◆ add_switch()

bool DCFile::add_switch | ( | DCSwitch * | dswitch | ) |

Adds the newly-allocated switch definition to the file.

The DCFile becomes the owner of the pointer and will delete it when it destructs. Returns true if the switch is successfully added, or false if there was a name conflict.

Definition at line 487 of file dcFile.cxx.

References DCSwitch::get_name().

## ◆ add_thing_to_delete()

void DCFile::add_thing_to_delete | ( | DCDeclaration * | decl | ) |

Adds the indicated declaration to the list of declarations that are not reported with the file, but will be deleted when the DCFile object destructs.

That is, transfers ownership of the indicated pointer to the DCFile.

Definition at line 583 of file dcFile.cxx.

## ◆ add_typedef()

bool DCFile::add_typedef | ( | DCTypedef * | dtypedef | ) |

Adds the newly-allocated distributed typedef definition to the file.

The DCFile becomes the owner of the pointer and will delete it when it destructs. Returns true if the typedef is successfully added, or false if there was a name conflict.

Definition at line 533 of file dcFile.cxx.

References DCTypedef::get_name(), get_num_typedefs(), DCTypedef::is_bogus_typedef(), DCTypedef::is_implicit_typedef(), and DCTypedef::set_number().

## ◆ all_objects_valid()

bool DCFile::all_objects_valid | ( |  | ) | const
| inline

Returns true if all of the classes read from the DC file were defined and valid, or false if any of them were undefined ("bogus classes").

If this is true, we might have read a partial file.

Definition at line 19 of file dcFile.I.

## ◆ check_inherited_fields()

void DCFile::check_inherited_fields | ( |  | ) |
| inline

Rebuilds all of the inherited fields tables, if necessary.

Definition at line 27 of file dcFile.I.

## ◆ clear()

void DCFile::clear | ( |  | ) |

Removes all of the classes defined within the DCFile and prepares it for reading a new file.

Definition at line 58 of file dcFile.cxx.

References DCKeywordList::clear_keywords().

## ◆ generate_hash()

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

Accumulates the properties of this file into the hash.

Definition at line 428 of file dcFile.cxx.

Referenced by get_hash().

## ◆ get_class()

DCClass * DCFile::get_class | ( | int | n | ) | const

Returns the nth class read from the .dc file(s).

Definition at line 251 of file dcFile.cxx.

## ◆ get_class_by_name()

DCClass * DCFile::get_class_by_name | ( | const std::string & | name | ) | const

Returns the class that has the indicated name, or NULL if there is no such class.

Definition at line 261 of file dcFile.cxx.

## ◆ get_field_by_index()

DCField * DCFile::get_field_by_index | ( | int | index_number | ) | const

Returns a pointer to the one DCField that has the indicated index number, of all the DCFields across all classes in the file.

This method is only valid if dc-multiple-inheritance is set true in the Config.prc file. Without this setting, different DCFields may share the same index number, so this global lookup is not possible.

Definition at line 295 of file dcFile.cxx.

## ◆ get_hash()

unsigned long DCFile::get_hash | ( |  | ) | const

Returns a 32-bit hash index associated with this file.

This number is guaranteed to be consistent if the contents of the file have not changed, and it is very likely to be different if the contents of the file do change.

Definition at line 418 of file dcFile.cxx.

References generate_hash(), and HashGenerator::get_hash().

## ◆ get_import_module()

string DCFile::get_import_module | ( | int | n | ) | const

Returns the module named by the nth import line read from the .dc file(s).

Definition at line 317 of file dcFile.cxx.

## ◆ get_import_symbol()

string DCFile::get_import_symbol | ( | int | n,
|  | int | i
| ) |  | const

Returns the ith symbol named by the nth import line read from the .dc file(s).

Definition at line 338 of file dcFile.cxx.

## ◆ get_keyword()

const DCKeyword * DCFile::get_keyword | ( | int | n | ) | const

Returns the nth keyword read from the .dc file(s).

Definition at line 388 of file dcFile.cxx.

References DCKeywordList::get_keyword().

## ◆ get_keyword_by_name()

const DCKeyword * DCFile::get_keyword_by_name | ( | const std::string & | name | ) | const

Returns the keyword that has the indicated name, or NULL if there is no such keyword name.

Definition at line 397 of file dcFile.cxx.

References DCKeywordList::get_keyword_by_name().

## ◆ get_num_classes()

int DCFile::get_num_classes | ( |  | ) | const

Returns the number of classes read from the .dc file(s).

Definition at line 243 of file dcFile.cxx.

Referenced by add_class().

## ◆ get_num_import_modules()

int DCFile::get_num_import_modules | ( |  | ) | const

Returns the number of import lines read from the .dc file(s).

Definition at line 309 of file dcFile.cxx.

## ◆ get_num_import_symbols()

int DCFile::get_num_import_symbols | ( | int | n | ) | const

Returns the number of symbols explicitly imported by the nth import line.

If this is 0, the line is "import modulename"; if it is more than 0, the line is "from modulename import symbol, symbol ... ".

Definition at line 328 of file dcFile.cxx.

## ◆ get_num_keywords()

int DCFile::get_num_keywords | ( |  | ) | const

Returns the number of keywords read from the .dc file(s).

Definition at line 380 of file dcFile.cxx.

References DCKeywordList::get_num_keywords().

## ◆ get_num_typedefs()

int DCFile::get_num_typedefs | ( |  | ) | const

Returns the number of typedefs read from the .dc file(s).

Definition at line 348 of file dcFile.cxx.

Referenced by add_typedef().

## ◆ get_switch_by_name()

DCSwitch * DCFile::get_switch_by_name | ( | const std::string & | name | ) | const

Returns the switch that has the indicated name, or NULL if there is no such switch.

Definition at line 276 of file dcFile.cxx.

## ◆ get_typedef()

DCTypedef * DCFile::get_typedef | ( | int | n | ) | const

Returns the nth typedef read from the .dc file(s).

Definition at line 356 of file dcFile.cxx.

## ◆ get_typedef_by_name()

DCTypedef * DCFile::get_typedef_by_name | ( | const std::string & | name | ) | const

Returns the typedef that has the indicated name, or NULL if there is no such typedef name.

Definition at line 366 of file dcFile.cxx.

## ◆ mark_inherited_fields_stale()

void DCFile::mark_inherited_fields_stale | ( |  | ) |
| inline

Indicates that something has changed in one or more of the inheritance chains or the set of fields; the next time check_inherited_fields() is called, the inherited fields tables of all classes will be rebuilt.

Definition at line 39 of file dcFile.I.

Referenced by DCClass::add_parent(), and DCField::set_name().

## ◆ read() [1/2]

bool DCFile::read | ( | Filename | filename | ) |

Opens and reads the indicated .dc file by name.

The distributed classes defined in the file will be appended to the set of distributed classes already recorded, if any.

Returns true if the file is successfully read, false if there was an error (in which case the file might have been partially read).

Definition at line 123 of file dcFile.cxx.

References Filename::set_text().

## ◆ read() [2/2]

bool DCFile::read | ( | std::istream & | in,
|  | const std::string & | filename = `std::string()`
| ) |  |

Parses the already-opened input stream for distributed class descriptions.

The filename parameter is optional and is only used when reporting errors.

The distributed classes defined in the file will be appended to the set of distributed classes already recorded, if any.

Returns true if the file is successfully read, false if there was an error (in which case the file might have been partially read).

Definition at line 168 of file dcFile.cxx.

## ◆ set_new_index_number()

void DCFile::set_new_index_number | ( | DCField * | field | ) |

Sets the next sequential available index number on the indicated field.

This is only meant to be called

Definition at line 592 of file dcFile.cxx.

References DCField::set_number().

## ◆ write() [1/2]

bool DCFile::write | ( | Filename | filename,
|  | bool | brief
| ) |  | const

Opens the indicated filename for output and writes a parseable description of all the known distributed classes to the file.

Returns true if the description is successfully written, false otherwise.

Definition at line 184 of file dcFile.cxx.

References Filename::open_write(), and Filename::set_text().

## ◆ write() [2/2]

bool DCFile::write | ( | std::ostream & | out,
|  | bool | brief
| ) |  | const

Writes a parseable description of all the known distributed classes to the stream.

Returns true if the description is successfully written, false otherwise.

Definition at line 208 of file dcFile.cxx.

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

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