Fawkes API  Fawkes Development Version
timesource.h
1 
2 /***************************************************************************
3  * timesource.h - A clock's timesource
4  *
5  * Created: Sun Jun 03 10:58:19 2007
6  * Copyright 2007 Daniel Beck
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __UTILS_TIME_TIMESOURCE_H_
25 #define __UTILS_TIME_TIMESOURCE_H_
26 
27 #include <sys/time.h>
28 
29 namespace fawkes {
30 
31 /** TimeSource interface.
32  * This interfaces describes a way to interact with time sources that can be
33  * given to a Clock (for instance for simulation environments).
34  * @author Daniel Beck
35  */
37 {
38  public:
39  /** Destructor. */
40  virtual ~TimeSource() {}
41 
42  /** Get the current time.
43  * @param tv the current time is written to this timeval
44  */
45  virtual void get_time(timeval* tv) const = 0;
46 
47  /** Convert a time given w.r.t. this time sources into system time.
48  * @param tv the time to convert
49  * @return the converted time
50  */
51  virtual timeval conv_to_realtime(const timeval* tv) const = 0;
52 
53  /** Convert a native time to the external time.
54  * When communicating with another instance which provides times in
55  * some timeformat native to the underlying time source (e.g. received
56  * from a simulation) it must be converted to a Fawkes time.
57  * @param tv time in external time source native format
58  * @return time in Fawkes comparable to other times generated using
59  * the external timesource.
60  */
61  virtual timeval conv_native_to_exttime(const timeval* tv) const = 0;
62 };
63 
64 } // end namespace fawkes
65 
66 #endif /* __UTILS_TIME_TIMESOURCE_H_ */
Fawkes library namespace.
TimeSource interface.
Definition: timesource.h:36
virtual timeval conv_to_realtime(const timeval *tv) const =0
Convert a time given w.r.t.
virtual ~TimeSource()
Destructor.
Definition: timesource.h:40
virtual void get_time(timeval *tv) const =0
Get the current time.
virtual timeval conv_native_to_exttime(const timeval *tv) const =0
Convert a native time to the external time.