Panda3D
 All Classes Functions Variables Enumerations
dcFile.h
1 // Filename: dcFile.h
2 // Created by: drose (05Oct00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef DCFILE_H
16 #define DCFILE_H
17 
18 #include "dcbase.h"
19 #include "dcKeywordList.h"
20 
21 class DCClass;
22 class DCSwitch;
23 class DCField;
24 class HashGenerator;
25 class DCTypedef;
26 class DCKeyword;
27 class DCDeclaration;
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : DCFile
31 // Description : Represents the complete list of Distributed Class
32 // descriptions as read from a .dc file.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_DIRECT DCFile {
35 PUBLISHED:
36  DCFile();
37  ~DCFile();
38 
39  void clear();
40 
41 #ifdef WITHIN_PANDA
42  bool read_all();
43 #endif
44 
45  bool read(Filename filename);
46  bool read(istream &in, const string &filename = string());
47 
48  bool write(Filename filename, bool brief) const;
49  bool write(ostream &out, bool brief) const;
50 
51  int get_num_classes() const;
52  DCClass *get_class(int n) const;
53  DCClass *get_class_by_name(const string &name) const;
54  DCSwitch *get_switch_by_name(const string &name) const;
55 
56  DCField *get_field_by_index(int index_number) const;
57 
58  INLINE bool all_objects_valid() const;
59 
60  int get_num_import_modules() const;
61  string get_import_module(int n) const;
62  int get_num_import_symbols(int n) const;
63  string get_import_symbol(int n, int i) const;
64 
65  int get_num_typedefs() const;
66  DCTypedef *get_typedef(int n) const;
67  DCTypedef *get_typedef_by_name(const string &name) const;
68 
69  int get_num_keywords() const;
70  const DCKeyword *get_keyword(int n) const;
71  const DCKeyword *get_keyword_by_name(const string &name) const;
72 
73  unsigned long get_hash() const;
74 
75 public:
76  void generate_hash(HashGenerator &hashgen) const;
77  bool add_class(DCClass *dclass);
78  bool add_switch(DCSwitch *dswitch);
79  void add_import_module(const string &import_module);
80  void add_import_symbol(const string &import_symbol);
81  bool add_typedef(DCTypedef *dtypedef);
82  bool add_keyword(const string &name);
83  void add_thing_to_delete(DCDeclaration *decl);
84 
85  void set_new_index_number(DCField *field);
86  INLINE void check_inherited_fields();
87  INLINE void mark_inherited_fields_stale();
88 
89 private:
90  void setup_default_keywords();
91  void rebuild_inherited_fields();
92 
93  typedef pvector<DCClass *> Classes;
94  Classes _classes;
95 
96  typedef pmap<string, DCDeclaration *> ThingsByName;
97  ThingsByName _things_by_name;
98 
99  typedef pvector<string> ImportSymbols;
100  class Import {
101  public:
102  string _module;
103  ImportSymbols _symbols;
104  };
105 
106  typedef pvector<Import> Imports;
107  Imports _imports;
108 
109  typedef pvector<DCTypedef *> Typedefs;
110  Typedefs _typedefs;
111 
112  typedef pmap<string, DCTypedef *> TypedefsByName;
113  TypedefsByName _typedefs_by_name;
114 
115  DCKeywordList _keywords;
116  DCKeywordList _default_keywords;
117 
118  typedef pvector<DCDeclaration *> Declarations;
119  Declarations _declarations;
120  Declarations _things_to_delete;
121 
122  typedef pvector<DCField *> FieldsByIndex;
123  FieldsByIndex _fields_by_index;
124 
125  bool _all_objects_valid;
126  bool _inherited_fields_stale;
127 };
128 
129 #include "dcFile.I"
130 
131 #endif
132 
133 
This represents a single keyword declaration in the dc file.
Definition: dcKeyword.h:31
This represents a single typedef declaration in the dc file.
Definition: dcTypedef.h:29
This is our own Panda specialization on the default STL map.
Definition: pmap.h:52
This is a list of keywords (see DCKeyword) that may be set on a particular field. ...
Definition: dcKeywordList.h:28
A single field of a Distributed Class, either atomic or molecular.
Definition: dcField.h:40
This represents a switch statement, which can appear inside a class body and represents two or more a...
Definition: dcSwitch.h:33
Defines a particular DistributedClass as read from an input .dc file.
Definition: dcClass.h:47
Represents the complete list of Distributed Class descriptions as read from a .dc file...
Definition: dcFile.h:34
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:39
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
This is a common interface for a declaration in a DC file.
Definition: dcDeclaration.h:33
This class generates an arbitrary hash number from a sequence of ints.
Definition: hashGenerator.h:26