Changeset 2344 for code/branches/objecthierarchy2/src/core/Core.cc
- Timestamp:
- Dec 4, 2008, 8:28:14 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/core/Core.cc
r2171 r2344 46 46 bool Core::bIsMaster_s = false; 47 47 48 Core* Core::singletonRef_s = 0; 49 48 50 /** 49 51 @brief Constructor: Registers the object and sets the config-values. … … 53 55 { 54 56 RegisterRootObject(Core); 57 58 assert(singletonRef_s == 0); 59 singletonRef_s = this; 60 55 61 this->setConfigValues(); 56 isCreatingCoreSettings() = false;57 62 } 58 63 … … 62 67 Core::~Core() 63 68 { 64 isCreatingCoreSettings() = true; 65 } 66 67 /** 68 @brief Returns true if the Core instance is not yet ready and the static functions have to return a default value. 69 */ 70 bool& Core::isCreatingCoreSettings() 71 { 72 static bool bCreatingCoreSettings = true; 73 return bCreatingCoreSettings; 74 } 75 76 /** 77 @brief Returns a unique instance of Core. 78 @return The instance 79 */ 80 Core& Core::getInstance() 81 { 82 // If bCreatingSoftDebugLevelObject is true, we're just about to create an instance of the DebugLevel class 83 //if (Core::isCreatingCoreSettings()) 84 //{ 85 // isCreatingCoreSettings() = false; 86 // //instance.setConfigValues(); 87 //} 88 89 static bool firstTime = true; 90 if (firstTime) 91 isCreatingCoreSettings() = true; 92 93 static Core instance; 94 return instance; 69 assert(singletonRef_s); 70 singletonRef_s = 0; 95 71 } 96 72 … … 140 116 int Core::getSoftDebugLevel(OutputHandler::OutputDevice device) 141 117 { 142 if (!Core::isCreatingCoreSettings())118 switch (device) 143 119 { 144 switch (device) 145 { 146 case OutputHandler::LD_All: 147 return Core::getInstance().softDebugLevel_; 148 case OutputHandler::LD_Console: 149 return Core::getInstance().softDebugLevelConsole_; 150 case OutputHandler::LD_Logfile: 151 return Core::getInstance().softDebugLevelLogfile_; 152 case OutputHandler::LD_Shell: 153 return Core::getInstance().softDebugLevelShell_; 154 default: 155 assert(0); 156 } 120 case OutputHandler::LD_All: 121 return Core::getInstance().softDebugLevel_; 122 case OutputHandler::LD_Console: 123 return Core::getInstance().softDebugLevelConsole_; 124 case OutputHandler::LD_Logfile: 125 return Core::getInstance().softDebugLevelLogfile_; 126 case OutputHandler::LD_Shell: 127 return Core::getInstance().softDebugLevelShell_; 128 default: 129 assert(0); 130 return 2; 157 131 } 158 159 // Return a constant value while we're creating the object160 return 2;161 132 } 162 133 … … 168 139 void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level) 169 140 { 170 if (!Core::isCreatingCoreSettings()) 171 { 172 if (device == OutputHandler::LD_All) 173 Core::getInstance().softDebugLevel_ = level; 174 else if (device == OutputHandler::LD_Console) 175 Core::getInstance().softDebugLevelConsole_ = level; 176 else if (device == OutputHandler::LD_Logfile) 177 Core::getInstance().softDebugLevelLogfile_ = level; 178 else if (device == OutputHandler::LD_Shell) 179 Core::getInstance().softDebugLevelShell_ = level; 141 if (device == OutputHandler::LD_All) 142 Core::getInstance().softDebugLevel_ = level; 143 else if (device == OutputHandler::LD_Console) 144 Core::getInstance().softDebugLevelConsole_ = level; 145 else if (device == OutputHandler::LD_Logfile) 146 Core::getInstance().softDebugLevelLogfile_ = level; 147 else if (device == OutputHandler::LD_Shell) 148 Core::getInstance().softDebugLevelShell_ = level; 180 149 181 OutputHandler::setSoftDebugLevel(device, level); 182 } 150 OutputHandler::setSoftDebugLevel(device, level); 183 151 } 184 152 … … 188 156 const std::string& Core::getLanguage() 189 157 { 190 if (!Core::isCreatingCoreSettings()) 191 return Core::getInstance().language_; 192 193 return Language::getLanguage().defaultLanguage_; 158 return Core::getInstance().language_; 194 159 } 195 160
Note: See TracChangeset
for help on using the changeset viewer.