Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 13, 2009, 5:05:17 PM (15 years ago)
Author:
dafrick
Message:

Hopefully merged trunk successfully into pickup branch.

Location:
code/branches/pickup
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup

  • code/branches/pickup/src/libraries/tools/CMakeLists.txt

    r5781 r5935  
    1 ADD_SOURCE_FILES(TOOLS_SRC_FILES
     1SET_SOURCE_FILES(TOOLS_SRC_FILES
     2COMPILATION_BEGIN ResourceCompilation.cc
     3  ResourceCollection.cc
     4  ResourceLocation.cc
     5COMPILATION_END
     6  TextureGenerator.cc
     7  Timer.cc
     8COMPILATION_BEGIN OgreCompilation.cc
    29  BillboardSet.cc
    310  DynamicLines.cc
     
    512  Mesh.cc
    613  ParticleInterface.cc
    7   ResourceCollection.cc
    8   ResourceLocation.cc
    914  Shader.cc
    10   TextureGenerator.cc
    11   Timer.cc
     15COMPILATION_END
    1216)
    1317ADD_SUBDIRECTORY(interfaces)
     
    1519ORXONOX_ADD_LIBRARY(tools
    1620  FIND_HEADER_FILES
    17   PCH_FILE
    18     ToolsPrecompiledHeaders.h
    1921  DEFINE_SYMBOL
    2022    "TOOLS_SHARED_BUILD"
  • code/branches/pickup/src/libraries/tools/ResourceLocation.cc

    r5781 r5935  
    3333
    3434#include "util/Exception.h"
    35 #include "core/Core.h"
    3635#include "core/CoreIncludes.h"
     36#include "core/PathConfig.h"
    3737#include "core/XMLFile.h"
    3838#include "core/XMLPort.h"
     
    7171
    7272        // Find the path
    73         boost::filesystem::path path;
    74         if (boost::filesystem::exists(Core::getDataPath() / this->getPath()))
    75             path = Core::getDataPath() / this->getPath();
    76         else if (Core::isDevelopmentRun() && boost::filesystem::exists(Core::getExternalDataPath() / this->getPath()))
    77             path = Core::getExternalDataPath() / this->getPath();
     73        namespace bf = boost::filesystem;
     74        bf::path path;
     75        if (bf::exists(PathConfig::getDataPath() / this->getPath()))
     76            path = PathConfig::getDataPath() / this->getPath();
     77        else if (PathConfig::isDevelopmentRun() && bf::exists(PathConfig::getExternalDataPath() / this->getPath()))
     78            path = PathConfig::getExternalDataPath() / this->getPath();
    7879        else
    7980        {
  • code/branches/pickup/src/libraries/tools/Timer.cc

    r5781 r5935  
    3131#include <set>
    3232
     33#include "util/Clock.h"
    3334#include "core/CoreIncludes.h"
    3435#include "core/ConsoleCommand.h"
    3536#include "core/CommandExecutor.h"
    36 #include "core/Clock.h"
    3737#include "core/Functor.h"
    3838
     
    4242    SetConsoleCommandShortcutExtern(killdelays);
    4343
    44     static std::set<StaticTimer*> delaytimerset;
     44    static std::set<Timer*> delaytimerset;
    4545
    4646    /**
     
    5151    void delay(float delay, const std::string& command)
    5252    {
    53         StaticTimer *delaytimer = new StaticTimer();
     53        Timer* delaytimer = new Timer();
    5454        delaytimerset.insert(delaytimer);
    5555
     
    6464        @param command The command to execute
    6565    */
    66     void executeDelayedCommand(StaticTimer* timer, const std::string& command)
     66    void executeDelayedCommand(Timer* timer, const std::string& command)
    6767    {
    6868        CommandExecutor::execute(command);
    69         delete timer;
     69        timer->destroy();
    7070        delaytimerset.erase(timer);
    7171    }
     
    7676    void killdelays()
    7777    {
    78         for (std::set<StaticTimer*>::iterator it = delaytimerset.begin(); it != delaytimerset.end(); ++it)
    79             delete (*it);
     78        for (std::set<Timer*>::iterator it = delaytimerset.begin(); it != delaytimerset.end(); ++it)
     79            (*it)->destroy();
    8080
    8181        delaytimerset.clear();
     
    8585        @brief Constructor: Sets the default-values.
    8686    */
    87     TimerBase::TimerBase()
     87    Timer::Timer()
     88    {
     89        this->init();
     90        RegisterObject(Timer);
     91    }
     92
     93    /**
     94        @brief Constructor: Initializes the Timer with given values.
     95        @param interval The timer-interval in seconds
     96        @param bLoop If true, the function gets called every 'interval' seconds
     97        @param exeuctor A executor of the function to call
     98    */
     99    Timer::Timer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall)
     100    {
     101        this->init();
     102        RegisterObject(Timer);
     103
     104        this->setTimer(interval, bLoop, executor, bKillAfterCall);
     105    }
     106
     107    /**
     108        @brief Deletes the executor.
     109    */
     110    Timer::~Timer()
     111    {
     112        this->deleteExecutor();
     113    }
     114   
     115    /**
     116        @brief Initializes the Timer
     117    */
     118    void Timer::init()
    88119    {
    89120        this->executor_ = 0;
     
    94125
    95126        this->time_ = 0;
    96 
    97         RegisterObject(TimerBase);
    98     }
    99 
    100     /**
    101         @brief Deletes the executor.
    102     */
    103     TimerBase::~TimerBase()
    104     {
    105         this->deleteExecutor();
    106127    }
    107128
     
    109130        @brief Executes the executor.
    110131    */
    111     void TimerBase::run() const
     132    void Timer::run()
    112133    {
    113134        bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer
     
    116137
    117138        if (temp)
    118             delete this;
     139            this->destroy();
    119140    }
    120141
     
    122143        @brief Deletes the executor.
    123144    */
    124     void TimerBase::deleteExecutor()
     145    void Timer::deleteExecutor()
    125146    {
    126147      if (this->executor_)
     
    131152        @brief Updates the timer before the frames are rendered.
    132153    */
    133     void TimerBase::tick(const Clock& time)
     154    void Timer::tick(const Clock& time)
    134155    {
    135156        if (this->bActive_)
  • code/branches/pickup/src/libraries/tools/Timer.h

    r5781 r5935  
    4040                ClassName();
    4141                void functionName();
    42                 Timer<ClassName> myTimer;
     42                Timer myTimer;
    4343        };
    4444
     
    4848        ClassName::ClassName()
    4949        {
    50             myTimer.setTimer(interval_in_seconds, bLoop, this, createExecutor(createFunctor(&ClassName::functionName)));
     50            myTimer.setTimer(interval_in_seconds, bLoop, createExecutor(createFunctor(&ClassName::functionName, this)));
    5151        }
    5252
     
    6969namespace orxonox
    7070{
    71     class StaticTimer;
    7271    void delay(float delay, const std::string& command);
    7372    void killdelays();
    74     void executeDelayedCommand(StaticTimer* timer, const std::string& command);
     73    void executeDelayedCommand(Timer* timer, const std::string& command);
    7574
    76     //! TimerBase is the parent of the Timer class.
    77     class _ToolsExport TimerBase : public TimeFactorListener
     75    //! The Timer is a callback-object, calling a given function after a given time-interval.
     76    class _ToolsExport Timer : public TimeFactorListener
    7877    {
    7978        public:
    80             ~TimerBase();
     79            Timer();
     80            ~Timer();
    8181
    82             void run() const;
     82            Timer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall = false);
     83
     84            /**
     85                @brief Initializes the Timer with given values.
     86                @param interval The timer-interval in seconds
     87                @param bLoop If true, the function gets called every 'interval' seconds
     88                @param object The object owning the timer and the function
     89                @param executor A executor of the function to call
     90            */
     91            void setTimer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall = false)
     92            {
     93                this->deleteExecutor();
     94
     95                this->setInterval(interval);
     96                this->bLoop_ = bLoop;
     97                this->executor_ = executor;
     98                this->bActive_ = true;
     99
     100                this->time_ = this->interval_;
     101                this->bKillAfterCall_ = bKillAfterCall;
     102            }
     103
     104            void run();
    83105            void deleteExecutor();
    84106
     
    116138            void tick(const Clock& time);
    117139
    118         protected:
    119             TimerBase();
    120 
     140        private:
     141            void init();
     142       
    121143            Executor* executor_;  //!< The executor of the function that should be called when the time expires
    122144
     
    128150            long long time_;      //!< Internal variable, counting the time till the next function-call
    129151    };
    130 
    131     //! The Timer is a callback-object, calling a given function after a given time-interval.
    132     template <class T = BaseObject>
    133     class Timer : public TimerBase
    134     {
    135         public:
    136             Timer() {}
    137 
    138             /**
    139                 @brief Constructor: Initializes the Timer with given values.
    140                 @param interval The timer-interval in seconds
    141                 @param bLoop If true, the function gets called every 'interval' seconds
    142                 @param object The object owning the timer and the function
    143                 @param exeuctor A executor of the function to call
    144             */
    145             Timer(float interval, bool bLoop, T* object, ExecutorMember<T>* exeuctor, bool bKillAfterCall = false)
    146             {
    147                 this->setTimer(interval, bLoop, object, exeuctor, bKillAfterCall);
    148             }
    149 
    150             /**
    151                 @brief Initializes the Timer with given values.
    152                 @param interval The timer-interval in seconds
    153                 @param bLoop If true, the function gets called every 'interval' seconds
    154                 @param object The object owning the timer and the function
    155                 @param exeuctor A executor of the function to call
    156             */
    157             void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor, bool bKillAfterCall = false)
    158             {
    159                 this->deleteExecutor();
    160 
    161                 this->setInterval(interval);
    162                 this->bLoop_ = bLoop;
    163                 executor->setObject(object);
    164                 this->executor_ = static_cast<Executor*>(executor);
    165                 this->bActive_ = true;
    166 
    167                 this->time_ = this->interval_;
    168                 this->bKillAfterCall_ = bKillAfterCall;
    169             }
    170     };
    171 
    172     //! The StaticTimer is a callback-object, calling a static function after a given time-interval.
    173     class _ToolsExport StaticTimer : public TimerBase
    174     {
    175         public:
    176             StaticTimer() {}
    177 
    178             /**
    179                 @brief Constructor: Initializes the Timer with given values.
    180                 @param interval The timer-interval in seconds
    181                 @param bLoop If true, the function gets called every 'interval' seconds
    182                 @param exeuctor A executor of the function to call
    183             */
    184             StaticTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false)
    185             {
    186                 this->setTimer(interval, bLoop, executor, bKillAfterCall);
    187             }
    188 
    189             /**
    190                 @brief Initializes the Timer with given values.
    191                 @param interval The timer-interval in seconds
    192                 @param bLoop If true, the function gets called every 'interval' seconds
    193                 @param object The object owning the timer and the function
    194                 @param executor A executor of the function to call
    195             */
    196             void setTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false)
    197             {
    198                 this->deleteExecutor();
    199 
    200                 this->setInterval(interval);
    201                 this->bLoop_ = bLoop;
    202                 this->executor_ = executor;
    203                 this->bActive_ = true;
    204 
    205                 this->time_ = this->interval_;
    206                 this->bKillAfterCall_ = bKillAfterCall;
    207             }
    208     };
    209 
    210152}
    211153
  • code/branches/pickup/src/libraries/tools/ToolsPrereqs.h

    r5781 r5935  
    2828
    2929/**
    30   @file
    31   @brief Contains all the necessary forward declarations for all classes and structs.
     30@file
     31@brief
     32    Shared library macros, enums, constants and forward declarations for the tools module
    3233*/
    3334
     
    4041// Shared library settings
    4142//-----------------------------------------------------------------------
     43
    4244#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
    4345#  ifdef TOOLS_SHARED_BUILD
     
    5759
    5860//-----------------------------------------------------------------------
    59 // Forward declarations
     61// Enums
    6062//-----------------------------------------------------------------------
    6163
     
    7274        };
    7375    }
     76}
    7477
     78//-----------------------------------------------------------------------
     79// Forward declarations
     80//-----------------------------------------------------------------------
     81
     82namespace orxonox
     83{
    7584    class BillboardSet;
    7685    class Mesh;
    7786    class ParticleInterface;
     87    class ResourceCollection;
     88    class ResourceLocation;
    7889    class Shader;
    79     template <class T>
     90    class Tickable;
     91    class TimeFactorListener;
    8092    class Timer;
    81     class StaticTimer;
    8293}
    8394
Note: See TracChangeset for help on using the changeset viewer.