Changeset 5929 for code/trunk/src/libraries/tools
- Timestamp:
- Oct 12, 2009, 8:20:07 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core5 (added) merged: 5768-5769,5772,5775-5780,5783-5785,5791-5792,5795-5807,5809-5814,5816-5832,5836-5839,5842-5853,5855-5899,5904-5922,5924-5928
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/tools/CMakeLists.txt
r5781 r5929 1 ADD_SOURCE_FILES(TOOLS_SRC_FILES 1 SET_SOURCE_FILES(TOOLS_SRC_FILES 2 COMPILATION_BEGIN ResourceCompilation.cc 3 ResourceCollection.cc 4 ResourceLocation.cc 5 COMPILATION_END 6 TextureGenerator.cc 7 Timer.cc 8 COMPILATION_BEGIN OgreCompilation.cc 2 9 BillboardSet.cc 3 10 DynamicLines.cc … … 5 12 Mesh.cc 6 13 ParticleInterface.cc 7 ResourceCollection.cc8 ResourceLocation.cc9 14 Shader.cc 10 TextureGenerator.cc 11 Timer.cc 15 COMPILATION_END 12 16 ) 13 17 ADD_SUBDIRECTORY(interfaces) … … 15 19 ORXONOX_ADD_LIBRARY(tools 16 20 FIND_HEADER_FILES 17 PCH_FILE18 ToolsPrecompiledHeaders.h19 21 DEFINE_SYMBOL 20 22 "TOOLS_SHARED_BUILD" -
code/trunk/src/libraries/tools/ResourceLocation.cc
r5781 r5929 33 33 34 34 #include "util/Exception.h" 35 #include "core/Core.h"36 35 #include "core/CoreIncludes.h" 36 #include "core/PathConfig.h" 37 37 #include "core/XMLFile.h" 38 38 #include "core/XMLPort.h" … … 71 71 72 72 // 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(); 78 79 else 79 80 { -
code/trunk/src/libraries/tools/Timer.cc
r5781 r5929 31 31 #include <set> 32 32 33 #include "util/Clock.h" 33 34 #include "core/CoreIncludes.h" 34 35 #include "core/ConsoleCommand.h" 35 36 #include "core/CommandExecutor.h" 36 #include "core/Clock.h"37 37 #include "core/Functor.h" 38 38 … … 42 42 SetConsoleCommandShortcutExtern(killdelays); 43 43 44 static std::set< StaticTimer*> delaytimerset;44 static std::set<Timer*> delaytimerset; 45 45 46 46 /** … … 51 51 void delay(float delay, const std::string& command) 52 52 { 53 StaticTimer *delaytimer = new StaticTimer();53 Timer* delaytimer = new Timer(); 54 54 delaytimerset.insert(delaytimer); 55 55 … … 64 64 @param command The command to execute 65 65 */ 66 void executeDelayedCommand( StaticTimer* timer, const std::string& command)66 void executeDelayedCommand(Timer* timer, const std::string& command) 67 67 { 68 68 CommandExecutor::execute(command); 69 delete timer;69 timer->destroy(); 70 70 delaytimerset.erase(timer); 71 71 } … … 76 76 void killdelays() 77 77 { 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(); 80 80 81 81 delaytimerset.clear(); … … 85 85 @brief Constructor: Sets the default-values. 86 86 */ 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() 88 119 { 89 120 this->executor_ = 0; … … 94 125 95 126 this->time_ = 0; 96 97 RegisterObject(TimerBase);98 }99 100 /**101 @brief Deletes the executor.102 */103 TimerBase::~TimerBase()104 {105 this->deleteExecutor();106 127 } 107 128 … … 109 130 @brief Executes the executor. 110 131 */ 111 void Timer Base::run() const132 void Timer::run() 112 133 { 113 134 bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer … … 116 137 117 138 if (temp) 118 delete this;139 this->destroy(); 119 140 } 120 141 … … 122 143 @brief Deletes the executor. 123 144 */ 124 void Timer Base::deleteExecutor()145 void Timer::deleteExecutor() 125 146 { 126 147 if (this->executor_) … … 131 152 @brief Updates the timer before the frames are rendered. 132 153 */ 133 void Timer Base::tick(const Clock& time)154 void Timer::tick(const Clock& time) 134 155 { 135 156 if (this->bActive_) -
code/trunk/src/libraries/tools/Timer.h
r5781 r5929 40 40 ClassName(); 41 41 void functionName(); 42 Timer <ClassName>myTimer;42 Timer myTimer; 43 43 }; 44 44 … … 48 48 ClassName::ClassName() 49 49 { 50 myTimer.setTimer(interval_in_seconds, bLoop, this, createExecutor(createFunctor(&ClassName::functionName)));50 myTimer.setTimer(interval_in_seconds, bLoop, createExecutor(createFunctor(&ClassName::functionName, this))); 51 51 } 52 52 … … 69 69 namespace orxonox 70 70 { 71 class StaticTimer;72 71 void delay(float delay, const std::string& command); 73 72 void killdelays(); 74 void executeDelayedCommand( StaticTimer* timer, const std::string& command);73 void executeDelayedCommand(Timer* timer, const std::string& command); 75 74 76 //! T imerBase is the parent of the Timer class.77 class _ToolsExport Timer Base: public TimeFactorListener75 //! The Timer is a callback-object, calling a given function after a given time-interval. 76 class _ToolsExport Timer : public TimeFactorListener 78 77 { 79 78 public: 80 ~TimerBase(); 79 Timer(); 80 ~Timer(); 81 81 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(); 83 105 void deleteExecutor(); 84 106 … … 116 138 void tick(const Clock& time); 117 139 118 pr otected:119 TimerBase();120 140 private: 141 void init(); 142 121 143 Executor* executor_; //!< The executor of the function that should be called when the time expires 122 144 … … 128 150 long long time_; //!< Internal variable, counting the time till the next function-call 129 151 }; 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 TimerBase134 {135 public:136 Timer() {}137 138 /**139 @brief Constructor: Initializes the Timer with given values.140 @param interval The timer-interval in seconds141 @param bLoop If true, the function gets called every 'interval' seconds142 @param object The object owning the timer and the function143 @param exeuctor A executor of the function to call144 */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 seconds153 @param bLoop If true, the function gets called every 'interval' seconds154 @param object The object owning the timer and the function155 @param exeuctor A executor of the function to call156 */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 TimerBase174 {175 public:176 StaticTimer() {}177 178 /**179 @brief Constructor: Initializes the Timer with given values.180 @param interval The timer-interval in seconds181 @param bLoop If true, the function gets called every 'interval' seconds182 @param exeuctor A executor of the function to call183 */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 seconds192 @param bLoop If true, the function gets called every 'interval' seconds193 @param object The object owning the timer and the function194 @param executor A executor of the function to call195 */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 210 152 } 211 153 -
code/trunk/src/libraries/tools/ToolsPrereqs.h
r5781 r5929 28 28 29 29 /** 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 32 33 */ 33 34 … … 40 41 // Shared library settings 41 42 //----------------------------------------------------------------------- 43 42 44 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD) 43 45 # ifdef TOOLS_SHARED_BUILD … … 57 59 58 60 //----------------------------------------------------------------------- 59 // Forward declarations61 // Enums 60 62 //----------------------------------------------------------------------- 61 63 … … 72 74 }; 73 75 } 76 } 74 77 78 //----------------------------------------------------------------------- 79 // Forward declarations 80 //----------------------------------------------------------------------- 81 82 namespace orxonox 83 { 75 84 class BillboardSet; 76 85 class Mesh; 77 86 class ParticleInterface; 87 class ResourceCollection; 88 class ResourceLocation; 78 89 class Shader; 79 template <class T> 90 class Tickable; 91 class TimeFactorListener; 80 92 class Timer; 81 class StaticTimer;82 93 } 83 94
Note: See TracChangeset
for help on using the changeset viewer.