Changeset 7908 for code/forks/sandbox_light/src/libraries
- Timestamp:
- Feb 17, 2011, 5:47:22 AM (14 years ago)
- Location:
- code/forks/sandbox_light/src/libraries
- Files:
-
- 86 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
code/forks/sandbox_light/src/libraries/CMakeLists.txt
r7401 r7908 24 24 ADD_SUBDIRECTORY(util) 25 25 ADD_SUBDIRECTORY(core) 26 ADD_SUBDIRECTORY(network)27 ADD_SUBDIRECTORY(tools) -
code/forks/sandbox_light/src/libraries/core/CMakeLists.txt
r7284 r7908 20 20 SET_SOURCE_FILES(CORE_SRC_FILES 21 21 CommandLineParser.cc 22 ConfigValueContainer.cc23 22 Core.cc 24 DynLib.cc25 DynLibManager.cc26 Event.cc27 Game.cc28 GameMode.cc29 GameState.cc30 GraphicsManager.cc31 GUIManager.cc32 Language.cc33 LuaState.cc34 ObjectListBase.cc35 OrxonoxClass.cc36 Resource.cc37 WindowEventListener.cc38 39 # hierarchy40 Identifier.cc41 MetaObjectList.cc42 43 # level44 BaseObject.cc45 ClassTreeMask.cc46 Loader.cc47 Namespace.cc48 NamespaceNode.cc49 Template.cc50 XMLPort.cc51 XMLNameListener.cc52 53 COMPILATION_BEGIN FilesystemCompilation.cc54 command/ArgumentCompletionFunctions.cc55 ConfigFileManager.cc56 MemoryArchive.cc57 23 PathConfig.cc 58 COMPILATION_END59 60 # multithreading61 ThreadPool.cc62 COMPILATION_BEGIN ThreadCompilation.cc63 command/TclThreadManager.cc64 Thread.cc65 COMPILATION_END66 24 ) 67 68 ADD_SUBDIRECTORY(command)69 ADD_SUBDIRECTORY(input)70 25 71 26 ORXONOX_ADD_LIBRARY(core 72 27 FIND_HEADER_FILES 73 TOLUA_FILES74 command/CommandExecutor.h75 ConfigFileManager.h76 Game.h77 GameMode.h78 GUIManager.h79 Loader.h80 LuaState.h81 PathConfig.h82 input/InputManager.h83 input/KeyBinder.h84 input/KeyBinderManager.h85 PCH_FILE86 CorePrecompiledHeaders.h87 28 LINK_LIBRARIES 88 ${OGRE_LIBRARY}89 29 ${Boost_FILESYSTEM_LIBRARY} 90 30 ${Boost_SYSTEM_LIBRARY} # Filesystem dependency 91 ${Boost_THREAD_LIBRARY}92 ${Boost_DATE_TIME_LIBRARY} # Thread dependency93 ${CEGUI_LIBRARY}94 ${CEGUILUA_LIBRARY}95 ${LUA_LIBRARIES}96 cpptcl_orxonox97 ogreceguirenderer_orxonox98 ois_orxonox99 tinyxml_orxonox100 tolua_orxonox101 31 util 102 32 SOURCE_FILES -
code/forks/sandbox_light/src/libraries/core/Core.cc
r7872 r7908 51 51 #endif 52 52 53 #include "util/Clock.h"54 53 #include "util/Debug.h" 55 #include "util/Exception.h"56 #include "util/Scope.h"57 #include "util/ScopedSingletonManager.h"58 54 #include "util/SignalHandler.h" 59 55 #include "PathConfig.h" 60 56 #include "CommandLineParser.h" 61 #include "ConfigFileManager.h"62 #include "ConfigValueIncludes.h"63 #include "CoreIncludes.h"64 #include "DynLibManager.h"65 #include "GameMode.h"66 #include "GraphicsManager.h"67 #include "GUIManager.h"68 #include "Identifier.h"69 #include "Language.h"70 #include "LuaState.h"71 #include "command/ConsoleCommand.h"72 #include "command/IOConsole.h"73 #include "command/TclBind.h"74 #include "command/TclThreadManager.h"75 #include "input/InputManager.h"76 57 77 58 namespace orxonox … … 80 61 Core* Core::singletonPtr_s = 0; 81 62 82 SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file");83 SetCommandLineSwitch(noIOConsole).information("Use this if you don't want to use the IOConsole (for instance for Lua debugging)");84 85 63 #ifdef ORXONOX_PLATFORM_WINDOWS 86 64 SetCommandLineArgument(limitToCPU, 1).information("Limits the program to one CPU/core (1, 2, 3, etc.). Default is the first core (faster than off)"); … … 88 66 89 67 Core::Core(const std::string& cmdLine) 90 // Cleanup guard for identifier destruction (incl. XMLPort, configValues, consoleCommands)91 : identifierDestroyer_(Identifier::destroyAllIdentifiers)92 // Cleanup guard for external console commands that don't belong to an Identifier93 , consoleCommandDestroyer_(ConsoleCommand::destroyAll)94 , bGraphicsLoaded_(false)95 , bStartIOConsole_(true)96 , lastLevelTimestamp_(0)97 , ogreConfigTimestamp_(0)98 68 { 99 69 // Set the hard coded fixed paths 100 70 this->pathConfig_.reset(new PathConfig()); 101 102 // Create a new dynamic library manager103 this->dynLibManager_.reset(new DynLibManager());104 105 // Load modules106 const std::vector<std::string>& modulePaths = this->pathConfig_->getModulePaths();107 for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)108 {109 try110 {111 this->dynLibManager_->load(*it);112 }113 catch (...)114 {115 COUT(1) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << std::endl;116 }117 }118 71 119 72 // Parse command line arguments AFTER the modules have been loaded (static code!) … … 143 96 #endif 144 97 145 // Manage ini files and set the default settings file (usually orxonox.ini)146 this->configFileManager_.reset(new ConfigFileManager());147 this->configFileManager_->setFilename(ConfigFileType::Settings,148 CommandLineParser::getValue("settingsFile").getString());149 150 // Required as well for the config values151 this->languageInstance_.reset(new Language());152 153 // Do this soon after the ConfigFileManager has been created to open up the154 // possibility to configure everything below here155 ClassIdentifier<Core>::getIdentifier("Core")->initialiseObject(this, "Core", true);156 this->setConfigValues();157 158 // create persistent io console159 if (CommandLineParser::getValue("noIOConsole").getBool())160 {161 ModifyConfigValue(bStartIOConsole_, tset, false);162 }163 if (this->bStartIOConsole_)164 this->ioConsole_.reset(new IOConsole());165 166 // creates the class hierarchy for all classes with factories167 Identifier::createClassHierarchy();168 169 // Load OGRE excluding the renderer and the render window170 this->graphicsManager_.reset(new GraphicsManager(false));171 172 // initialise Tcl173 this->tclBind_.reset(new TclBind(PathConfig::getDataPathString()));174 this->tclThreadManager_.reset(new TclThreadManager(tclBind_->getTclInterpreter()));175 176 // Create singletons that always exist (in other libraries)177 this->rootScope_.reset(new Scope<ScopeID::Root>());178 179 98 // Generate documentation instead of normal run? 180 99 std::string docFilename; … … 199 118 Core::~Core() 200 119 { 201 // Remove us from the object lists again to avoid problems when destroying them202 this->unregisterObject();203 }204 205 //! Function to collect the SetConfigValue-macro calls.206 void Core::setConfigValues()207 {208 #ifdef ORXONOX_RELEASE209 const unsigned int defaultLevelLogFile = 3;210 #else211 const unsigned int defaultLevelLogFile = 4;212 #endif213 SetConfigValueExternal(softDebugLevelLogFile_, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile)214 .description("The maximum level of debug output shown in the log file");215 OutputHandler::getInstance().setSoftDebugLevel(OutputHandler::logFileOutputListenerName_s, this->softDebugLevelLogFile_);216 217 SetConfigValue(language_, Language::getInstance().defaultLanguage_)218 .description("The language of the in game text")219 .callback(this, &Core::languageChanged);220 SetConfigValue(bInitRandomNumberGenerator_, true)221 .description("If true, all random actions are different each time you start the game")222 .callback(this, &Core::initRandomNumberGenerator);223 SetConfigValue(bStartIOConsole_, true)224 .description("Set to false if you don't want to use the IOConsole (for Lua debugging for instance)");225 SetConfigValue(lastLevelTimestamp_, 0)226 .description("Timestamp when the last level was started.");227 SetConfigValue(ogreConfigTimestamp_, 0)228 .description("Timestamp when the ogre config file was changed.");229 }230 231 //! Callback function if the language has changed.232 void Core::languageChanged()233 {234 // Read the translation file after the language was configured235 Language::getInstance().readTranslatedLanguageFile();236 120 } 237 121 … … 245 129 bInitialized = true; 246 130 } 247 }248 249 void Core::loadGraphics()250 {251 // Any exception should trigger this, even in upgradeToGraphics (see its remarks)252 Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics);253 254 // Upgrade OGRE to receive a render window255 try256 {257 graphicsManager_->upgradeToGraphics();258 }259 catch (const InitialisationFailedException&)260 {261 // Exit the application if the Ogre config dialog was canceled262 COUT(1) << Exception::handleMessage() << std::endl;263 exit(EXIT_FAILURE);264 }265 catch (...)266 {267 // Recovery from this is very difficult. It requires to completely268 // destroy Ogre related objects and load again (without graphics).269 // However since Ogre 1.7 there seems to be a problem when Ogre270 // throws an exception and the graphics engine then gets destroyed271 // and reloaded between throw and catch (access violation in MSVC).272 // That's why we abort completely and only display the exception.273 COUT(1) << "An exception occurred during upgrade to graphics. "274 << "That is unrecoverable. The message was:" << endl275 << Exception::handleMessage() << endl;276 abort();277 }278 279 // Calls the InputManager which sets up the input devices.280 inputManager_.reset(new InputManager());281 282 // Load the CEGUI interface283 guiManager_.reset(new GUIManager(inputManager_->getMousePosition()));284 285 bGraphicsLoaded_ = true;286 GameMode::bShowsGraphics_s = true;287 288 // Load some sort of a debug overlay (only denoted by its name, "debug.oxo")289 graphicsManager_->loadDebugOverlay();290 291 // Create singletons associated with graphics (in other libraries)292 graphicsScope_.reset(new Scope<ScopeID::Graphics>());293 294 unloader.Dismiss();295 }296 297 void Core::unloadGraphics()298 {299 this->graphicsScope_.reset();300 this->guiManager_.reset();301 this->inputManager_.reset();302 this->graphicsManager_.reset();303 304 // Load Ogre::Root again, but without the render system305 try306 { this->graphicsManager_.reset(new GraphicsManager(false)); }307 catch (...)308 {309 COUT(0) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << std::endl310 << "Another exception might be being handled which may lead to undefined behaviour!" << std::endl311 << "Terminating the program." << std::endl;312 abort();313 }314 315 bGraphicsLoaded_ = false;316 GameMode::bShowsGraphics_s = false;317 }318 319 //! Sets the language in the config-file back to the default.320 void Core::resetLanguage()321 {322 ResetConfigValue(language_);323 131 } 324 132 … … 368 176 #endif 369 177 } 370 371 void Core::preUpdate(const Clock& time)372 {373 // Update singletons before general ticking374 ScopedSingletonManager::preUpdate<ScopeID::Root>(time);375 if (this->bGraphicsLoaded_)376 {377 // Process input events378 this->inputManager_->preUpdate(time);379 // Update GUI380 this->guiManager_->preUpdate(time);381 // Update singletons before general ticking382 ScopedSingletonManager::preUpdate<ScopeID::Graphics>(time);383 }384 // Process console events and status line385 if (this->ioConsole_ != NULL)386 this->ioConsole_->preUpdate(time);387 // Process thread commands388 this->tclThreadManager_->preUpdate(time);389 }390 391 void Core::postUpdate(const Clock& time)392 {393 // Update singletons just before rendering394 ScopedSingletonManager::postUpdate<ScopeID::Root>(time);395 if (this->bGraphicsLoaded_)396 {397 // Update singletons just before rendering398 ScopedSingletonManager::postUpdate<ScopeID::Graphics>(time);399 // Render (doesn't throw)400 this->graphicsManager_->postUpdate(time);401 }402 }403 404 void Core::updateLastLevelTimestamp()405 {406 ModifyConfigValue(lastLevelTimestamp_, set, static_cast<long long>(time(NULL)));407 }408 409 void Core::updateOgreConfigTimestamp()410 {411 ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL)));412 }413 178 } -
code/forks/sandbox_light/src/libraries/core/Core.h
r7870 r7908 46 46 #include <string> 47 47 #include <boost/scoped_ptr.hpp> 48 #include <loki/ScopeGuard.h>49 48 50 49 #include "util/Singleton.h" 51 #include "OrxonoxClass.h"52 50 53 51 namespace orxonox … … 59 57 You should only create this singleton once because it destroys the identifiers! 60 58 */ 61 class _CoreExport Core : public Singleton<Core> , public OrxonoxClass59 class _CoreExport Core : public Singleton<Core> 62 60 { 63 typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard;64 61 friend class Singleton<Core>; 65 friend class Game;66 62 67 63 public: … … 76 72 ~Core(); 77 73 78 void setConfigValues();79 80 //! Returns the configured language.81 const std::string& getLanguage()82 { return this->language_; }83 void resetLanguage();84 85 void updateLastLevelTimestamp();86 inline long long getLastLevelTimestamp() const87 { return this->lastLevelTimestamp_; }88 89 void updateOgreConfigTimestamp();90 inline long long getOgreConfigTimestamp() const91 { return this->ogreConfigTimestamp_; }92 93 74 private: 94 75 Core(const Core&); //!< Don't use (undefined symbol) 95 76 96 void languageChanged();97 77 void initRandomNumberGenerator(); 98 78 99 void preUpdate(const Clock& time); 100 void postUpdate(const Clock& time); 79 void setThreadAffinity(int limitToCPU); 101 80 102 void loadGraphics();103 void unloadGraphics();104 105 void setThreadAffinity(int limitToCPU);106 81 // MANAGED SINGLETONS/OBJECTS 107 82 // Mind the order for the destruction! 108 83 scoped_ptr<PathConfig> pathConfig_; 109 scoped_ptr<DynLibManager> dynLibManager_;110 84 scoped_ptr<SignalHandler> signalHandler_; 111 SimpleScopeGuard identifierDestroyer_;112 SimpleScopeGuard consoleCommandDestroyer_;113 scoped_ptr<ConfigFileManager> configFileManager_;114 scoped_ptr<Language> languageInstance_;115 scoped_ptr<IOConsole> ioConsole_;116 scoped_ptr<TclBind> tclBind_;117 scoped_ptr<TclThreadManager> tclThreadManager_;118 scoped_ptr<Scope<ScopeID::Root> > rootScope_;119 // graphical120 scoped_ptr<GraphicsManager> graphicsManager_; //!< Interface to OGRE121 scoped_ptr<InputManager> inputManager_; //!< Interface to OIS122 scoped_ptr<GUIManager> guiManager_; //!< Interface to GUI123 scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_;124 85 125 bool bGraphicsLoaded_;126 86 int softDebugLevelLogFile_; //!< The debug level for the log file (belongs to OutputHandler) 127 std::string language_; //!< The language128 87 bool bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called 129 bool bStartIOConsole_; //!< Set to false if you don't want to use the IOConsole130 long long lastLevelTimestamp_; ///< Timestamp when the last level was started131 long long ogreConfigTimestamp_; ///< Timestamp wehen the ogre config level was modified132 88 133 89 static Core* singletonPtr_s; -
code/forks/sandbox_light/src/libraries/core/CorePrereqs.h
r7849 r7908 65 65 namespace orxonox 66 66 { 67 static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);68 67 } 69 68 … … 74 73 namespace orxonox 75 74 { 76 namespace XMLPort77 {78 enum Mode79 {80 NOP,81 LoadObject,82 SaveObject,83 ExpandObject84 };85 }86 87 namespace ConfigFileType88 {89 enum Value90 {91 Settings,92 JoyStickCalibration,93 CommandHistory94 // Don't forget to adjust the array size in the ConfigFileManager when adding a new entry here!95 };96 }97 98 namespace KeybindMode99 {100 enum Value101 {102 OnPress,103 OnHold,104 OnRelease,105 None106 };107 };108 75 } 109 76 … … 114 81 namespace orxonox 115 82 { 116 typedef std::string LanguageEntryLabel;117 118 template <class T, class U>119 T orxonox_cast(U*);120 121 class BaseObject;122 template <class T>123 class ClassFactory;124 template <class T>125 class ClassIdentifier;126 class ClassTreeMask;127 class ClassTreeMaskIterator;128 class ClassTreeMaskNode;129 class ClassTreeMaskObjectIterator;130 83 class CommandLineParser; 131 84 class CommandLineArgument; 132 class ConfigFile;133 class ConfigFileEntry;134 class ConfigFileEntryComment;135 class ConfigFileEntryValue;136 class ConfigFileManager;137 class ConfigFileSection;138 class ConfigValueContainer;139 85 class Core; 140 class DestructionListener;141 class DynLib;142 class DynLibManager;143 struct Event;144 class EventState;145 class Factory;146 class Game;147 class GameState;148 struct GameStateInfo;149 struct GameStateTreeNode;150 class GraphicsManager;151 class GUIManager;152 class Identifier;153 template <class T>154 class Iterator;155 class Language;156 class LuaFunctor;157 class LuaState;158 class MemoryArchive;159 class MemoryArchiveFactory;160 class MetaObjectList;161 class MetaObjectListElement;162 class Namespace;163 class NamespaceNode;164 template <class T>165 class ObjectList;166 class ObjectListBase;167 class ObjectListBaseElement;168 template <class T>169 class ObjectListElement;170 template <class T>171 class ObjectListIterator;172 class OgreWindowEventListener;173 class OrxonoxClass;174 86 class PathConfig; 175 struct ResourceInfo;176 class SettingsConfigFile;177 template <class T>178 class SmartPtr;179 template <class T>180 class SubclassIdentifier;181 class Template;182 class Thread;183 class ThreadPool;184 template <class T>185 class WeakPtr;186 class WindowEventListener;187 class XMLFile;188 class XMLNameListener;189 template <class T, class O>190 class XMLPortClassObjectContainer;191 template <class T>192 class XMLPortClassParamContainer;193 class XMLPortObjectContainer;194 class XMLPortParamContainer;195 196 // Command197 class ArgumentCompleter;198 class ArgumentCompletionListElement;199 class CommandEvaluation;200 class ConsoleCommand;201 class Executor;202 template <class T>203 class ExecutorMember;204 class ExecutorStatic;205 class Functor;206 template <class O>207 class FunctorMember;208 typedef FunctorMember<void> FunctorStatic;209 template <class F, class O>210 class FunctorPointer;211 class IOConsole;212 class IRC;213 class Shell;214 class ShellListener;215 class TclBind;216 struct TclInterpreterBundle;217 template <class T>218 class TclThreadList;219 class TclThreadManager;220 221 // Input222 class BaseCommand;223 class BufferedParamCommand;224 class Button;225 class HalfAxis;226 class InputBuffer;227 class InputDevice;228 template <class Traits>229 class InputDeviceTemplated;230 class InputHandler;231 class InputManager;232 class InputState;233 struct InputStatePriority;234 class JoyStickQuantityListener;235 class JoyStick;236 class KeyBinder;237 class KeyBinderManager;238 class Keyboard;239 class KeyDetector;240 class KeyEvent;241 class Mouse;242 class ParamCommand;243 class SimpleCommand;244 }245 246 #include "command/FunctorPtr.h"247 #include "command/ExecutorPtr.h"248 249 // CppTcl250 namespace Tcl251 {252 class interpreter;253 class object;254 87 } 255 88 … … 278 111 } 279 112 #endif 280 class thread;281 class mutex;282 class shared_mutex;283 class condition_variable;284 }285 286 // Ogre287 namespace Ogre288 {289 class DataStream;290 template <class T> class SharedPtr;291 typedef SharedPtr<DataStream> DataStreamPtr;292 }293 namespace orxonox294 {295 // Import the Ogre::DataStream296 using Ogre::DataStream;297 using Ogre::DataStreamPtr;298 }299 300 // CEGUI301 namespace CEGUI302 {303 class DefaultLogger;304 class Logger;305 class LuaScriptModule;306 307 class OgreCEGUIRenderer;308 class OgreCEGUIResourceProvider;309 class OgreCEGUITexture;310 }311 312 // Lua313 struct lua_State;314 315 // TinyXML and TinyXML++316 class TiXmlString;317 class TiXmlOutStream;318 class TiXmlNode;319 class TiXmlHandle;320 class TiXmlDocument;321 class TiXmlElement;322 class TiXmlComment;323 class TiXmlUnknown;324 class TiXmlAttribute;325 class TiXmlText;326 class TiXmlDeclaration;327 class TiXmlParsingData;328 namespace ticpp329 {330 class Document;331 class Element;332 class Declaration;333 class StylesheetReference;334 class Text;335 class Comment;336 class Attribute;337 }338 namespace orxonox339 {340 using ticpp::Element;341 113 } 342 114 -
code/forks/sandbox_light/src/libraries/core/PathConfig.cc
r6417 r7908 76 76 : rootPath_(*(new bf::path())) 77 77 , executablePath_(*(new bf::path())) 78 , modulePath_(*(new bf::path()))79 78 , dataPath_(*(new bf::path())) 80 , externalDataPath_(*(new bf::path()))81 79 , configPath_(*(new bf::path())) 82 80 , logPath_(*(new bf::path())) … … 138 136 COUT(1) << "Running from the build tree." << std::endl; 139 137 PathConfig::bDevRun_ = true; 140 modulePath_ = specialConfig::moduleDevDirectory;141 138 } 142 139 else … … 153 150 ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?"); 154 151 155 // Module path is fixed as well156 modulePath_ = rootPath_ / specialConfig::defaultModulePath;157 158 152 #else 159 153 160 154 // There is no root path, so don't set it at all 161 // Module path is fixed as well162 modulePath_ = specialConfig::moduleInstallDirectory;163 155 164 156 #endif … … 170 162 delete &rootPath_; 171 163 delete &executablePath_; 172 delete &modulePath_;173 164 delete &dataPath_; 174 delete &externalDataPath_;175 165 delete &configPath_; 176 166 delete &logPath_; … … 184 174 configPath_ = specialConfig::configDevDirectory; 185 175 logPath_ = specialConfig::logDevDirectory; 186 187 // Check for data path override by the command line188 if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue())189 externalDataPath_ = CommandLineParser::getValue("externalDataPath").getString();190 else191 externalDataPath_ = specialConfig::externalDataDevDirectory;192 176 } 193 177 else … … 251 235 } 252 236 253 std::vector<std::string> PathConfig::getModulePaths()254 {255 std::vector<std::string> modulePaths;256 257 // We search for helper files with the following extension258 const std::string& moduleextension = specialConfig::moduleExtension;259 size_t moduleextensionlength = moduleextension.size();260 261 // Add that path to the PATH variable in case a module depends on another one262 std::string pathVariable(getenv("PATH"));263 putenv(const_cast<char*>(("PATH=" + pathVariable + ';' + modulePath_.string()).c_str()));264 265 // Make sure the path exists, otherwise don't load modules266 if (!boost::filesystem::exists(modulePath_))267 return modulePaths;268 269 boost::filesystem::directory_iterator file(modulePath_);270 boost::filesystem::directory_iterator end;271 272 // Iterate through all files273 while (file != end)274 {275 const std::string& filename = file->BOOST_LEAF_FUNCTION();276 277 // Check if the file ends with the exension in question278 if (filename.size() > moduleextensionlength)279 {280 if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)281 {282 // We've found a helper file283 const std::string& library = filename.substr(0, filename.size() - moduleextensionlength);284 modulePaths.push_back((modulePath_ / library).file_string());285 }286 }287 ++file;288 }289 290 return modulePaths;291 }292 293 237 /*static*/ std::string PathConfig::getRootPathString() 294 238 { … … 306 250 } 307 251 308 /*static*/ std::string PathConfig::getExternalDataPathString()309 {310 return getInstance().externalDataPath_.string() + '/';311 }312 313 252 /*static*/ std::string PathConfig::getConfigPathString() 314 253 { … … 320 259 return getInstance().logPath_.string() + '/'; 321 260 } 322 323 /*static*/ std::string PathConfig::getModulePathString()324 {325 return getInstance().modulePath_.string() + '/';326 }327 261 } -
code/forks/sandbox_light/src/libraries/core/PathConfig.h
r7427 r7908 85 85 static const boost::filesystem::path& getDataPath() 86 86 { return getInstance().dataPath_; } 87 //! Returns the path to the external data files as boost::filesystem::path88 static const boost::filesystem::path& getExternalDataPath()89 { return getInstance().externalDataPath_; }90 87 //! Returns the path to the config files as boost::filesystem::path 91 88 static const boost::filesystem::path& getConfigPath() … … 94 91 static const boost::filesystem::path& getLogPath() 95 92 { return getInstance().logPath_; } 96 //! Returns the path to the modules as boost::filesystem::path97 static const boost::filesystem::path& getModulePath()98 { return getInstance().modulePath_; }99 93 100 94 //! Returns the path to the root folder as std::string … … 104 98 //! Returns the path to the data files as std::string 105 99 static std::string getDataPathString(); 106 //! Returns the path to the external data files as std::string107 static std::string getExternalDataPathString();108 100 //! Returns the path to the config files as std::string 109 101 static std::string getConfigPathString(); //tolua_export 110 102 //! Returns the path to the log files as std::string 111 103 static std::string getLogPathString(); 112 //! Returns the path to the modules as std::string113 static std::string getModulePathString();114 104 115 105 //! Return trrue for runs in the build directory (not installed) … … 126 116 */ 127 117 void setConfigurablePaths(); 128 //! Returns a list with all modules declared by a *.module file in the module folder.129 std::vector<std::string> getModulePaths();130 118 131 119 //! Path to the parent directory of the ones above if program was installed with relativ paths 132 120 boost::filesystem::path& rootPath_; 133 121 boost::filesystem::path& executablePath_; //!< Path to the executable 134 boost::filesystem::path& modulePath_; //!< Path to the modules135 122 boost::filesystem::path& dataPath_; //!< Path to the data files folder 136 boost::filesystem::path& externalDataPath_; //!< Path to the external data files folder137 123 boost::filesystem::path& configPath_; //!< Path to the config files folder 138 124 boost::filesystem::path& logPath_; //!< Path to the log files folder -
code/forks/sandbox_light/src/libraries/util/CMakeLists.txt
r7449 r7908 21 21 Clock.cc 22 22 Exception.cc 23 ExprParser.cc24 23 Math.cc 25 24 MultiType.cc 26 Scope.cc27 25 StringUtils.cc 28 26 COMPILATION_BEGIN StableCompilation.cc 29 Clipboard.cc30 27 Convert.cc 31 28 CRC32.cc 32 29 OutputHandler.cc 33 ScopedSingletonManager.cc34 30 SharedPtr.cc 35 31 SignalHandler.cc … … 54 50 FIND_HEADER_FILES 55 51 LINK_LIBRARIES 56 ${CEGUI_LIBRARY} 57 ${OGRE_LIBRARY} 52 ogremath_orxonox 58 53 SOURCE_FILES 59 54 ${UTIL_SRC_FILES} -
code/forks/sandbox_light/src/libraries/util/Clock.cc
r7401 r7908 28 28 29 29 #include "Clock.h" 30 #include < OgreTimer.h>30 #include <ogremath/OgreTimer.h> 31 31 32 32 namespace orxonox -
code/forks/sandbox_light/src/libraries/util/Exception.cc
r7401 r7908 35 35 #include "Exception.h" 36 36 37 #include <CEGUIExceptions.h>38 37 #include "Debug.h" 39 38 … … 99 98 return ex.what(); 100 99 } 101 catch (const CEGUI::Exception& ex)102 {103 #if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6104 return GeneralException(ex.getMessage().c_str()).getDescription();105 #else106 return GeneralException(ex.getMessage().c_str(), ex.getLine(),107 ex.getFileName().c_str(), ex.getName().c_str()).getDescription();108 #endif109 }110 100 catch (...) 111 101 { -
code/forks/sandbox_light/src/libraries/util/Math.cc
r7401 r7908 34 34 #include "Math.h" 35 35 36 #include < OgrePlane.h>36 #include <ogremath/OgrePlane.h> 37 37 38 38 #include "MathConvert.h" -
code/forks/sandbox_light/src/libraries/util/Math.h
r7427 r7908 47 47 #include <cstdlib> 48 48 49 #include < OgreMath.h>50 #include < OgreVector2.h>51 #include < OgreVector3.h>52 #include < OgreVector4.h>53 #include < OgreQuaternion.h>54 #include < OgreColourValue.h>49 #include <ogremath/OgreMath.h> 50 #include <ogremath/OgreVector2.h> 51 #include <ogremath/OgreVector3.h> 52 #include <ogremath/OgreVector4.h> 53 #include <ogremath/OgreQuaternion.h> 54 #include <ogremath/OgreColourValue.h> 55 55 56 56 // Certain headers might define unwanted macros... -
code/forks/sandbox_light/src/libraries/util/MultiType.h
r7401 r7908 100 100 #include <cassert> 101 101 #include <string> 102 #include < OgreVector2.h>103 #include < OgreVector3.h>104 #include < OgreVector4.h>105 #include < OgreQuaternion.h>106 #include < OgreColourValue.h>102 #include <ogremath/OgreVector2.h> 103 #include <ogremath/OgreVector3.h> 104 #include <ogremath/OgreVector4.h> 105 #include <ogremath/OgreQuaternion.h> 106 #include <ogremath/OgreColourValue.h> 107 107 #include <loki/TypeTraits.h> 108 108 #include "mbool.h" … … 260 260 261 261 virtual void toString(std::ostream& outstream) const = 0; 262 263 virtual void importData( uint8_t*& mem )=0;264 virtual void exportData( uint8_t*& mem ) const=0;265 virtual uint8_t getSize() const=0;266 262 267 263 MT_Type::Value type_; ///< The type of the current value … … 374 370 std::string getTypename() const; 375 371 376 /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT377 inline void exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }378 /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT379 inline void importData(uint8_t*& mem) { assert(sizeof(MT_Type::Value)<=8); this->setType(static_cast<MT_Type::Value>(*static_cast<uint8_t*>(mem))); mem+=sizeof(uint8_t); this->value_->importData(mem); }380 /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT381 inline uint8_t*& operator << (uint8_t*& mem) { importData(mem); return mem; }382 /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT383 inline void operator >> (uint8_t*& mem) const { exportData(mem); }384 inline uint32_t getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }385 386 372 /// Checks whether the value is a default one (assigned after a failed conversion) 387 373 bool hasDefaultValue() const { return this->value_->hasDefaultValue(); } -
code/forks/sandbox_light/src/libraries/util/MultiTypeValue.h
r7401 r7908 43 43 #include "MathConvert.h" 44 44 #include "MultiType.h" 45 #include "Serialise.h"46 45 47 46 namespace orxonox … … 155 154 inline void toString(std::ostream& outstream) const { outstream << this->value_; } 156 155 157 /// loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data158 inline void importData( uint8_t*& mem ) { loadAndIncrease( /*(const T&)*/this->value_, mem ); }159 /// saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data160 inline void exportData( uint8_t*& mem ) const { saveAndIncrease( /*(const T&)*/this->value_, mem ); }161 /// returns the size of the data that would be saved by exportData162 inline uint8_t getSize() const { return returnSize( this->value_ ); }163 164 156 T value_; ///< The stored value 165 157 }; 166 167 // Import / Export specialisation168 // ColourValue169 template <> inline void MT_Value<ColourValue>::importData( uint8_t*& mem )170 {171 loadAndIncrease( this->value_.r, mem );172 loadAndIncrease( this->value_.g, mem );173 loadAndIncrease( this->value_.b, mem );174 loadAndIncrease( this->value_.a, mem );175 }176 template <> inline void MT_Value<ColourValue>::exportData( uint8_t*& mem ) const177 {178 saveAndIncrease( this->value_.r, mem );179 saveAndIncrease( this->value_.g, mem );180 saveAndIncrease( this->value_.b, mem );181 saveAndIncrease( this->value_.a, mem );182 }183 template <> inline uint8_t MT_Value<ColourValue>::getSize() const184 {185 return 4*returnSize(this->value_.r);186 }187 // Ogre::Quaternion188 template <> inline void MT_Value<Ogre::Quaternion>::importData( uint8_t*& mem )189 {190 loadAndIncrease( this->value_.x, mem );191 loadAndIncrease( this->value_.y, mem );192 loadAndIncrease( this->value_.z, mem );193 loadAndIncrease( this->value_.w, mem );194 }195 template <> inline void MT_Value<Ogre::Quaternion>::exportData( uint8_t*& mem ) const196 {197 saveAndIncrease( this->value_.x, mem );198 saveAndIncrease( this->value_.y, mem );199 saveAndIncrease( this->value_.z, mem );200 saveAndIncrease( this->value_.w, mem );201 }202 template <> inline uint8_t MT_Value<Ogre::Quaternion>::getSize() const203 {204 return 4*returnSize(this->value_.x);205 }206 // Ogre::Vector2207 template <> inline void MT_Value<Ogre::Vector2>::importData( uint8_t*& mem )208 {209 loadAndIncrease( this->value_.x, mem );210 loadAndIncrease( this->value_.y, mem );211 }212 template <> inline void MT_Value<Ogre::Vector2>::exportData( uint8_t*& mem ) const213 {214 saveAndIncrease( this->value_.x, mem );215 saveAndIncrease( this->value_.y, mem );216 }217 template <> inline uint8_t MT_Value<Ogre::Vector2>::getSize() const218 {219 return 2*returnSize(this->value_.x);220 }221 // Ogre::Vector3222 template <> inline void MT_Value<Ogre::Vector3>::importData( uint8_t*& mem )223 {224 loadAndIncrease( this->value_.x, mem );225 loadAndIncrease( this->value_.y, mem );226 loadAndIncrease( this->value_.z, mem );227 }228 template <> inline void MT_Value<Ogre::Vector3>::exportData( uint8_t*& mem ) const229 {230 saveAndIncrease( this->value_.x, mem );231 saveAndIncrease( this->value_.y, mem );232 saveAndIncrease( this->value_.z, mem );233 }234 template <> inline uint8_t MT_Value<Ogre::Vector3>::getSize() const235 {236 return 3*returnSize(this->value_.x);237 }238 // Ogre::Vector4239 template <> inline void MT_Value<Ogre::Vector4>::importData( uint8_t*& mem )240 {241 loadAndIncrease( this->value_.x, mem );242 loadAndIncrease( this->value_.y, mem );243 loadAndIncrease( this->value_.z, mem );244 loadAndIncrease( this->value_.w, mem );245 }246 template <> inline void MT_Value<Ogre::Vector4>::exportData( uint8_t*& mem ) const247 {248 saveAndIncrease( this->value_.x, mem );249 saveAndIncrease( this->value_.y, mem );250 saveAndIncrease( this->value_.z, mem );251 saveAndIncrease( this->value_.w, mem );252 }253 template <> inline uint8_t MT_Value<Ogre::Vector4>::getSize() const254 {255 return 4*returnSize(this->value_.x);256 }257 template <> inline void MT_Value<void*>::importData( uint8_t*& mem )258 {259 assert(0);260 }261 template <> inline void MT_Value<void*>::exportData( uint8_t*& mem ) const262 {263 assert(0);264 }265 template <> inline uint8_t MT_Value<void*>::getSize() const266 {267 assert(0); return 0;268 }269 158 } 270 159 -
code/forks/sandbox_light/src/libraries/util/UtilPrereqs.h
r6417 r7908 64 64 namespace orxonox 65 65 { 66 namespace ScopeID67 {68 //!A list of available scopes for the Scope template.69 enum Value70 {71 Root,72 Graphics73 };74 }75 66 } 76 67 … … 83 74 class Clock; 84 75 class Exception; 85 class ExprParser;86 76 class IntVector2; 87 77 class IntVector3; … … 89 79 class OutputHandler; 90 80 class OutputListener; 91 template <ScopeID::Value>92 class Scope;93 template <class, ScopeID::Value>94 class ScopedSingleton;95 class ScopeListener;96 81 class SignalHandler; 97 82 template <class T>
Note: See TracChangeset
for help on using the changeset viewer.