Panda3D
 All Classes Functions Variables Enumerations
dconfig.h
00001 // Filename: dconfig.h
00002 // Created by:  cary (14Jul98)
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 DCONFIG_H
00016 #define DCONFIG_H
00017 
00018 #include "dtoolbase.h"
00019 
00020 #include "config_dconfig.h"
00021 #include "configVariableString.h"
00022 #include "configVariableBool.h"
00023 #include "configVariableInt.h"
00024 #include "configVariableDouble.h"
00025 #include "configVariableList.h"
00026 #include "configFlags.h"
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : DConfig
00030 // Description : This class emulates the old dconfig-style interface
00031 //               to our Panda config system.  It exists only to
00032 //               provide backward-compatible support, and it is used
00033 //               primarily by Python code.  For modern code, use the
00034 //               new ConfigVariable* interface instead of this
00035 //               deprecated interface.
00036 ////////////////////////////////////////////////////////////////////
00037 class EXPCL_DTOOLCONFIG DConfig {
00038 PUBLISHED:
00039   static INLINE bool GetBool(const string &sym, bool def = false);
00040   static INLINE int GetInt(const string &sym, int def = 0);
00041   static INLINE float GetFloat(const string &sym, float def = 0.);
00042   static INLINE double GetDouble(const string &sym, double def = 0.);
00043   static INLINE string GetString(const string &sym, const string &def = "");
00044 };
00045 
00046 #include "dconfig.I"
00047 
00048 
00049 // These macros are used in each directory to call an initialization
00050 // function at static-init time.  These macros may eventually be
00051 // phased out in favor of a simpler interface that does not require
00052 // static init.
00053 
00054 // NOTE:
00055 // Having a macro called Configure proved to be problematic with some
00056 // DX9 headers. To avoid that in the future we provide a new family
00057 // of macros prefixed by DTool and deprecate the old ones, to be
00058 // removed from the codebase sometime in the future.
00059 
00060 // This macro should appear in the config_*.h file.
00061 
00062 #define ConfigureDecl(name, expcl, exptp)
00063 #define DToolConfigureDecl(name, expcl, exptp)
00064 
00065 // This macro defines the actual declaration of the object defined
00066 // above; it should appear in the config_*.cxx file.
00067 
00068 #define ConfigureDef(name) \
00069   class StaticInitializer_ ## name { \
00070   public: \
00071     StaticInitializer_ ## name(); \
00072   }; \
00073   static StaticInitializer_ ## name name;
00074 #define DToolConfigureDef(name) \
00075   class StaticInitializer_ ## name { \
00076   public: \
00077     StaticInitializer_ ## name(); \
00078   }; \
00079   static StaticInitializer_ ## name name;
00080 
00081 // This macro can be used in lieu of the above two when the Configure
00082 // object does not need to be visible outside of the current C file.
00083 
00084 #define Configure(name) ConfigureDef(name)
00085 #define DToolConfigure(name) DToolConfigureDef(name)
00086 
00087 // This one defines a block of code that will be executed at static
00088 // init time.  It must always be defined (in the C file), even if no
00089 // code is to be executed.
00090 
00091 #define ConfigureFn(name) \
00092   StaticInitializer_ ## name::StaticInitializer_ ## name()
00093 #define DToolConfigureFn(name) \
00094   StaticInitializer_ ## name::StaticInitializer_ ## name()
00095 
00096 #endif /* __CONFIG_H__ */
 All Classes Functions Variables Enumerations