KatanaNativeInterface $VERSION$
Timer.h
Go to the documentation of this file.
1/*
2 * Katana Native Interface - A C++ interface to the robot arm Katana.
3 * Copyright (C) 2005 Neuronics AG
4 * Check out the AUTHORS file for detailed contact information.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef KNITIMER_H
22#define KNITIMER_H
23
24#include <ctime>
25
26#ifndef WIN32 // POSIX 1b
27#include <sys/time.h>
28#endif
29
30namespace KNI {
31
36 void sleep(long time);
37
41 class Timer {
42 private:
44
45#ifdef WIN32
46 clock_t _ct;
47#else
48 struct timeval _ct;
49#endif
50
52 long _ElapsedTime() const;
53
54 public:
56 Timer(long timeout);
57
58 void Set(long timeout);
59 void Start();
60
61 void Set_And_Start(long timeout);
62
66 bool Elapsed() const;
67
71 long ElapsedTime() const;
72
76 void WaitUntilElapsed() const;
77
78 };
79
80
81
82}
83
84#endif
Provides a stop-watch-like class with a resolution of milliseconds.
Definition: Timer.h:41
struct timeval _ct
Definition: Timer.h:48
Timer(long timeout)
long ElapsedTime() const
Returns the elapsed time.
long _timeout
Definition: Timer.h:43
bool Elapsed() const
Returns true if timer is elapsed.
void Set(long timeout)
long _ElapsedTime() const
Platform specific implementation of ElapsedTime().
void WaitUntilElapsed() const
Block until time's up.
void Start()
void Set_And_Start(long timeout)
Definition: Timer.h:30
void sleep(long time)
This functions shields the platform specific implementation of the sleep function.