zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Timer.hxx
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef ZENI_TIMER_HXX
19 #define ZENI_TIMER_HXX
20 
21 #include <Zeni/Timer.h>
22 
23 #include <SDL/SDL.h>
24 
25 namespace Zeni {
26 
28  m_ticks = ticks;
29  return *this;
30  }
31 
33  return get_Timer().get_ticks() - m_ticks;
34  }
35 
36  float Time::get_seconds_passed() const {
37  return float(get_ticks_passed()) * 0.001f;
38  }
39 
41  return m_ticks - time.m_ticks;
42  }
43 
44  float Time::get_seconds_since(const Time &time) const {
45  return float(get_ticks_since(time)) * 0.001f;
46  }
47 
48  void Time::update() {
49  m_ticks = get_Timer().get_ticks();
50  }
51 
52  bool Time::operator<(const Time &rhs) const {
53  return m_ticks < rhs.m_ticks;
54  }
55 
57  update();
58  return m_ticks;
59  }
60 
62  return 1000u;
63  }
64 
66  return float(get_ticks()) * 0.001f;
67  }
68 
70  update();
71  return Time(m_ticks);
72  }
73 
74 }
75 
76 #endif
Time::Tick_Type get_ticks_per_second()
Get the number of ticks per second.
Definition: Timer.hxx:61
Tick_Type get_ticks_passed() const
Get the number of clock ticks passed since this Time.
Definition: Timer.hxx:32
Time::Tick_Type get_ticks()
Get the number of ticks passed since instantiation.
Definition: Timer.hxx:56
Tick_Type get_ticks_since(const Time &time) const
Get the number of clock ticks passed between &#39;time&#39; and this Time.
Definition: Timer.hxx:40
Timer & get_Timer()
Get access to the singleton.
Definition: Timer.cpp:73
ALuint u
Definition: alMain.h:58
Time get_time()
Get the current Time.
Definition: Timer.hxx:69
bool operator<(const Time &rhs) const
Definition: Timer.hxx:52
float get_seconds_passed() const
Get the number of seconds passed since this Time.
Definition: Timer.hxx:36
size_t Tick_Type
Definition: Timer.h:65
float get_seconds_since(const Time &time) const
Get the number of seconds passed between &#39;time&#39; and this Time.
Definition: Timer.hxx:44
void update()
Update to current Time.
Definition: Timer.hxx:48
Time & operator=(const Tick_Type &ticks)
Definition: Timer.hxx:27
float get_seconds()
Get the number of seconds passed since instantiation.
Definition: Timer.hxx:65
A Snapshot of the Timer.
Definition: Timer.h:63