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 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 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 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...
 
DCClassget_class (int n) const
 Returns the nth class read from the .dc file(s). More...
 
DCClassget_class_by_name (const string &name) const
 Returns the class that has the indicated name, or NULL if there is no such class. More...
 
DCFieldget_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...
 
string get_import_module (int n) const
 Returns the module named by the nth import line read from the .dc file(s). More...
 
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 DCKeywordget_keyword (int n) const
 Returns the nth keyword read from the .dc file(s). More...
 
const DCKeywordget_keyword_by_name (const 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...
 
DCSwitchget_switch_by_name (const string &name) const
 Returns the switch that has the indicated name, or NULL if there is no such switch. More...
 
DCTypedefget_typedef (int n) const
 Returns the nth typedef read from the .dc file(s). More...
 
DCTypedefget_typedef_by_name (const 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 (istream &in, const string &filename=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 (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 34 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 524 of file dcFile.cxx.

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

Referenced by generate_hash().

◆ add_import_module()

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.

References add_import_symbol().

Referenced by add_switch().

◆ add_import_symbol()

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.

References add_typedef().

Referenced by add_import_module().

◆ add_keyword()

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(), and add_thing_to_delete().

Referenced by add_typedef().

◆ 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 562 of file dcFile.cxx.

References add_import_module(), and DCSwitch::get_name().

Referenced by add_class().

◆ 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 673 of file dcFile.cxx.

References set_new_index_number().

Referenced by add_keyword().

◆ 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 617 of file dcFile.cxx.

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

Referenced by add_import_symbol().

◆ 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 25 of file dcFile.I.

References check_inherited_fields().

◆ check_inherited_fields()

void DCFile::check_inherited_fields ( )
inline

Rebuilds all of the inherited fields tables, if necessary.

Definition at line 36 of file dcFile.I.

References mark_inherited_fields_stale().

Referenced by all_objects_valid().

◆ clear()

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(), ExecutionEnvironment::expand_string(), Filename::from_os_specific(), read(), and ConfigVariableList::size().

◆ generate_hash()

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 add_class(), and HashGenerator::add_int().

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 281 of file dcFile.cxx.

References get_class_by_name().

Referenced by get_num_classes().

◆ get_class_by_name()

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.

References get_switch_by_name().

Referenced by get_class().

◆ 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 333 of file dcFile.cxx.

References get_num_import_modules().

Referenced by get_switch_by_name().

◆ 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 484 of file dcFile.cxx.

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

Referenced by get_keyword_by_name().

◆ 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 361 of file dcFile.cxx.

References get_num_import_symbols().

Referenced by get_num_import_modules().

◆ 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 387 of file dcFile.cxx.

References get_num_typedefs().

Referenced by get_num_import_symbols().

◆ get_keyword()

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(), and get_keyword_by_name().

Referenced by get_num_keywords().

◆ get_keyword_by_name()

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 get_hash(), and DCKeywordList::get_keyword_by_name().

Referenced by get_keyword().

◆ get_num_classes()

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.

References get_class().

Referenced by add_class(), and write().

◆ 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 350 of file dcFile.cxx.

References get_import_module().

Referenced by get_field_by_index().

◆ 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 375 of file dcFile.cxx.

References get_import_symbol().

Referenced by get_import_module().

◆ get_num_keywords()

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 get_keyword(), and DCKeywordList::get_num_keywords().

Referenced by get_typedef_by_name().

◆ get_num_typedefs()

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.

References get_typedef().

Referenced by add_typedef(), and get_import_symbol().

◆ get_switch_by_name()

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.

References get_field_by_index().

Referenced by get_class_by_name().

◆ get_typedef()

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.

References get_typedef_by_name().

Referenced by get_num_typedefs().

◆ get_typedef_by_name()

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.

References get_num_keywords().

Referenced by get_typedef().

◆ 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 52 of file dcFile.I.

Referenced by check_inherited_fields().

◆ 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 135 of file dcFile.cxx.

References VirtualFileSystem::close_read_file(), VirtualFileSystem::get_global_ptr(), VirtualFileSystem::open_read_file(), and Filename::set_text().

Referenced by clear().

◆ read() [2/2]

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.

References write().

◆ 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 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 add_thing_to_delete().

◆ 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 206 of file dcFile.cxx.

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

Referenced by read().

◆ write() [2/2]

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.

References get_num_classes().


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