Changeset 695 for code/branches/FICN/src/orxonox/core
- Timestamp:
- Dec 27, 2007, 3:44:20 AM (17 years ago)
- Location:
- code/branches/FICN/src/orxonox/core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/core/DebugLevel.cc
r689 r695 31 31 */ 32 32 33 #include "Co nfigValueContainer.h"33 #include "CoreIncludes.h" 34 34 #include "Debug.h" 35 35 #include "DebugLevel.h" … … 39 39 /** 40 40 @brief Constructor: Registers the object and sets the debug level. 41 @param A reference to a global variable, used to avoid an infinite recursion in getSoftDebugLevel() 41 42 */ 42 DebugLevel::DebugLevel( )43 DebugLevel::DebugLevel(bool& bReturnSoftDebugLevel) 43 44 { 44 this->softDebugLevelContainer_ = new ConfigValueContainer(std::string("DebugLevel"), std::string("softDebugLevel_"), this->softDebugLevel_ = 2); 45 this->softDebugLevel_ = this->softDebugLevelContainer_->getValue(this->softDebugLevel_); 45 RegisterRootObject(DebugLevel); 46 this->setConfigValues(); 47 bReturnSoftDebugLevel = true; 48 } 49 50 /** 51 @brief Function to collect the SetConfigValue-macro calls. 52 */ 53 void DebugLevel::setConfigValues() 54 { 55 SetConfigValue(softDebugLevel_, 2); 46 56 } 47 57 … … 51 61 int DebugLevel::getSoftDebugLevel() 52 62 { 53 static DebugLevel theOneAndOnlyInstance = DebugLevel(); 54 return theOneAndOnlyInstance.softDebugLevel_; 63 static bool bCreatingSoftDebugLevelObject = true; // Static variable - used to enhance the performance 64 static bool bReturnSoftDebugLevel = false; // Static variable - used to avoid an infinite recursion 65 static DebugLevel* theOnlyDebugLevelObject = 0; // Static variable - will contain a pointer to the only instance of the DebugLevel class 66 67 // If bReturnSoftDebugLevel is true, the instance of DebugLevel was created (it's set to true at the end of the constructor, call by reference) 68 if (bReturnSoftDebugLevel) 69 return theOnlyDebugLevelObject->softDebugLevel_; 70 71 // If bCreatingSoftDebugLevelObject is true, we're just about to create an instance of the DebugLevel class 72 if (bCreatingSoftDebugLevelObject) 73 { 74 bCreatingSoftDebugLevelObject = false; 75 theOnlyDebugLevelObject = new DebugLevel(bReturnSoftDebugLevel); 76 return theOnlyDebugLevelObject->softDebugLevel_; 77 } 78 79 // Return a constant value while we're creating the object 80 return 4; 55 81 } 56 57 82 } 58 83 -
code/branches/FICN/src/orxonox/core/DebugLevel.h
r689 r695 38 38 39 39 #include "CorePrereqs.h" 40 #include "OrxonoxClass.h" 40 41 41 42 namespace orxonox 42 43 { 43 44 //! The DebugLevel class is a singleton, only used to configure the amount of debug output. 44 class _CoreExport DebugLevel 45 class _CoreExport DebugLevel : public OrxonoxClass 45 46 { 46 47 public: 47 48 static int getSoftDebugLevel(); 49 void setConfigValues(); 50 48 51 private: 49 DebugLevel(); // don't create52 explicit DebugLevel(bool& bReturnSoftDebugLevel); 50 53 DebugLevel(const DebugLevel& dl) {} // don't copy 51 54 ~DebugLevel() {} // don't delete -
code/branches/FICN/src/orxonox/core/OrxonoxClass.cc
r670 r695 43 43 this->bActive_ = true; 44 44 this->bVisible_ = true; 45 46 this->setConfigValues(); 45 47 } 46 48 -
code/branches/FICN/src/orxonox/core/OrxonoxClass.h
r682 r695 57 57 virtual ~OrxonoxClass(); 58 58 59 /** @brief Function to collect the SetConfigValue-macro calls. */ 59 60 void setConfigValues() {}; 60 61
Note: See TracChangeset
for help on using the changeset viewer.