File: myTime.h

package info (click to toggle)
spring 0.81.2.1%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 28,496 kB
  • ctags: 37,096
  • sloc: cpp: 238,659; ansic: 13,784; java: 12,175; awk: 3,428; python: 1,159; xml: 738; perl: 405; sh: 297; makefile: 267; pascal: 228; objc: 192
file content (31 lines) | stat: -rw-r--r-- 1,105 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef MYTIME_H
#define MYTIME_H

#define SPRING_TIME 1 // boost microsec timer SUCKS atm, when it works again, set to 0
#if SPRING_TIME
#include <SDL_timer.h>
typedef unsigned spring_time;
typedef int spring_duration;
inline spring_time spring_gettime() { return SDL_GetTicks(); };
#define spring_tomsecs(time) (time)
#define spring_msecs(time) (time)
#define spring_secs(time) (time*1000)
#define spring_istime(time) (time>0)
#define spring_sleep(time) SDL_Delay(time)
#define spring_notime(time) time = 0
#else
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/posix_time/ptime.hpp>
using namespace boost::posix_time;
typedef ptime spring_time;
typedef time_duration spring_duration;
inline spring_time spring_gettime() { return microsec_clock::local_time(); };
#define spring_tomsecs(time) ((time).total_milliseconds())
#define spring_msecs(time) (milliseconds(time))
#define spring_secs(time) (seconds(time))
#define spring_istime(time) (!(time).is_not_a_date_time())
#define spring_sleep(time) boost::this_thread::sleep(time)
#define spring_notime(time)
#endif

#endif