Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 
54 } // end namespace fawkes
55 
56 #endif /* __UTILS_TIME_TIMESOURCE_H_ */