configVariableCore.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // Filename: configVariableCore.h
  2. // Created by: drose (15Oct04)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef CONFIGVARIABLECORE_H
  19. #define CONFIGVARIABLECORE_H
  20. #include "dtoolbase.h"
  21. #include "configFlags.h"
  22. #include "configPageManager.h"
  23. #include "pnotify.h"
  24. #include "pvector.h"
  25. #include "pmap.h"
  26. class ConfigDeclaration;
  27. ////////////////////////////////////////////////////////////////////
  28. // Class : ConfigVariableCore
  29. // Description : The internal definition of a ConfigVariable. This
  30. // object is shared between all instances of a
  31. // ConfigVariable that use the same variable name.
  32. //
  33. // You cannot create a ConfigVariableCore instance
  34. // directly; instead, use the make() method, which may
  35. // return a shared instance. Once created, these
  36. // objects are never destructed.
  37. ////////////////////////////////////////////////////////////////////
  38. class EXPCL_DTOOLCONFIG ConfigVariableCore : public ConfigFlags {
  39. private:
  40. ConfigVariableCore(const string &name);
  41. ConfigVariableCore(const ConfigVariableCore &templ, const string &name);
  42. ~ConfigVariableCore();
  43. public:
  44. INLINE const string &get_name() const;
  45. INLINE bool is_used() const;
  46. INLINE ValueType get_value_type() const;
  47. INLINE const string &get_description() const;
  48. INLINE int get_flags() const;
  49. INLINE bool is_closed() const;
  50. INLINE int get_trust_level() const;
  51. INLINE bool is_dynamic() const;
  52. INLINE const ConfigDeclaration *get_default_value() const;
  53. void set_value_type(ValueType value_type);
  54. void set_flags(int flags);
  55. void set_description(const string &description);
  56. void set_default_value(const string &default_value);
  57. INLINE void set_used();
  58. ConfigDeclaration *make_local_value();
  59. bool clear_local_value();
  60. INLINE bool has_local_value() const;
  61. bool has_value() const;
  62. int get_num_declarations() const;
  63. const ConfigDeclaration *get_declaration(int n) const;
  64. INLINE int get_value_seq() const;
  65. INLINE int get_num_references() const;
  66. INLINE const ConfigDeclaration *get_reference(int n) const;
  67. INLINE int get_num_trusted_references() const;
  68. INLINE const ConfigDeclaration *get_trusted_reference(int n) const;
  69. INLINE int get_num_unique_references() const;
  70. INLINE const ConfigDeclaration *get_unique_reference(int n) const;
  71. void output(ostream &out) const;
  72. void write(ostream &out) const;
  73. private:
  74. void add_declaration(ConfigDeclaration *decl);
  75. void remove_declaration(ConfigDeclaration *decl);
  76. INLINE void check_sort_declarations() const;
  77. void sort_declarations();
  78. private:
  79. string _name;
  80. bool _is_used;
  81. ValueType _value_type;
  82. string _description;
  83. int _flags;
  84. ConfigDeclaration *_default_value;
  85. ConfigDeclaration *_local_value;
  86. typedef pvector<const ConfigDeclaration *> Declarations;
  87. Declarations _declarations;
  88. Declarations _trusted_declarations;
  89. Declarations _untrusted_declarations;
  90. Declarations _unique_declarations;
  91. bool _declarations_sorted;
  92. bool _value_queried;
  93. int _value_seq;
  94. friend class ConfigDeclaration;
  95. friend class ConfigVariableManager;
  96. };
  97. INLINE ostream &operator << (ostream &out, const ConfigVariableCore &variable);
  98. #include "configVariableCore.I"
  99. #endif