Changeset 1524 for code/branches/input/src/core
- Timestamp:
- Jun 3, 2008, 12:20:36 AM (17 years ago)
- Location:
- code/branches/input/src/core
- Files:
-
- 2 added
- 9 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/CMakeLists.txt
r1520 r1524 4 4 ConfigFileManager.cc 5 5 ConfigValueContainer.cc 6 Core Settings.cc6 Core.cc 7 7 Error.cc 8 8 Executor.cc … … 27 27 SignalHandler.cc 28 28 TclBind.cc 29 Tickable.cc30 29 XMLPort.cc 31 30 TclThreadManager.cc -
code/branches/input/src/core/Core.cc
r1510 r1524 28 28 29 29 /** 30 @file Core Settings.cc31 @brief Implementation of the Core Settingsclass.30 @file Core.cc 31 @brief Implementation of the Core class. 32 32 */ 33 33 34 #include "Core Settings.h"34 #include "Core.h" 35 35 #include "Language.h" 36 36 #include "CoreIncludes.h" 37 37 #include "ConfigValueIncludes.h" 38 #include "input/InputManager.h" 39 #include "TclThreadManager.h" 38 40 39 41 namespace orxonox … … 43 45 @param A reference to a global variable, used to avoid an infinite recursion in getSoftDebugLevel() 44 46 */ 45 Core Settings::CoreSettings()46 { 47 RegisterRootObject(Core Settings);47 Core::Core() 48 { 49 RegisterRootObject(Core); 48 50 this->setConfigValues(); 49 51 } … … 52 54 @brief Sets the bool to true to avoid static functions accessing a deleted object. 53 55 */ 54 Core Settings::~CoreSettings()56 Core::~Core() 55 57 { 56 58 isCreatingCoreSettings() = true; … … 58 60 59 61 /** 60 @brief Returns true if the Core Settingsinstance is not yet ready and the static functions have to return a default value.61 */ 62 bool& Core Settings::isCreatingCoreSettings()62 @brief Returns true if the Core instance is not yet ready and the static functions have to return a default value. 63 */ 64 bool& Core::isCreatingCoreSettings() 63 65 { 64 66 static bool bCreatingCoreSettings = true; … … 67 69 { 68 70 bFirstTime = false; 69 Core Settings::getInstance();71 Core::getInstance(); 70 72 } 71 73 return bCreatingCoreSettings; … … 73 75 74 76 /** 75 @brief Returns a unique instance of Core Settings.77 @brief Returns a unique instance of Core. 76 78 @return The instance 77 79 */ 78 Core Settings& CoreSettings::getInstance()79 { 80 static Core Settings instance = CoreSettings();80 Core& Core::getInstance() 81 { 82 static Core instance = Core(); 81 83 82 84 // If bCreatingSoftDebugLevelObject is true, we're just about to create an instance of the DebugLevel class 83 if (Core Settings::isCreatingCoreSettings())85 if (Core::isCreatingCoreSettings()) 84 86 { 85 87 isCreatingCoreSettings() = false; … … 92 94 @brief Function to collect the SetConfigValue-macro calls. 93 95 */ 94 void Core Settings::setConfigValues()96 void Core::setConfigValues() 95 97 { 96 98 SetConfigValue(softDebugLevelConsole_, 3).description("The maximal level of debug output shown in the console"); … … 121 123 @return The softDebugLevel 122 124 */ 123 int Core Settings::getSoftDebugLevel(OutputHandler::OutputDevice device)124 { 125 if (!Core Settings::isCreatingCoreSettings())125 int Core::getSoftDebugLevel(OutputHandler::OutputDevice device) 126 { 127 if (!Core::isCreatingCoreSettings()) 126 128 { 127 129 if (device == OutputHandler::LD_All) 128 return Core Settings::getInstance().softDebugLevel_;130 return Core::getInstance().softDebugLevel_; 129 131 else if (device == OutputHandler::LD_Console) 130 return Core Settings::getInstance().softDebugLevelConsole_;132 return Core::getInstance().softDebugLevelConsole_; 131 133 else if (device == OutputHandler::LD_Logfile) 132 return Core Settings::getInstance().softDebugLevelLogfile_;134 return Core::getInstance().softDebugLevelLogfile_; 133 135 else if (device == OutputHandler::LD_Shell) 134 return Core Settings::getInstance().softDebugLevelShell_;136 return Core::getInstance().softDebugLevelShell_; 135 137 } 136 138 … … 144 146 @param level The level 145 147 */ 146 void Core Settings::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)148 void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level) 147 149 { 148 if (!Core Settings::isCreatingCoreSettings())150 if (!Core::isCreatingCoreSettings()) 149 151 { 150 152 if (device == OutputHandler::LD_All) 151 Core Settings::getInstance().softDebugLevel_ = level;153 Core::getInstance().softDebugLevel_ = level; 152 154 else if (device == OutputHandler::LD_Console) 153 Core Settings::getInstance().softDebugLevelConsole_ = level;155 Core::getInstance().softDebugLevelConsole_ = level; 154 156 else if (device == OutputHandler::LD_Logfile) 155 Core Settings::getInstance().softDebugLevelLogfile_ = level;157 Core::getInstance().softDebugLevelLogfile_ = level; 156 158 else if (device == OutputHandler::LD_Shell) 157 Core Settings::getInstance().softDebugLevelShell_ = level;159 Core::getInstance().softDebugLevelShell_ = level; 158 160 } 159 161 } … … 162 164 @brief Returns the configured language. 163 165 */ 164 const std::string& Core Settings::getLanguage()165 { 166 if (!Core Settings::isCreatingCoreSettings())167 return Core Settings::getInstance().language_;166 const std::string& Core::getLanguage() 167 { 168 if (!Core::isCreatingCoreSettings()) 169 return Core::getInstance().language_; 168 170 169 171 return Language::getLanguage().defaultLanguage_; … … 173 175 @brief Sets the language in the config-file back to the default. 174 176 */ 175 void Core Settings::resetLanguage()176 { 177 Core Settings::getInstance().resetLanguageIntern();177 void Core::resetLanguage() 178 { 179 Core::getInstance().resetLanguageIntern(); 178 180 } 179 181 … … 181 183 @brief Sets the language in the config-file back to the default. 182 184 */ 183 void Core Settings::resetLanguageIntern()185 void Core::resetLanguageIntern() 184 186 { 185 187 ResetConfigValue(language_); 188 } 189 190 /** 191 @brief Ticks every core class in a specified sequence. Has to be called 192 every Orxonox tick! 193 @param dt Delta Time 194 */ 195 void Core::tick(float dt) 196 { 197 TclThreadManager::getInstance().tick(dt); 198 InputManager::tick(dt); 186 199 } 187 200 } … … 193 206 int getSoftDebugLevel() 194 207 { 195 return orxonox::Core Settings::getSoftDebugLevel();208 return orxonox::Core::getSoftDebugLevel(); 196 209 } -
code/branches/input/src/core/Core.h
r1510 r1524 28 28 29 29 /** 30 @file Core Settings.h31 @brief Definition of the Core Settingsclass.30 @file Core.h 31 @brief Definition of the Core class. 32 32 33 The Core Settingsclass is a singleton, only used to configure some variables33 The Core class is a singleton, only used to configure some variables 34 34 in the core through the config-file. 35 35 */ … … 45 45 namespace orxonox 46 46 { 47 //! The Core Settingsclass is a singleton, only used to configure some config-values.48 class _CoreExport Core Settings: public OrxonoxClass47 //! The Core class is a singleton, only used to configure some config-values. 48 class _CoreExport Core : public OrxonoxClass 49 49 { 50 50 public: 51 static Core Settings& getInstance();51 static Core& getInstance(); 52 52 static bool& isCreatingCoreSettings(); 53 53 void setConfigValues(); … … 58 58 static void resetLanguage(); 59 59 60 static void tick(float dt); 61 60 62 private: 61 63 void resetLanguageIntern(); 62 64 63 Core Settings();64 Core Settings(const CoreSettings& other);65 virtual ~Core Settings();65 Core(); 66 Core(const Core& other); 67 virtual ~Core(); 66 68 67 69 int softDebugLevel_; //!< The debug level -
code/branches/input/src/core/CorePrereqs.h
r1520 r1524 112 112 class ConfigValueContainer; 113 113 class ConsoleCommand; 114 class Core Settings;114 class Core; 115 115 class Error; 116 116 class Executor; -
code/branches/input/src/core/Language.cc
r1505 r1524 36 36 #include <fstream> 37 37 38 #include "Core Settings.h"38 #include "Core.h" 39 39 40 40 #include "Debug.h" … … 245 245 void Language::readTranslatedLanguageFile() 246 246 { 247 COUT(4) << "Read translated language file (" << Core Settings::getLanguage() << ")." << std::endl;247 COUT(4) << "Read translated language file (" << Core::getLanguage() << ")." << std::endl; 248 248 249 249 // Open the file 250 250 std::ifstream file; 251 file.open(getFileName(Core Settings::getLanguage()).c_str(), std::fstream::in);251 file.open(getFileName(Core::getLanguage()).c_str(), std::fstream::in); 252 252 253 253 if (!file.is_open()) 254 254 { 255 255 COUT(1) << "An error occurred in Language.cc:" << std::endl; 256 COUT(1) << "Error: Couldn't open file " << getFileName(Core Settings::getLanguage()) << " to read the translated language entries!" << std::endl;257 Core Settings::resetLanguage();256 COUT(1) << "Error: Couldn't open file " << getFileName(Core::getLanguage()) << " to read the translated language entries!" << std::endl; 257 Core::resetLanguage(); 258 258 COUT(3) << "Info: Reset language to " << this->defaultLanguage_ << "." << std::endl; 259 259 return; … … 286 286 else 287 287 { 288 COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFileName(Core Settings::getLanguage()) << std::endl;288 COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFileName(Core::getLanguage()) << std::endl; 289 289 } 290 290 } -
code/branches/input/src/core/Language.h
r1505 r1524 113 113 class _CoreExport Language 114 114 { 115 friend class Core Settings;115 friend class Core; 116 116 117 117 public: -
code/branches/input/src/core/OutputHandler.cc
r1505 r1524 33 33 34 34 #include "OutputHandler.h" 35 #include "Core Settings.h"35 #include "Core.h" 36 36 #include "ConsoleCommand.h" 37 37 #include "Shell.h" … … 83 83 int OutputHandler::getSoftDebugLevel(OutputHandler::OutputDevice device) 84 84 { 85 return Core Settings::getSoftDebugLevel(device);85 return Core::getSoftDebugLevel(device); 86 86 } 87 87 -
code/branches/input/src/core/Shell.cc
r1519 r1524 31 31 #include "CoreIncludes.h" 32 32 #include "ConfigValueIncludes.h" 33 #include "Core Settings.h"33 #include "Core.h" 34 34 #include "ConsoleCommand.h" 35 35 #include "input/InputInterfaces.h" … … 67 67 Shell& Shell::createShell() 68 68 { 69 int level = Core Settings::getSoftDebugLevel(OutputHandler::LD_Shell);70 Core Settings::setSoftDebugLevel(OutputHandler::LD_Shell, -1);69 int level = Core::getSoftDebugLevel(OutputHandler::LD_Shell); 70 Core::setSoftDebugLevel(OutputHandler::LD_Shell, -1); 71 71 static Shell instance; 72 Core Settings::setSoftDebugLevel(OutputHandler::LD_Shell, level);72 Core::setSoftDebugLevel(OutputHandler::LD_Shell, level); 73 73 return instance; 74 74 } -
code/branches/input/src/core/TclThreadManager.h
r1505 r1524 30 30 #define _TclThreadManager_H__ 31 31 32 #include "CorePrereqs.h" 33 32 34 #include <queue> 33 35 #include <map> … … 38 40 #include <boost/thread/thread.hpp> 39 41 40 #include "CorePrereqs.h"41 #include "Tickable.h"42 42 #include "cpptcl/CppTcl.h" 43 #include "core/OrxonoxClass.h" 43 44 44 45 namespace orxonox … … 68 69 }; 69 70 70 class _CoreExport TclThreadManager : public Tickable71 class _CoreExport TclThreadManager : public OrxonoxClass 71 72 { 72 73 public: -
code/branches/input/src/core/input/InputManager.cc
r1520 r1524 499 499 @param dt Delta time 500 500 */ 501 void InputManager:: tick(float dt)501 void InputManager::_tick(float dt) 502 502 { 503 503 if (state_ == IS_UNINIT) … … 649 649 activeHandlers_[iHandler].first->tickInput(dt, activeHandlers_[iHandler].second); 650 650 } 651 651 652 652 void InputManager::_completeCalibration() 653 653 { … … 1141 1141 } 1142 1142 1143 void InputManager::tick(float dt) 1144 { 1145 _getSingleton()._tick(dt); 1146 } 1147 1143 1148 // ###### KeyHandler ###### 1144 1149 -
code/branches/input/src/core/input/InputManager.h
r1519 r1524 43 43 #include "ois/OIS.h" 44 44 #include "util/Math.h" 45 #include "core/ Tickable.h"45 #include "core/OrxonoxClass.h" 46 46 #include "InputInterfaces.h" 47 47 … … 89 89 */ 90 90 class _CoreExport InputManager 91 : public TickableReal,91 : public OrxonoxClass, 92 92 public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener 93 93 { … … 143 143 static void calibrate(); 144 144 145 static void tick(float dt); 146 145 147 static bool addKeyHandler (KeyHandler* handler, const std::string& name); 146 148 static bool removeKeyHandler (const std::string& name); … … 191 193 unsigned int _getJoystick(const OIS::JoyStickEvent& arg); 192 194 193 void tick(float dt);195 void _tick(float dt); 194 196 195 197 // input events
Note: See TracChangeset
for help on using the changeset viewer.