Orxonox  0.0.5 Codename: Arcturus
Clock.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Reto Grieder
24  * Co-authors:
25  * ...
26  *
27  */
28 
34 #ifndef _Clock_H__
35 #define _Clock_H__
36 
37 #include "UtilPrereqs.h"
38 #include "OgreForwardRefs.h"
39 
40 namespace orxonox
41 {
58  {
59  public:
61  Clock();
62  ~Clock();
63 
73  void capture();
74 
76  unsigned long long getMicroseconds() const
77  { return tickTime_; }
79  unsigned long long getMilliseconds() const
80  { return tickTime_ / 1000; }
82  unsigned long getSeconds() const
83  { return static_cast<long> (tickTime_ / 1000000); }
85  float getSecondsPrecise() const
86  { return static_cast<float>(tickTime_ / 1000000.0f); }
87 
89  float getDeltaTime() const
90  { return tickDtFloat_; }
93  { return tickDt_; }
94 
100  unsigned long long getRealMicroseconds() const;
101 
102  private:
103  // non-copyable:
104  Clock(const Clock&) = delete;
105  Clock& operator=(const Clock&) = delete;
106 
107  Ogre::Timer* timer_;
108  unsigned long long tickTime_;
109  long tickDt_;
110  float tickDtFloat_;
111  };
112 }
113 
114 #endif /* _Clock_H__ */
#define _UtilExport
Definition: UtilPrereqs.h:60
unsigned long long getMilliseconds() const
Returns the last captured absolute time in milliseconds.
Definition: Clock.h:79
unsigned long getSeconds() const
Returns the last captured absolute time in seconds.
Definition: Clock.h:82
float tickDtFloat_
Delta time in seconds (cache value)
Definition: Clock.h:110
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Shared library macros, enums, constants and forward declarations for the util library ...
unsigned long long tickTime_
Currently captured time.
Definition: Clock.h:108
unsigned long long getMicroseconds() const
Returns the last captured absolute time in microseconds.
Definition: Clock.h:76
float getSecondsPrecise() const
Returns the last captured absolute time in seconds as float.
Definition: Clock.h:85
long getDeltaTimeMicroseconds() const
Returns the timespan in microseconds between the last two calls to capture()
Definition: Clock.h:92
Simple real time clock based on Ogre::Timer.
Definition: Clock.h:57
long tickDt_
Delta time in microseconds (cache value)
Definition: Clock.h:109
Ogre::Timer * timer_
Ogre timer object.
Definition: Clock.h:107
float getDeltaTime() const
Returns the timespan in seconds between the last two calls to capture()
Definition: Clock.h:89