Changeset 686 for code/branches/FICN/src/orxonox/core
- Timestamp:
- Dec 26, 2007, 7:22:06 PM (17 years ago)
- Location:
- code/branches/FICN/src/orxonox/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/core/DebugLevel.cc
r684 r686 37 37 namespace orxonox 38 38 { 39 DebugLevel* DebugLevel::pointer_s = 0; // Set the static member variable pointer_s to zero40 bool DebugLevel::bCreatingDebugLevelObject_s = false; // Set the static member variable bCreatingDebugLevelObject_s to false41 42 39 /** 43 40 @brief Constructor: Registers the object and sets the debug level. … … 45 42 DebugLevel::DebugLevel() 46 43 { 44 this->softDebugLevel_ = 4; // accounts for the recursive call when creating the object 47 45 RegisterRootObject(DebugLevel); 48 SetConfigValue(softDebugLevel_ s, 2);46 SetConfigValue(softDebugLevel_, 2); 49 47 } 50 48 … … 54 52 int DebugLevel::getSoftDebugLevel() 55 53 { 56 if (!pointer_s && !bCreatingDebugLevelObject_s) 57 { 58 // We need the bCreatingDebugLevelObject_s variable to avoid an infinite recursion: 59 // Creating the object produces debug output and debug output needs the object. 60 bCreatingDebugLevelObject_s = true; 61 pointer_s = new DebugLevel; 62 bCreatingDebugLevelObject_s = false; 63 } 64 else if (bCreatingDebugLevelObject_s) 65 return 4; 66 67 return pointer_s->softDebugLevel_s; 54 static DebugLevel theOneAndOnlyInstance = DebugLevel(); 55 return theOneAndOnlyInstance.softDebugLevel_; 68 56 } 69 57 } -
code/branches/FICN/src/orxonox/core/DebugLevel.h
r684 r686 54 54 ~DebugLevel() {} // don't delete 55 55 56 int softDebugLevel_s; //!< The output level 57 static DebugLevel* pointer_s; //!< A pointer to the only existing instance of this class 58 static bool bCreatingDebugLevelObject_s; //!< True if the only instance is being created (this is needed to avoid recurstion - creating the object produces debug output, debug output needs the object) 56 int softDebugLevel_; //!< The output level 59 57 }; 60 58 }
Note: See TracChangeset
for help on using the changeset viewer.