Panda3D
|
00001 // Filename: configVariableBase.h 00002 // Created by: drose (21Oct04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef CONFIGVARIABLEBASE_H 00016 #define CONFIGVARIABLEBASE_H 00017 00018 #include "dtoolbase.h" 00019 #include "configFlags.h" 00020 #include "configVariableCore.h" 00021 #include "configDeclaration.h" 00022 #include "configVariableManager.h" 00023 #include "vector_string.h" 00024 #include "pset.h" 00025 00026 // Use this macro to wrap around a description passed to a 00027 // ConfigVariable constructor. This allows the description to be 00028 // completely compiled out, so that it won't even be a part of the 00029 // string table, in the absence of PRC_SAVE_DESCRIPTIONS. 00030 #ifdef PRC_SAVE_DESCRIPTIONS 00031 #define PRC_DESC(description) description 00032 #else 00033 #define PRC_DESC(description) "" 00034 #endif 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Class : ConfigVariableBase 00038 // Description : This class is the base class for both 00039 // ConfigVariableList and ConfigVariable (and hence for 00040 // all of the ConfigVariableBool, ConfigVaribleString, 00041 // etc. classes). It collects together the common 00042 // interface for all generic ConfigVariables. 00043 // 00044 // Mostly, this class serves as a thin wrapper around 00045 // ConfigVariableCore and/or ConfigDeclaration, more or 00046 // less duplicating the interface presented there. 00047 //////////////////////////////////////////////////////////////////// 00048 class EXPCL_DTOOLCONFIG ConfigVariableBase : public ConfigFlags { 00049 protected: 00050 INLINE ConfigVariableBase(const string &name, ValueType type); 00051 ConfigVariableBase(const string &name, ValueType type, 00052 const string &description, int flags); 00053 INLINE ~ConfigVariableBase(); 00054 00055 PUBLISHED: 00056 INLINE const string &get_name() const; 00057 00058 INLINE ValueType get_value_type() const; 00059 INLINE const string &get_description() const; 00060 INLINE int get_flags() const; 00061 INLINE bool is_closed() const; 00062 INLINE int get_trust_level() const; 00063 INLINE bool is_dynamic() const; 00064 00065 INLINE bool clear_local_value(); 00066 INLINE bool has_local_value() const; 00067 INLINE bool has_value() const; 00068 00069 INLINE void output(ostream &out) const; 00070 INLINE void write(ostream &out) const; 00071 00072 protected: 00073 void record_unconstructed() const; 00074 bool was_unconstructed() const; 00075 00076 ConfigVariableCore *_core; 00077 00078 typedef pset<const ConfigVariableBase *> Unconstructed; 00079 static Unconstructed *_unconstructed; 00080 }; 00081 00082 INLINE ostream &operator << (ostream &out, const ConfigVariableBase &variable); 00083 00084 #include "configVariableBase.I" 00085 00086 #endif