Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 3, 2008, 12:20:36 AM (17 years ago)
Author:
rgrieder
Message:
  • moved Tickable to objects again
  • network, audio and core now have their own tick routine
  • Sequence is defined in Orxonox.cc
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  
    44  ConfigFileManager.cc
    55  ConfigValueContainer.cc
    6   CoreSettings.cc
     6  Core.cc
    77  Error.cc
    88  Executor.cc
     
    2727  SignalHandler.cc
    2828  TclBind.cc
    29   Tickable.cc
    3029  XMLPort.cc
    3130  TclThreadManager.cc
  • code/branches/input/src/core/Core.cc

    r1510 r1524  
    2828
    2929/**
    30     @file CoreSettings.cc
    31     @brief Implementation of the CoreSettings class.
     30    @file Core.cc
     31    @brief Implementation of the Core class.
    3232*/
    3333
    34 #include "CoreSettings.h"
     34#include "Core.h"
    3535#include "Language.h"
    3636#include "CoreIncludes.h"
    3737#include "ConfigValueIncludes.h"
     38#include "input/InputManager.h"
     39#include "TclThreadManager.h"
    3840
    3941namespace orxonox
     
    4345        @param A reference to a global variable, used to avoid an infinite recursion in getSoftDebugLevel()
    4446    */
    45     CoreSettings::CoreSettings()
    46     {
    47         RegisterRootObject(CoreSettings);
     47    Core::Core()
     48    {
     49        RegisterRootObject(Core);
    4850        this->setConfigValues();
    4951    }
     
    5254        @brief Sets the bool to true to avoid static functions accessing a deleted object.
    5355    */
    54     CoreSettings::~CoreSettings()
     56    Core::~Core()
    5557    {
    5658        isCreatingCoreSettings() = true;
     
    5860
    5961    /**
    60         @brief Returns true if the CoreSettings instance is not yet ready and the static functions have to return a default value.
    61     */
    62     bool& CoreSettings::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()
    6365    {
    6466        static bool bCreatingCoreSettings = true;
     
    6769        {
    6870            bFirstTime = false;
    69             CoreSettings::getInstance();
     71            Core::getInstance();
    7072        }
    7173        return bCreatingCoreSettings;
     
    7375
    7476    /**
    75         @brief Returns a unique instance of CoreSettings.
     77        @brief Returns a unique instance of Core.
    7678        @return The instance
    7779    */
    78     CoreSettings& CoreSettings::getInstance()
    79     {
    80         static CoreSettings instance = CoreSettings();
     80    Core& Core::getInstance()
     81    {
     82        static Core instance = Core();
    8183
    8284        // If bCreatingSoftDebugLevelObject is true, we're just about to create an instance of the DebugLevel class
    83         if (CoreSettings::isCreatingCoreSettings())
     85        if (Core::isCreatingCoreSettings())
    8486        {
    8587            isCreatingCoreSettings() = false;
     
    9294        @brief Function to collect the SetConfigValue-macro calls.
    9395    */
    94     void CoreSettings::setConfigValues()
     96    void Core::setConfigValues()
    9597    {
    9698        SetConfigValue(softDebugLevelConsole_, 3).description("The maximal level of debug output shown in the console");
     
    121123        @return The softDebugLevel
    122124    */
    123     int CoreSettings::getSoftDebugLevel(OutputHandler::OutputDevice device)
    124     {
    125         if (!CoreSettings::isCreatingCoreSettings())
     125    int Core::getSoftDebugLevel(OutputHandler::OutputDevice device)
     126    {
     127        if (!Core::isCreatingCoreSettings())
    126128        {
    127129            if (device == OutputHandler::LD_All)
    128                 return CoreSettings::getInstance().softDebugLevel_;
     130                return Core::getInstance().softDebugLevel_;
    129131            else if (device == OutputHandler::LD_Console)
    130                 return CoreSettings::getInstance().softDebugLevelConsole_;
     132                return Core::getInstance().softDebugLevelConsole_;
    131133            else if (device == OutputHandler::LD_Logfile)
    132                 return CoreSettings::getInstance().softDebugLevelLogfile_;
     134                return Core::getInstance().softDebugLevelLogfile_;
    133135            else if (device == OutputHandler::LD_Shell)
    134                 return CoreSettings::getInstance().softDebugLevelShell_;
     136                return Core::getInstance().softDebugLevelShell_;
    135137        }
    136138
     
    144146        @param level The level
    145147    */
    146      void CoreSettings::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
     148     void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
    147149     {
    148         if (!CoreSettings::isCreatingCoreSettings())
     150        if (!Core::isCreatingCoreSettings())
    149151        {
    150152            if (device == OutputHandler::LD_All)
    151                 CoreSettings::getInstance().softDebugLevel_ = level;
     153                Core::getInstance().softDebugLevel_ = level;
    152154            else if (device == OutputHandler::LD_Console)
    153                 CoreSettings::getInstance().softDebugLevelConsole_ = level;
     155                Core::getInstance().softDebugLevelConsole_ = level;
    154156            else if (device == OutputHandler::LD_Logfile)
    155                 CoreSettings::getInstance().softDebugLevelLogfile_ = level;
     157                Core::getInstance().softDebugLevelLogfile_ = level;
    156158            else if (device == OutputHandler::LD_Shell)
    157                 CoreSettings::getInstance().softDebugLevelShell_ = level;
     159                Core::getInstance().softDebugLevelShell_ = level;
    158160        }
    159161     }
     
    162164        @brief Returns the configured language.
    163165    */
    164     const std::string& CoreSettings::getLanguage()
    165     {
    166         if (!CoreSettings::isCreatingCoreSettings())
    167             return CoreSettings::getInstance().language_;
     166    const std::string& Core::getLanguage()
     167    {
     168        if (!Core::isCreatingCoreSettings())
     169            return Core::getInstance().language_;
    168170
    169171        return Language::getLanguage().defaultLanguage_;
     
    173175        @brief Sets the language in the config-file back to the default.
    174176    */
    175     void CoreSettings::resetLanguage()
    176     {
    177         CoreSettings::getInstance().resetLanguageIntern();
     177    void Core::resetLanguage()
     178    {
     179        Core::getInstance().resetLanguageIntern();
    178180    }
    179181
     
    181183        @brief Sets the language in the config-file back to the default.
    182184    */
    183     void CoreSettings::resetLanguageIntern()
     185    void Core::resetLanguageIntern()
    184186    {
    185187        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);
    186199    }
    187200}
     
    193206int getSoftDebugLevel()
    194207{
    195     return orxonox::CoreSettings::getSoftDebugLevel();
     208    return orxonox::Core::getSoftDebugLevel();
    196209}
  • code/branches/input/src/core/Core.h

    r1510 r1524  
    2828
    2929/**
    30     @file CoreSettings.h
    31     @brief Definition of the CoreSettings class.
     30    @file Core.h
     31    @brief Definition of the Core class.
    3232
    33     The CoreSettings class is a singleton, only used to configure some variables
     33    The Core class is a singleton, only used to configure some variables
    3434    in the core through the config-file.
    3535*/
     
    4545namespace orxonox
    4646{
    47     //! The CoreSettings class is a singleton, only used to configure some config-values.
    48     class _CoreExport CoreSettings : public OrxonoxClass
     47    //! The Core class is a singleton, only used to configure some config-values.
     48    class _CoreExport Core : public OrxonoxClass
    4949    {
    5050        public:
    51             static CoreSettings& getInstance();
     51            static Core& getInstance();
    5252            static bool& isCreatingCoreSettings();
    5353            void setConfigValues();
     
    5858            static void resetLanguage();
    5959
     60            static void tick(float dt);
     61
    6062        private:
    6163            void resetLanguageIntern();
    6264
    63             CoreSettings();
    64             CoreSettings(const CoreSettings& other);
    65             virtual ~CoreSettings();
     65            Core();
     66            Core(const Core& other);
     67            virtual ~Core();
    6668
    6769            int softDebugLevel_;                            //!< The debug level
  • code/branches/input/src/core/CorePrereqs.h

    r1520 r1524  
    112112  class ConfigValueContainer;
    113113  class ConsoleCommand;
    114   class CoreSettings;
     114  class Core;
    115115  class Error;
    116116  class Executor;
  • code/branches/input/src/core/Language.cc

    r1505 r1524  
    3636#include <fstream>
    3737
    38 #include "CoreSettings.h"
     38#include "Core.h"
    3939
    4040#include "Debug.h"
     
    245245    void Language::readTranslatedLanguageFile()
    246246    {
    247         COUT(4) << "Read translated language file (" << CoreSettings::getLanguage() << ")." << std::endl;
     247        COUT(4) << "Read translated language file (" << Core::getLanguage() << ")." << std::endl;
    248248
    249249        // Open the file
    250250        std::ifstream file;
    251         file.open(getFileName(CoreSettings::getLanguage()).c_str(), std::fstream::in);
     251        file.open(getFileName(Core::getLanguage()).c_str(), std::fstream::in);
    252252
    253253        if (!file.is_open())
    254254        {
    255255            COUT(1) << "An error occurred in Language.cc:" << std::endl;
    256             COUT(1) << "Error: Couldn't open file " << getFileName(CoreSettings::getLanguage()) << " to read the translated language entries!" << std::endl;
    257             CoreSettings::resetLanguage();
     256            COUT(1) << "Error: Couldn't open file " << getFileName(Core::getLanguage()) << " to read the translated language entries!" << std::endl;
     257            Core::resetLanguage();
    258258            COUT(3) << "Info: Reset language to " << this->defaultLanguage_ << "." << std::endl;
    259259            return;
     
    286286                else
    287287                {
    288                     COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFileName(CoreSettings::getLanguage()) << std::endl;
     288                    COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFileName(Core::getLanguage()) << std::endl;
    289289                }
    290290            }
  • code/branches/input/src/core/Language.h

    r1505 r1524  
    113113    class _CoreExport Language
    114114    {
    115         friend class CoreSettings;
     115        friend class Core;
    116116
    117117        public:
  • code/branches/input/src/core/OutputHandler.cc

    r1505 r1524  
    3333
    3434#include "OutputHandler.h"
    35 #include "CoreSettings.h"
     35#include "Core.h"
    3636#include "ConsoleCommand.h"
    3737#include "Shell.h"
     
    8383    int OutputHandler::getSoftDebugLevel(OutputHandler::OutputDevice device)
    8484    {
    85         return CoreSettings::getSoftDebugLevel(device);
     85        return Core::getSoftDebugLevel(device);
    8686    }
    8787
  • code/branches/input/src/core/Shell.cc

    r1519 r1524  
    3131#include "CoreIncludes.h"
    3232#include "ConfigValueIncludes.h"
    33 #include "CoreSettings.h"
     33#include "Core.h"
    3434#include "ConsoleCommand.h"
    3535#include "input/InputInterfaces.h"
     
    6767    Shell& Shell::createShell()
    6868    {
    69         int level = CoreSettings::getSoftDebugLevel(OutputHandler::LD_Shell);
    70         CoreSettings::setSoftDebugLevel(OutputHandler::LD_Shell, -1);
     69        int level = Core::getSoftDebugLevel(OutputHandler::LD_Shell);
     70        Core::setSoftDebugLevel(OutputHandler::LD_Shell, -1);
    7171        static Shell instance;
    72         CoreSettings::setSoftDebugLevel(OutputHandler::LD_Shell, level);
     72        Core::setSoftDebugLevel(OutputHandler::LD_Shell, level);
    7373        return instance;
    7474    }
  • code/branches/input/src/core/TclThreadManager.h

    r1505 r1524  
    3030#define _TclThreadManager_H__
    3131
     32#include "CorePrereqs.h"
     33
    3234#include <queue>
    3335#include <map>
     
    3840#include <boost/thread/thread.hpp>
    3941
    40 #include "CorePrereqs.h"
    41 #include "Tickable.h"
    4242#include "cpptcl/CppTcl.h"
     43#include "core/OrxonoxClass.h"
    4344
    4445namespace orxonox
     
    6869    };
    6970
    70     class _CoreExport TclThreadManager : public Tickable
     71    class _CoreExport TclThreadManager : public OrxonoxClass
    7172    {
    7273        public:
  • code/branches/input/src/core/input/InputManager.cc

    r1520 r1524  
    499499    @param dt Delta time
    500500  */
    501   void InputManager::tick(float dt)
     501  void InputManager::_tick(float dt)
    502502  {
    503503    if (state_ == IS_UNINIT)
     
    649649      activeHandlers_[iHandler].first->tickInput(dt, activeHandlers_[iHandler].second);
    650650  }
    651 
     651   
    652652  void InputManager::_completeCalibration()
    653653  {
     
    11411141  }
    11421142
     1143  void InputManager::tick(float dt)
     1144  {
     1145    _getSingleton()._tick(dt);
     1146  }
     1147
    11431148  // ###### KeyHandler ######
    11441149
  • code/branches/input/src/core/input/InputManager.h

    r1519 r1524  
    4343#include "ois/OIS.h"
    4444#include "util/Math.h"
    45 #include "core/Tickable.h"
     45#include "core/OrxonoxClass.h"
    4646#include "InputInterfaces.h"
    4747
     
    8989  */
    9090  class _CoreExport InputManager
    91         : public TickableReal,
     91        : public OrxonoxClass,
    9292          public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener
    9393  {
     
    143143    static void calibrate();
    144144
     145    static void tick(float dt);
     146
    145147    static bool addKeyHandler                 (KeyHandler* handler, const std::string& name);
    146148    static bool removeKeyHandler              (const std::string& name);
     
    191193    unsigned int _getJoystick(const OIS::JoyStickEvent& arg);
    192194
    193     void tick(float dt);
     195    void _tick(float dt);
    194196
    195197    // input events
Note: See TracChangeset for help on using the changeset viewer.