Changeset 695 for code/branches/FICN/src/orxonox/core/DebugLevel.cc
- Timestamp:
- Dec 27, 2007, 3:44:20 AM (16 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.