Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1524 for code/branches/input


Ignore:
Timestamp:
Jun 3, 2008, 12:20:36 AM (16 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
Files:
2 added
22 edited
4 moved

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/audio/AudioManager.h

    r1505 r1524  
    3535#include <string>
    3636
    37 #include "core/Tickable.h"
    38 
    3937namespace audio
    4038{
    41   class _AudioExport AudioManager : public orxonox::Tickable
     39  class _AudioExport AudioManager
    4240        {
    4341        public:
  • 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
  • code/branches/input/src/network/Client.h

    r1505 r1524  
    4646#include <string>
    4747
    48 #include "core/Tickable.h"
    4948#include "ClientConnection.h"
    5049#include "PacketManager.h"
     
    6362  *
    6463  */
    65   class _NetworkExport Client : PacketDecoder, public orxonox::Tickable{
     64  class _NetworkExport Client : PacketDecoder{
    6665  public:
    6766   
  • code/branches/input/src/network/Server.h

    r1505 r1524  
    4646#include <string>
    4747
    48 #include "core/Tickable.h"
    4948#include "PacketManager.h"
    5049
     
    5756  * It implements all functions necessary for a Server
    5857  */
    59   class _NetworkExport Server : public PacketDecoder, public orxonox::Tickable{
     58  class _NetworkExport Server : public PacketDecoder{
    6059  public:
    6160    Server();
  • code/branches/input/src/orxonox/CMakeLists.txt

    r1505 r1524  
    2929  objects/SpaceShip.cc
    3030  objects/SpaceShipAI.cc
     31  objects/Tickable.cc
    3132  objects/WorldEntity.cc
    3233
  • code/branches/input/src/orxonox/Orxonox.cc

    r1519 r1524  
    5757#include "core/Debug.h"
    5858#include "core/Loader.h"
    59 #include "core/Tickable.h"
    6059#include "core/input/InputManager.h"
    6160#include "core/TclBind.h"
     61#include "core/Core.h"
    6262
    6363// audio
     
    7070// objects and tools
    7171#include "hud/HUD.h"
    72 #include <Ogre.h>
     72#include "objects/Tickable.h"
    7373
    7474#include "GraphicsEngine.h"
     
    7676// FIXME: is this really file scope?
    7777// globals for the server or client
    78 network::Client *client_g;
    79 network::Server *server_g;
     78network::Client *client_g = 0;
     79network::Server *server_g = 0;
    8080
    8181namespace orxonox
     
    430430      }
    431431
     432      // tick the core
     433      Core::tick((float)evt.timeSinceLastFrame);
    432434      // Call those objects that need the real time
    433435      for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
     
    436438      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    437439        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
     440      //AudioManager::tick();
     441      if (client_g)
     442        client_g->tick((float)evt.timeSinceLastFrame);
     443      if (server_g)
     444        server_g->tick((float)evt.timeSinceLastFrame);
    438445
    439446      // don't forget to call _fireFrameStarted in ogre to make sure
  • code/branches/input/src/orxonox/OrxonoxStableHeaders.h

    r1505 r1524  
    104104#include "core/Debug.h"
    105105//#include "core/Executor.h"
    106 #include "core/Tickable.h"
    107106//#include "core/XMLPort.h"
    108107
     
    111110#include "OrxonoxPrereqs.h"
    112111#include "tools/Timer.h"
     112#include "objects/Tickable.h"
    113113#include "objects/Model.h"
    114114#include "objects/WorldEntity.h"
  • code/branches/input/src/orxonox/console/InGameConsole.h

    r1505 r1524  
    3636#include <OgreTextAreaOverlayElement.h>
    3737
    38 #include "core/Tickable.h"
    3938#include "core/Shell.h"
     39#include "objects/Tickable.h"
    4040
    4141
  • code/branches/input/src/orxonox/hud/HUD.h

    r1505 r1524  
    3636#include <OgreTextAreaOverlayElement.h>
    3737#include <OgreSceneNode.h>
    38 #include "core/Tickable.h"
     38#include "objects/Tickable.h"
    3939#include "util/Math.h"
    4040
    4141namespace orxonox
    4242{
    43     class _OrxonoxExport HUD : public Tickable
     43    class _OrxonoxExport HUD : public TickableReal
    4444    {
    4545      private:
  • code/branches/input/src/orxonox/hud/RadarOverlayElement.cc

    r1505 r1524  
    3535
    3636#include "GraphicsEngine.h"
    37 #include "core/Tickable.h"
    3837#include "core/ConsoleCommand.h"
     38#include "objects/Tickable.h"
    3939#include "objects/SpaceShip.h"
    4040#include "RadarObject.h"
  • code/branches/input/src/orxonox/objects/Tickable.cc

    r1510 r1524  
    2727 */
    2828
     29#include "OrxonoxStableHeaders.h"
    2930#include "Tickable.h"
    30 #include "CoreIncludes.h"
    31 #include "ConsoleCommand.h"
     31#include "core/CoreIncludes.h"
     32#include "core/ConsoleCommand.h"
    3233
    3334namespace orxonox
  • code/branches/input/src/orxonox/objects/Tickable.h

    r1510 r1524  
    4242#define _Tickable_H__
    4343
    44 #include "CorePrereqs.h"
     44#include "OrxonoxPrereqs.h"
    4545
    46 #include "OrxonoxClass.h"
     46#include "core/OrxonoxClass.h"
    4747
    4848namespace orxonox
    4949{
    5050    //! The Tickable interface provides a tick(dt) function, that gets called every frame.
    51     class _CoreExport Tickable : virtual public OrxonoxClass
     51    class _OrxonoxExport Tickable : virtual public OrxonoxClass
    5252    {
    5353        public:
     
    6363
    6464    //! The Tickable interface provides a tick(dt) function, that gets called every frame.
    65     class _CoreExport TickableReal : virtual public OrxonoxClass
     65    class _OrxonoxExport TickableReal : virtual public OrxonoxClass
    6666    {
    6767        public:
  • code/branches/input/src/orxonox/objects/WorldEntity.h

    r1505 r1524  
    3939#include "network/Synchronisable.h"
    4040#include "core/BaseObject.h"
    41 #include "core/Tickable.h"
     41#include "Tickable.h"
    4242#include "../tools/Mesh.h"
    4343
  • code/branches/input/src/orxonox/tools/Timer.h

    r1505 r1524  
    6262
    6363#include "OrxonoxPrereqs.h"
    64 #include "core/CorePrereqs.h"
    65 #include "core/Tickable.h"
     64#include "objects/Tickable.h"
    6665
    6766namespace orxonox
  • code/branches/input/visual_studio/vc8/core.vcproj

    r1520 r1524  
    157157                        </File>
    158158                        <File
    159                                 RelativePath="..\..\src\core\CoreSettings.cc"
     159                                RelativePath="..\..\src\core\Core.cc"
    160160                                >
    161161                        </File>
     
    186186                        <File
    187187                                RelativePath="..\..\src\core\SignalHandler.cc"
    188                                 >
    189                         </File>
    190                         <File
    191                                 RelativePath="..\..\src\core\Tickable.cc"
    192188                                >
    193189                        </File>
     
    351347                        </File>
    352348                        <File
     349                                RelativePath="..\..\src\core\Core.h"
     350                                >
     351                        </File>
     352                        <File
    353353                                RelativePath="..\..\src\core\CorePrereqs.h"
    354354                                >
    355355                        </File>
    356356                        <File
    357                                 RelativePath="..\..\src\core\CoreSettings.h"
    358                                 >
    359                         </File>
    360                         <File
    361357                                RelativePath="..\..\src\core\Debug.h"
    362358                                >
     
    392388                        <File
    393389                                RelativePath="..\..\src\core\SignalHandler.h"
    394                                 >
    395                         </File>
    396                         <File
    397                                 RelativePath="..\..\src\core\Tickable.h"
    398390                                >
    399391                        </File>
  • code/branches/input/visual_studio/vc8/orxonox.vcproj

    r1502 r1524  
    256256                                </File>
    257257                                <File
     258                                        RelativePath="..\..\src\orxonox\objects\Tickable.cc"
     259                                        >
     260                                </File>
     261                                <File
    258262                                        RelativePath="..\..\src\orxonox\objects\WorldEntity.cc"
    259263                                        >
     
    539543                                <File
    540544                                        RelativePath="..\..\src\orxonox\objects\SpaceShipAI.h"
     545                                        >
     546                                </File>
     547                                <File
     548                                        RelativePath="..\..\src\orxonox\objects\Tickable.h"
    541549                                        >
    542550                                </File>
Note: See TracChangeset for help on using the changeset viewer.