Panda3D
|
Represents the complete list of Distributed Class descriptions as read from a .dc file. More...
#include "dcFile.h"
Classes | |
class | Import |
Public Member Functions | |
bool | add_class (DCClass *dclass) |
Adds the newly-allocated distributed class definition to the file. | |
void | add_import_module (const 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. | |
void | add_import_symbol (const 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. | |
bool | add_keyword (const string &name) |
Adds the indicated keyword string to the list of keywords known to the DCFile. | |
bool | add_switch (DCSwitch *dswitch) |
Adds the newly-allocated switch definition to the file. | |
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. | |
bool | add_typedef (DCTypedef *dtypedef) |
Adds the newly-allocated distributed typedef definition to the file. | |
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"). | |
void | check_inherited_fields () |
Rebuilds all of the inherited fields tables, if necessary. | |
void | clear () |
Removes all of the classes defined within the DCFile and prepares it for reading a new file. | |
void | generate_hash (HashGenerator &hashgen) const |
Accumulates the properties of this file into the hash. | |
DCClass * | get_class (int n) const |
Returns the nth class read from the .dc file(s). | |
DCClass * | get_class_by_name (const string &name) const |
Returns the class that has the indicated name, or NULL if there is no such class. | |
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. | |
unsigned long | get_hash () const |
Returns a 32-bit hash index associated with this file. | |
string | get_import_module (int n) const |
Returns the module named by the nth import line read from the .dc file(s). | |
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). | |
const DCKeyword * | get_keyword (int n) const |
Returns the nth keyword read from the .dc file(s). | |
const DCKeyword * | get_keyword_by_name (const string &name) const |
Returns the keyword that has the indicated name, or NULL if there is no such keyword name. | |
int | get_num_classes () const |
Returns the number of classes read from the .dc file(s). | |
int | get_num_import_modules () const |
Returns the number of import lines read from the .dc file(s). | |
int | get_num_import_symbols (int n) const |
Returns the number of symbols explicitly imported by the nth import line. | |
int | get_num_keywords () const |
Returns the number of keywords read from the .dc file(s). | |
int | get_num_typedefs () const |
Returns the number of typedefs read from the .dc file(s). | |
DCSwitch * | get_switch_by_name (const string &name) const |
Returns the switch that has the indicated name, or NULL if there is no such switch. | |
DCTypedef * | get_typedef (int n) const |
Returns the nth typedef read from the .dc file(s). | |
DCTypedef * | get_typedef_by_name (const string &name) const |
Returns the typedef that has the indicated name, or NULL if there is no such typedef name. | |
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. | |
bool | read (Filename filename) |
Opens and reads the indicated .dc file by name. | |
bool | read (istream &in, const string &filename=string()) |
Parses the already-opened input stream for distributed class descriptions. | |
void | set_new_index_number (DCField *field) |
Sets the next sequential available index number on the indicated field. | |
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. | |
bool | write (ostream &out, bool brief) const |
Writes a parseable description of all the known distributed classes to the stream. |
Represents the complete list of Distributed Class descriptions as read from a .dc file.
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 524 of file dcFile.cxx.
References DCClass::get_name(), get_num_classes(), DCClass::is_bogus_class(), DCClass::is_struct(), and DCClass::set_number().
void DCFile::add_import_module | ( | const 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 586 of file dcFile.cxx.
void DCFile::add_import_symbol | ( | const 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 602 of file dcFile.cxx.
bool DCFile::add_keyword | ( | const 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 650 of file dcFile.cxx.
References DCKeywordList::add_keyword().
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 562 of file dcFile.cxx.
References DCSwitch::get_name().
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 673 of file dcFile.cxx.
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 617 of file dcFile.cxx.
References DCTypedef::get_name(), get_num_typedefs(), DCTypedef::is_bogus_typedef(), DCTypedef::is_implicit_typedef(), and DCTypedef::set_number().
bool DCFile::all_objects_valid | ( | ) | const [inline] |
void DCFile::check_inherited_fields | ( | ) | [inline] |
Rebuilds all of the inherited fields tables, if necessary.
Definition at line 36 of file dcFile.I.
Referenced by DCClass::get_inherited_field(), and DCClass::get_num_inherited_fields().
void DCFile::clear | ( | ) |
Removes all of the classes defined within the DCFile and prepares it for reading a new file.
Definition at line 63 of file dcFile.cxx.
References DCKeywordList::clear_keywords().
void DCFile::generate_hash | ( | HashGenerator & | hashgen | ) | const |
Accumulates the properties of this file into the hash.
Definition at line 497 of file dcFile.cxx.
References HashGenerator::add_int().
Referenced by get_hash().
DCClass * DCFile::get_class | ( | int | n | ) | const |
Returns the nth class read from the .dc file(s).
Definition at line 281 of file dcFile.cxx.
DCClass * DCFile::get_class_by_name | ( | const string & | name | ) | const |
Returns the class that has the indicated name, or NULL if there is no such class.
Definition at line 293 of file dcFile.cxx.
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 333 of file dcFile.cxx.
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 484 of file dcFile.cxx.
References generate_hash(), and HashGenerator::get_hash().
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 361 of file dcFile.cxx.
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 387 of file dcFile.cxx.
const DCKeyword * DCFile::get_keyword | ( | int | n | ) | const |
Returns the nth keyword read from the .dc file(s).
Definition at line 449 of file dcFile.cxx.
References DCKeywordList::get_keyword().
const DCKeyword * DCFile::get_keyword_by_name | ( | const string & | name | ) | const |
Returns the keyword that has the indicated name, or NULL if there is no such keyword name.
Definition at line 460 of file dcFile.cxx.
References DCKeywordList::get_keyword_by_name().
int DCFile::get_num_classes | ( | ) | const |
Returns the number of classes read from the .dc file(s).
Definition at line 271 of file dcFile.cxx.
Referenced by add_class().
int DCFile::get_num_import_modules | ( | ) | const |
Returns the number of import lines read from the .dc file(s).
Definition at line 350 of file dcFile.cxx.
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 375 of file dcFile.cxx.
int DCFile::get_num_keywords | ( | ) | const |
Returns the number of keywords read from the .dc file(s).
Definition at line 439 of file dcFile.cxx.
References DCKeywordList::get_num_keywords().
int DCFile::get_num_typedefs | ( | ) | const |
Returns the number of typedefs read from the .dc file(s).
Definition at line 400 of file dcFile.cxx.
Referenced by add_typedef().
DCSwitch * DCFile::get_switch_by_name | ( | const string & | name | ) | const |
Returns the switch that has the indicated name, or NULL if there is no such switch.
Definition at line 310 of file dcFile.cxx.
DCTypedef * DCFile::get_typedef | ( | int | n | ) | const |
Returns the nth typedef read from the .dc file(s).
Definition at line 410 of file dcFile.cxx.
DCTypedef * DCFile::get_typedef_by_name | ( | const string & | name | ) | const |
Returns the typedef that has the indicated name, or NULL if there is no such typedef name.
Definition at line 422 of file dcFile.cxx.
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 52 of file dcFile.I.
Referenced by DCClass::add_field(), DCClass::add_parent(), and DCField::set_name().
bool DCFile::read | ( | istream & | in, |
const string & | filename = 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 186 of file dcFile.cxx.
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 135 of file dcFile.cxx.
References VirtualFileSystem::close_read_file(), VirtualFileSystem::get_global_ptr(), VirtualFileSystem::open_read_file(), and Filename::set_text().
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 by DCClass::add_field(), while the dc file is being parsed.
Definition at line 686 of file dcFile.cxx.
References DCField::set_number().
Referenced by DCClass::add_field().
bool DCFile::write | ( | 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 233 of file dcFile.cxx.
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 206 of file dcFile.cxx.
References Filename::open_write(), and Filename::set_text().