dcFile.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file dcFile.h
  10. * @author drose
  11. * @date 2000-10-05
  12. */
  13. #ifndef DCFILE_H
  14. #define DCFILE_H
  15. #include "dcbase.h"
  16. #include "dcKeywordList.h"
  17. class DCClass;
  18. class DCSwitch;
  19. class DCField;
  20. class HashGenerator;
  21. class DCTypedef;
  22. class DCKeyword;
  23. class DCDeclaration;
  24. /**
  25. * Represents the complete list of Distributed Class descriptions as read from
  26. * a .dc file.
  27. */
  28. class DCFile {
  29. PUBLISHED:
  30. DCFile();
  31. ~DCFile();
  32. void clear();
  33. #ifdef WITHIN_PANDA
  34. bool read_all();
  35. #endif
  36. bool read(Filename filename);
  37. bool read(istream &in, const string &filename = string());
  38. bool write(Filename filename, bool brief) const;
  39. bool write(ostream &out, bool brief) const;
  40. int get_num_classes() const;
  41. DCClass *get_class(int n) const;
  42. DCClass *get_class_by_name(const string &name) const;
  43. DCSwitch *get_switch_by_name(const string &name) const;
  44. DCField *get_field_by_index(int index_number) const;
  45. INLINE bool all_objects_valid() const;
  46. int get_num_import_modules() const;
  47. string get_import_module(int n) const;
  48. int get_num_import_symbols(int n) const;
  49. string get_import_symbol(int n, int i) const;
  50. int get_num_typedefs() const;
  51. DCTypedef *get_typedef(int n) const;
  52. DCTypedef *get_typedef_by_name(const string &name) const;
  53. int get_num_keywords() const;
  54. const DCKeyword *get_keyword(int n) const;
  55. const DCKeyword *get_keyword_by_name(const string &name) const;
  56. unsigned long get_hash() const;
  57. public:
  58. void generate_hash(HashGenerator &hashgen) const;
  59. bool add_class(DCClass *dclass);
  60. bool add_switch(DCSwitch *dswitch);
  61. void add_import_module(const string &import_module);
  62. void add_import_symbol(const string &import_symbol);
  63. bool add_typedef(DCTypedef *dtypedef);
  64. bool add_keyword(const string &name);
  65. void add_thing_to_delete(DCDeclaration *decl);
  66. void set_new_index_number(DCField *field);
  67. INLINE void check_inherited_fields();
  68. INLINE void mark_inherited_fields_stale();
  69. private:
  70. void setup_default_keywords();
  71. void rebuild_inherited_fields();
  72. typedef pvector<DCClass *> Classes;
  73. Classes _classes;
  74. typedef pmap<string, DCDeclaration *> ThingsByName;
  75. ThingsByName _things_by_name;
  76. typedef pvector<string> ImportSymbols;
  77. class Import {
  78. public:
  79. string _module;
  80. ImportSymbols _symbols;
  81. };
  82. typedef pvector<Import> Imports;
  83. Imports _imports;
  84. typedef pvector<DCTypedef *> Typedefs;
  85. Typedefs _typedefs;
  86. typedef pmap<string, DCTypedef *> TypedefsByName;
  87. TypedefsByName _typedefs_by_name;
  88. DCKeywordList _keywords;
  89. DCKeywordList _default_keywords;
  90. typedef pvector<DCDeclaration *> Declarations;
  91. Declarations _declarations;
  92. Declarations _things_to_delete;
  93. typedef pvector<DCField *> FieldsByIndex;
  94. FieldsByIndex _fields_by_index;
  95. bool _all_objects_valid;
  96. bool _inherited_fields_stale;
  97. };
  98. #include "dcFile.I"
  99. #endif