Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 17, 2011, 5:47:22 AM (14 years ago)
Author:
rgrieder
Message:

Stripped down trunk to form a new light sandbox.

Location:
code/forks/sandbox_light/src/libraries/core
Files:
74 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • code/forks/sandbox_light/src/libraries/core/CMakeLists.txt

    r7284 r7908  
    2020SET_SOURCE_FILES(CORE_SRC_FILES
    2121  CommandLineParser.cc
    22   ConfigValueContainer.cc
    2322  Core.cc
    24   DynLib.cc
    25   DynLibManager.cc
    26   Event.cc
    27   Game.cc
    28   GameMode.cc
    29   GameState.cc
    30   GraphicsManager.cc
    31   GUIManager.cc
    32   Language.cc
    33   LuaState.cc
    34   ObjectListBase.cc
    35   OrxonoxClass.cc
    36   Resource.cc
    37   WindowEventListener.cc
    38 
    39   # hierarchy
    40   Identifier.cc
    41   MetaObjectList.cc
    42 
    43   # level
    44   BaseObject.cc
    45   ClassTreeMask.cc
    46   Loader.cc
    47   Namespace.cc
    48   NamespaceNode.cc
    49   Template.cc
    50   XMLPort.cc
    51   XMLNameListener.cc
    52 
    53 COMPILATION_BEGIN FilesystemCompilation.cc
    54   command/ArgumentCompletionFunctions.cc
    55   ConfigFileManager.cc
    56   MemoryArchive.cc
    5723  PathConfig.cc
    58 COMPILATION_END
    59 
    60   # multithreading
    61   ThreadPool.cc
    62 COMPILATION_BEGIN ThreadCompilation.cc
    63   command/TclThreadManager.cc
    64   Thread.cc
    65 COMPILATION_END
    6624)
    67 
    68 ADD_SUBDIRECTORY(command)
    69 ADD_SUBDIRECTORY(input)
    7025
    7126ORXONOX_ADD_LIBRARY(core
    7227  FIND_HEADER_FILES
    73   TOLUA_FILES
    74     command/CommandExecutor.h
    75     ConfigFileManager.h
    76     Game.h
    77     GameMode.h
    78     GUIManager.h
    79     Loader.h
    80     LuaState.h
    81     PathConfig.h
    82     input/InputManager.h
    83     input/KeyBinder.h
    84     input/KeyBinderManager.h
    85   PCH_FILE
    86     CorePrecompiledHeaders.h
    8728  LINK_LIBRARIES
    88     ${OGRE_LIBRARY}
    8929    ${Boost_FILESYSTEM_LIBRARY}
    9030    ${Boost_SYSTEM_LIBRARY} # Filesystem dependency
    91     ${Boost_THREAD_LIBRARY}
    92     ${Boost_DATE_TIME_LIBRARY} # Thread dependency
    93     ${CEGUI_LIBRARY}
    94     ${CEGUILUA_LIBRARY}
    95     ${LUA_LIBRARIES}
    96     cpptcl_orxonox
    97     ogreceguirenderer_orxonox
    98     ois_orxonox
    99     tinyxml_orxonox
    100     tolua_orxonox
    10131    util
    10232  SOURCE_FILES
  • code/forks/sandbox_light/src/libraries/core/Core.cc

    r7872 r7908  
    5151#endif
    5252
    53 #include "util/Clock.h"
    5453#include "util/Debug.h"
    55 #include "util/Exception.h"
    56 #include "util/Scope.h"
    57 #include "util/ScopedSingletonManager.h"
    5854#include "util/SignalHandler.h"
    5955#include "PathConfig.h"
    6056#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"
    7657
    7758namespace orxonox
     
    8061    Core* Core::singletonPtr_s  = 0;
    8162
    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 
    8563#ifdef ORXONOX_PLATFORM_WINDOWS
    8664    SetCommandLineArgument(limitToCPU, 1).information("Limits the program to one CPU/core (1, 2, 3, etc.). Default is the first core (faster than off)");
     
    8866
    8967    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 Identifier
    93         , consoleCommandDestroyer_(ConsoleCommand::destroyAll)
    94         , bGraphicsLoaded_(false)
    95         , bStartIOConsole_(true)
    96         , lastLevelTimestamp_(0)
    97         , ogreConfigTimestamp_(0)
    9868    {
    9969        // Set the hard coded fixed paths
    10070        this->pathConfig_.reset(new PathConfig());
    101 
    102         // Create a new dynamic library manager
    103         this->dynLibManager_.reset(new DynLibManager());
    104 
    105         // Load modules
    106         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             try
    110             {
    111                 this->dynLibManager_->load(*it);
    112             }
    113             catch (...)
    114             {
    115                 COUT(1) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << std::endl;
    116             }
    117         }
    11871
    11972        // Parse command line arguments AFTER the modules have been loaded (static code!)
     
    14396#endif
    14497
    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 values
    151         this->languageInstance_.reset(new Language());
    152 
    153         // Do this soon after the ConfigFileManager has been created to open up the
    154         // possibility to configure everything below here
    155         ClassIdentifier<Core>::getIdentifier("Core")->initialiseObject(this, "Core", true);
    156         this->setConfigValues();
    157 
    158         // create persistent io console
    159         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 factories
    167         Identifier::createClassHierarchy();
    168 
    169         // Load OGRE excluding the renderer and the render window
    170         this->graphicsManager_.reset(new GraphicsManager(false));
    171 
    172         // initialise Tcl
    173         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 
    17998        // Generate documentation instead of normal run?
    18099        std::string docFilename;
     
    199118    Core::~Core()
    200119    {
    201         // Remove us from the object lists again to avoid problems when destroying them
    202         this->unregisterObject();
    203     }
    204 
    205     //! Function to collect the SetConfigValue-macro calls.
    206     void Core::setConfigValues()
    207     {
    208 #ifdef ORXONOX_RELEASE
    209         const unsigned int defaultLevelLogFile = 3;
    210 #else
    211         const unsigned int defaultLevelLogFile = 4;
    212 #endif
    213         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 configured
    235         Language::getInstance().readTranslatedLanguageFile();
    236120    }
    237121
     
    245129            bInitialized = true;
    246130        }
    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 window
    255         try
    256         {
    257             graphicsManager_->upgradeToGraphics();
    258         }
    259         catch (const InitialisationFailedException&)
    260         {
    261             // Exit the application if the Ogre config dialog was canceled
    262             COUT(1) << Exception::handleMessage() << std::endl;
    263             exit(EXIT_FAILURE);
    264         }
    265         catch (...)
    266         {
    267             // Recovery from this is very difficult. It requires to completely
    268             // destroy Ogre related objects and load again (without graphics).
    269             // However since Ogre 1.7 there seems to be a problem when Ogre
    270             // throws an exception and the graphics engine then gets destroyed
    271             // 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:" << endl
    275                     << 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 interface
    283         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 system
    305         try
    306             { this->graphicsManager_.reset(new GraphicsManager(false)); }
    307         catch (...)
    308         {
    309             COUT(0) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << std::endl
    310                     << "Another exception might be being handled which may lead to undefined behaviour!" << std::endl
    311                     << "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_);
    323131    }
    324132
     
    368176#endif
    369177    }
    370 
    371     void Core::preUpdate(const Clock& time)
    372     {
    373         // Update singletons before general ticking
    374         ScopedSingletonManager::preUpdate<ScopeID::Root>(time);
    375         if (this->bGraphicsLoaded_)
    376         {
    377             // Process input events
    378             this->inputManager_->preUpdate(time);
    379             // Update GUI
    380             this->guiManager_->preUpdate(time);
    381             // Update singletons before general ticking
    382             ScopedSingletonManager::preUpdate<ScopeID::Graphics>(time);
    383         }
    384         // Process console events and status line
    385         if (this->ioConsole_ != NULL)
    386             this->ioConsole_->preUpdate(time);
    387         // Process thread commands
    388         this->tclThreadManager_->preUpdate(time);
    389     }
    390 
    391     void Core::postUpdate(const Clock& time)
    392     {
    393         // Update singletons just before rendering
    394         ScopedSingletonManager::postUpdate<ScopeID::Root>(time);
    395         if (this->bGraphicsLoaded_)
    396         {
    397             // Update singletons just before rendering
    398             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     }
    413178}
  • code/forks/sandbox_light/src/libraries/core/Core.h

    r7870 r7908  
    4646#include <string>
    4747#include <boost/scoped_ptr.hpp>
    48 #include <loki/ScopeGuard.h>
    4948
    5049#include "util/Singleton.h"
    51 #include "OrxonoxClass.h"
    5250
    5351namespace orxonox
     
    5957        You should only create this singleton once because it destroys the identifiers!
    6058    */
    61     class _CoreExport Core : public Singleton<Core>, public OrxonoxClass
     59    class _CoreExport Core : public Singleton<Core>
    6260    {
    63         typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard;
    6461        friend class Singleton<Core>;
    65         friend class Game;
    6662
    6763        public:
     
    7672            ~Core();
    7773
    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() const
    87                 { return this->lastLevelTimestamp_; }
    88 
    89             void updateOgreConfigTimestamp();
    90             inline long long getOgreConfigTimestamp() const
    91                 { return this->ogreConfigTimestamp_; }
    92 
    9374        private:
    9475            Core(const Core&); //!< Don't use (undefined symbol)
    9576
    96             void languageChanged();
    9777            void initRandomNumberGenerator();
    9878
    99             void preUpdate(const Clock& time);
    100             void postUpdate(const Clock& time);
     79            void setThreadAffinity(int limitToCPU);
    10180
    102             void loadGraphics();
    103             void unloadGraphics();
    104 
    105             void setThreadAffinity(int limitToCPU);
    10681            // MANAGED SINGLETONS/OBJECTS
    10782            // Mind the order for the destruction!
    10883            scoped_ptr<PathConfig>        pathConfig_;
    109             scoped_ptr<DynLibManager>     dynLibManager_;
    11084            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             // graphical
    120             scoped_ptr<GraphicsManager>   graphicsManager_;     //!< Interface to OGRE
    121             scoped_ptr<InputManager>      inputManager_;        //!< Interface to OIS
    122             scoped_ptr<GUIManager>        guiManager_;          //!< Interface to GUI
    123             scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_;
    12485
    125             bool                          bGraphicsLoaded_;
    12686            int                           softDebugLevelLogFile_;      //!< The debug level for the log file (belongs to OutputHandler)
    127             std::string                   language_;                   //!< The language
    12887            bool                          bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
    129             bool                          bStartIOConsole_;            //!< Set to false if you don't want to use the IOConsole
    130             long long                     lastLevelTimestamp_;         ///< Timestamp when the last level was started
    131             long long                     ogreConfigTimestamp_;        ///< Timestamp wehen the ogre config level was modified
    13288
    13389            static Core*                  singletonPtr_s;
  • code/forks/sandbox_light/src/libraries/core/CorePrereqs.h

    r7849 r7908  
    6565namespace orxonox
    6666{
    67     static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);
    6867}
    6968
     
    7473namespace orxonox
    7574{
    76     namespace XMLPort
    77     {
    78         enum Mode
    79         {
    80             NOP,
    81             LoadObject,
    82             SaveObject,
    83             ExpandObject
    84         };
    85     }
    86 
    87     namespace ConfigFileType
    88     {
    89         enum Value
    90         {
    91             Settings,
    92             JoyStickCalibration,
    93             CommandHistory
    94             // Don't forget to adjust the array size in the ConfigFileManager when adding a new entry here!
    95         };
    96     }
    97 
    98     namespace KeybindMode
    99     {
    100         enum Value
    101         {
    102             OnPress,
    103             OnHold,
    104             OnRelease,
    105             None
    106         };
    107     };
    10875}
    10976
     
    11481namespace orxonox
    11582{
    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;
    13083    class CommandLineParser;
    13184    class CommandLineArgument;
    132     class ConfigFile;
    133     class ConfigFileEntry;
    134     class ConfigFileEntryComment;
    135     class ConfigFileEntryValue;
    136     class ConfigFileManager;
    137     class ConfigFileSection;
    138     class ConfigValueContainer;
    13985    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;
    17486    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     // Command
    197     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     // Input
    222     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 // CppTcl
    250 namespace Tcl
    251 {
    252     class interpreter;
    253     class object;
    25487}
    25588
     
    278111    }
    279112#endif
    280     class thread;
    281     class mutex;
    282     class shared_mutex;
    283     class condition_variable;
    284 }
    285 
    286 // Ogre
    287 namespace Ogre
    288 {
    289     class DataStream;
    290     template <class T> class SharedPtr;
    291     typedef SharedPtr<DataStream> DataStreamPtr;
    292 }
    293 namespace orxonox
    294 {
    295     // Import the Ogre::DataStream
    296     using Ogre::DataStream;
    297     using Ogre::DataStreamPtr;
    298 }
    299 
    300 // CEGUI
    301 namespace CEGUI
    302 {
    303     class DefaultLogger;
    304     class Logger;
    305     class LuaScriptModule;
    306 
    307     class OgreCEGUIRenderer;
    308     class OgreCEGUIResourceProvider;
    309     class OgreCEGUITexture;
    310 }
    311 
    312 // Lua
    313 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 ticpp
    329 {
    330     class Document;
    331     class Element;
    332     class Declaration;
    333     class StylesheetReference;
    334     class Text;
    335     class Comment;
    336     class Attribute;
    337 }
    338 namespace orxonox
    339 {
    340     using ticpp::Element;
    341113}
    342114
  • code/forks/sandbox_light/src/libraries/core/PathConfig.cc

    r6417 r7908  
    7676        : rootPath_(*(new bf::path()))
    7777        , executablePath_(*(new bf::path()))
    78         , modulePath_(*(new bf::path()))
    7978        , dataPath_(*(new bf::path()))
    80         , externalDataPath_(*(new bf::path()))
    8179        , configPath_(*(new bf::path()))
    8280        , logPath_(*(new bf::path()))
     
    138136            COUT(1) << "Running from the build tree." << std::endl;
    139137            PathConfig::bDevRun_ = true;
    140             modulePath_ = specialConfig::moduleDevDirectory;
    141138        }
    142139        else
     
    153150                ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
    154151
    155             // Module path is fixed as well
    156             modulePath_ = rootPath_ / specialConfig::defaultModulePath;
    157 
    158152#else
    159153
    160154            // There is no root path, so don't set it at all
    161             // Module path is fixed as well
    162             modulePath_ = specialConfig::moduleInstallDirectory;
    163155
    164156#endif
     
    170162        delete &rootPath_;
    171163        delete &executablePath_;
    172         delete &modulePath_;
    173164        delete &dataPath_;
    174         delete &externalDataPath_;
    175165        delete &configPath_;
    176166        delete &logPath_;
     
    184174            configPath_       = specialConfig::configDevDirectory;
    185175            logPath_          = specialConfig::logDevDirectory;
    186 
    187             // Check for data path override by the command line
    188             if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue())
    189                 externalDataPath_ = CommandLineParser::getValue("externalDataPath").getString();
    190             else
    191                 externalDataPath_ = specialConfig::externalDataDevDirectory;
    192176        }
    193177        else
     
    251235    }
    252236
    253     std::vector<std::string> PathConfig::getModulePaths()
    254     {
    255         std::vector<std::string> modulePaths;
    256 
    257         // We search for helper files with the following extension
    258         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 one
    262         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 modules
    266         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 files
    273         while (file != end)
    274         {
    275             const std::string& filename = file->BOOST_LEAF_FUNCTION();
    276 
    277             // Check if the file ends with the exension in question
    278             if (filename.size() > moduleextensionlength)
    279             {
    280                 if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)
    281                 {
    282                     // We've found a helper file
    283                     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 
    293237    /*static*/ std::string PathConfig::getRootPathString()
    294238    {
     
    306250    }
    307251
    308     /*static*/ std::string PathConfig::getExternalDataPathString()
    309     {
    310         return getInstance().externalDataPath_.string() + '/';
    311     }
    312 
    313252    /*static*/ std::string PathConfig::getConfigPathString()
    314253    {
     
    320259        return getInstance().logPath_.string() + '/';
    321260    }
    322 
    323     /*static*/ std::string PathConfig::getModulePathString()
    324     {
    325         return getInstance().modulePath_.string() + '/';
    326     }
    327261}
  • code/forks/sandbox_light/src/libraries/core/PathConfig.h

    r7427 r7908  
    8585            static const boost::filesystem::path& getDataPath()
    8686                { return getInstance().dataPath_; }
    87             //! Returns the path to the external data files as boost::filesystem::path
    88             static const boost::filesystem::path& getExternalDataPath()
    89                 { return getInstance().externalDataPath_; }
    9087            //! Returns the path to the config files as boost::filesystem::path
    9188            static const boost::filesystem::path& getConfigPath()
     
    9491            static const boost::filesystem::path& getLogPath()
    9592                { return getInstance().logPath_; }
    96             //! Returns the path to the modules as boost::filesystem::path
    97             static const boost::filesystem::path& getModulePath()
    98                 { return getInstance().modulePath_; }
    9993
    10094            //! Returns the path to the root folder as std::string
     
    10498            //! Returns the path to the data files as std::string
    10599            static std::string getDataPathString();
    106             //! Returns the path to the external data files as std::string
    107             static std::string getExternalDataPathString();
    108100            //! Returns the path to the config files as std::string
    109101            static std::string getConfigPathString(); //tolua_export
    110102            //! Returns the path to the log files as std::string
    111103            static std::string getLogPathString();
    112             //! Returns the path to the modules as std::string
    113             static std::string getModulePathString();
    114104
    115105            //! Return trrue for runs in the build directory (not installed)
     
    126116            */
    127117            void setConfigurablePaths();
    128             //! Returns a list with all modules declared by a *.module file in the module folder.
    129             std::vector<std::string> getModulePaths();
    130118
    131119            //! Path to the parent directory of the ones above if program was installed with relativ paths
    132120            boost::filesystem::path& rootPath_;
    133121            boost::filesystem::path& executablePath_;        //!< Path to the executable
    134             boost::filesystem::path& modulePath_;            //!< Path to the modules
    135122            boost::filesystem::path& dataPath_;              //!< Path to the data files folder
    136             boost::filesystem::path& externalDataPath_;      //!< Path to the external data files folder
    137123            boost::filesystem::path& configPath_;            //!< Path to the config files folder
    138124            boost::filesystem::path& logPath_;               //!< Path to the log files folder
Note: See TracChangeset for help on using the changeset viewer.