Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 26, 2009, 12:44:49 AM (15 years ago)
Author:
rgrieder
Message:

Stripped sandbox further down to get a light version that excludes almost all core features.
Also, the Ogre dependency has been removed and a little ogremath library been added.

Location:
sandbox_light/src/libraries/core
Files:
40 deleted
5 edited

Legend:

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

    r5782 r5789  
    2020SET_SOURCE_FILES(CORE_SRC_FILES
    2121  Clock.cc
    22   ConfigFileManager.cc
    23   ConfigValueContainer.cc
     22  CommandLine.cc
    2423  Core.cc
    25   DynLib.cc
    26   DynLibManager.cc
    27   Game.cc
    28   GameState.cc
    29   Language.cc
    3024  LuaState.cc
    31   ObjectListBase.cc
    32   OrxonoxClass.cc
    33 
    34   # command
    35   CommandLine.cc
    36   Executor.cc
    37 
    38   # hierarchy
    39   Factory.cc
    40   Identifier.cc
    41   MetaObjectList.cc
    42 
    43   # level
    44   BaseObject.cc
    45 
    46   # multithreading
    47   Thread.cc
    48   ThreadPool.cc
    4925)
    5026
     
    5531  DEFINE_SYMBOL
    5632    "CORE_SHARED_BUILD"
    57   PCH_FILE
    58     CorePrecompiledHeaders.h
    5933  LINK_LIBRARIES
    60     ${OGRE_LIBRARY}
    6134    ${Boost_FILESYSTEM_LIBRARY}
    6235    ${Boost_SYSTEM_LIBRARY} # Filesystem dependency
    63     ${Boost_THREAD_LIBRARY}
    64     ${Boost_DATE_TIME_LIBRARY} # Thread dependency
    6536    ${LUA_LIBRARIES}
     37    ogremath_orxonox
    6638    tolua++_orxonox
    6739    util
  • sandbox_light/src/libraries/core/Clock.cc

    r5738 r5789  
    3333
    3434#include "Clock.h"
    35 #include <OgreTimer.h>
     35#include <ogremath/OgreTimer.h>
    3636
    3737namespace orxonox
  • sandbox_light/src/libraries/core/CommandLine.cc

    r5738 r5789  
    3131#include <algorithm>
    3232#include <sstream>
    33 #include <boost/filesystem.hpp>
    3433
    3534#include "util/Convert.h"
     
    348347    {
    349348        std::string filename = CommandLine::getValue("optionsFile").getString();
    350         boost::filesystem::path filepath(Core::getConfigPath() / filename);
    351349
    352350        // look for additional arguments in given file or start.ini as default
    353351        // They will not overwrite the arguments given directly
    354352        std::ifstream file;
    355         file.open(filepath.string().c_str());
     353        file.open((Core::getConfigPathString() + filename).c_str());
    356354        std::vector<std::string> args;
    357355        if (file)
  • sandbox_light/src/libraries/core/Core.cc

    r5782 r5789  
    6464#include "Clock.h"
    6565#include "CommandLine.h"
    66 #include "ConfigFileManager.h"
    67 #include "ConfigValueIncludes.h"
    68 #include "CoreIncludes.h"
    69 #include "DynLibManager.h"
    70 #include "Factory.h"
    71 #include "Identifier.h"
    72 #include "Language.h"
    7366#include "LuaState.h"
    7467
     
    8578    Core* Core::singletonPtr_s  = 0;
    8679
    87     SetCommandLineArgument(externalDataPath, "").information("Path to the external data files");
    8880    SetCommandLineOnlyArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
    8981    SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file");
     
    9890        destruction in the Core destructor.
    9991    */
    100     class CoreConfiguration : public OrxonoxClass
     92    class CoreConfiguration
    10193    {
    10294    public:
     
    10698
    10799        void initialise()
    108         {
    109             RegisterRootObject(CoreConfiguration);
    110             this->setConfigValues();
    111         }
    112 
    113         /**
    114             @brief Function to collect the SetConfigValue-macro calls.
    115         */
    116         void setConfigValues()
    117100        {
    118101#ifdef NDEBUG
     
    125108            const unsigned int defaultLevelShell   = 3;
    126109#endif
    127             SetConfigValue(softDebugLevelConsole_, defaultLevelConsole)
    128                 .description("The maximal level of debug output shown in the console")
    129                 .callback(this, &CoreConfiguration::debugLevelChanged);
    130             SetConfigValue(softDebugLevelLogfile_, defaultLevelLogfile)
    131                 .description("The maximal level of debug output shown in the logfile")
    132                 .callback(this, &CoreConfiguration::debugLevelChanged);
    133             SetConfigValue(softDebugLevelShell_, defaultLevelShell)
    134                 .description("The maximal level of debug output shown in the ingame shell")
    135                 .callback(this, &CoreConfiguration::debugLevelChanged);
    136 
    137             SetConfigValue(language_, Language::getInstance().defaultLanguage_)
    138                 .description("The language of the ingame text")
    139                 .callback(this, &CoreConfiguration::languageChanged);
    140             SetConfigValue(bInitializeRandomNumberGenerator_, true)
    141                 .description("If true, all random actions are different each time you start the game")
    142                 .callback(this, &CoreConfiguration::initializeRandomNumberGenerator);
     110            softDebugLevelConsole_ = defaultLevelConsole;
     111            softDebugLevelLogfile_ = defaultLevelLogfile;
     112            softDebugLevelShell_   = defaultLevelShell;
     113            this->debugLevelChanged();
     114
     115            bInitializeRandomNumberGenerator_ = true;
     116            this->initializeRandomNumberGenerator();
    143117        }
    144118
     
    159133            OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_);
    160134            OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell,   this->softDebugLevelShell_);
    161         }
    162 
    163         /**
    164             @brief Callback function if the language has changed.
    165         */
    166         void languageChanged()
    167         {
    168             // Read the translation file after the language was configured
    169             Language::getInstance().readTranslatedLanguageFile();
    170         }
    171 
    172         /**
    173             @brief Sets the language in the config-file back to the default.
    174         */
    175         void resetLanguage()
    176         {
    177             ResetConfigValue(language_);
    178135        }
    179136
     
    193150        int softDebugLevelLogfile_;                     //!< The debug level for the logfile
    194151        int softDebugLevelShell_;                       //!< The debug level for the ingame shell
    195         std::string language_;                          //!< The language
    196152        bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
    197153
     
    199155        boost::filesystem::path rootPath_;
    200156        boost::filesystem::path executablePath_;        //!< Path to the executable
    201         boost::filesystem::path modulePath_;            //!< Path to the modules
    202157        boost::filesystem::path dataPath_;              //!< Path to the data file folder
    203158        boost::filesystem::path configPath_;            //!< Path to the config file folder
     
    208163    Core::Core(const std::string& cmdLine)
    209164        // Cleanup guard for identifier destruction (incl. XMLPort, configValues, consoleCommands)
    210         : identifierDestroyer_(Identifier::destroyAllIdentifiers)
    211         , configuration_(new CoreConfiguration()) // Don't yet create config values!
     165        : configuration_(new CoreConfiguration()) // Don't yet create config values!
    212166        , bDevRun_(false)
    213167    {
    214168        // Set the hard coded fixed paths
    215169        this->setFixedPaths();
    216 
    217         // Create a new dynamic library manager
    218         this->dynLibManager_.reset(new DynLibManager());
    219 
    220         // Load modules
    221         try
    222         {
    223             // We search for helper files with the following extension
    224             std::string moduleextension = specialConfig::moduleExtension;
    225             size_t moduleextensionlength = moduleextension.size();
    226 
    227             // Search in the directory of our executable
    228             boost::filesystem::path searchpath = this->configuration_->modulePath_;
    229 
    230             // Add that path to the PATH variable in case a module depends on another one
    231             std::string pathVariable = getenv("PATH");
    232             putenv(const_cast<char*>(("PATH=" + pathVariable + ";" + configuration_->modulePath_.string()).c_str()));
    233 
    234             boost::filesystem::directory_iterator file(searchpath);
    235             boost::filesystem::directory_iterator end;
    236 
    237             // Iterate through all files
    238             while (file != end)
    239             {
    240                 std::string filename = file->BOOST_LEAF_FUNCTION();
    241 
    242                 // Check if the file ends with the exension in question
    243                 if (filename.size() > moduleextensionlength)
    244                 {
    245                     if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)
    246                     {
    247                         // We've found a helper file - now load the library with the same name
    248                         std::string library = filename.substr(0, filename.size() - moduleextensionlength);
    249                         boost::filesystem::path librarypath = searchpath / library;
    250 
    251                         try
    252                         {
    253                             DynLibManager::getInstance().load(librarypath.string());
    254                         }
    255                         catch (...)
    256                         {
    257                             COUT(1) << "Couldn't load module \"" << librarypath.string() << "\": " << Exception::handleMessage() << std::endl;
    258                         }
    259                     }
    260                 }
    261 
    262                 ++file;
    263             }
    264         }
    265         catch (...)
    266         {
    267             COUT(1) << "An error occurred while loading modules: " << Exception::handleMessage() << std::endl;
    268         }
    269170
    270171        // Parse command line arguments AFTER the modules have been loaded (static code!)
     
    293194            setThreadAffinity(static_cast<unsigned int>(limitToCPU));
    294195#endif
    295 
    296         // Manage ini files and set the default settings file (usually orxonox.ini)
    297         this->configFileManager_.reset(new ConfigFileManager());
    298         this->configFileManager_->setFilename(ConfigFileType::Settings,
    299             CommandLine::getValue("settingsFile").getString());
    300 
    301         // Required as well for the config values
    302         this->languageInstance_.reset(new Language());
    303 
    304         // creates the class hierarchy for all classes with factories
    305         Factory::createClassHierarchy();
    306196
    307197        // Do this soon after the ConfigFileManager has been created to open up the
     
    360250    }
    361251
    362     /**
    363         @brief Returns the configured language.
    364     */
    365     /*static*/ const std::string& Core::getLanguage()
    366     {
    367         return Core::getInstance().configuration_->language_;
    368     }
    369 
    370     /**
    371         @brief Sets the language in the config-file back to the default.
    372     */
    373     /*static*/ void Core::resetLanguage()
    374     {
    375         Core::getInstance().configuration_->resetLanguage();
    376     }
    377 
    378252    /*static*/ const boost::filesystem::path& Core::getDataPath()
    379253    {
     
    524398            COUT(1) << "Running from the build tree." << std::endl;
    525399            Core::bDevRun_ = true;
    526             configuration_->modulePath_ = specialConfig::moduleDevDirectory;
    527400        }
    528401        else
     
    539412            if (configuration_->rootPath_.empty())
    540413                ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
    541 
    542             // Module path is fixed as well
    543             configuration_->modulePath_ = configuration_->rootPath_ / specialConfig::defaultModulePath;
    544 
    545 #else
    546 
    547             // There is no root path, so don't set it at all
    548             // Module path is fixed as well
    549             configuration_->modulePath_ = specialConfig::moduleInstallDirectory;
    550414
    551415#endif
     
    626490        }
    627491    }
    628 
    629     void Core::preUpdate(const Clock& time)
    630     {
    631     }
    632 
    633     void Core::postUpdate(const Clock& time)
    634     {
    635     }
    636492}
  • sandbox_light/src/libraries/core/Core.h

    r5782 r5789  
    6565        typedef Loki::ScopeGuardImpl0<void (*)()> SimpleScopeGuard;
    6666        friend class Singleton<Core>;
    67         friend class Game;
    6867
    6968        public:
     
    8281            static int   getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
    8382            static void  setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
    84             static const std::string& getLanguage();
    85             static void  resetLanguage();
    8683
    8784            //! Returns the path to the data files as boost::filesystem::path
     
    107104            Core(const Core&); //!< Don't use (undefined symbol)
    108105
    109             void preUpdate(const Clock& time);
    110             void postUpdate(const Clock& time);
    111 
    112106            void setFixedPaths();
    113107            void setConfigurablePaths();
     
    115109
    116110            // Mind the order for the destruction!
    117             scoped_ptr<DynLibManager>     dynLibManager_;
    118111            scoped_ptr<SignalHandler>     signalHandler_;
    119             SimpleScopeGuard              identifierDestroyer_;
    120             scoped_ptr<ConfigFileManager> configFileManager_;
    121             scoped_ptr<Language>          languageInstance_;
    122112            scoped_ptr<CoreConfiguration> configuration_;
    123113
Note: See TracChangeset for help on using the changeset viewer.