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
29namespace 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{
38public:
39 /** Destructor. */
40 virtual ~TimeSource()
41 {
42 }
43
44 /** Get the current time.
45 * @param tv the current time is written to this timeval
46 */
47 virtual void get_time(timeval *tv) const = 0;
48
49 /** Convert a time given w.r.t. this time sources into system time.
50 * @param tv the time to convert
51 * @return the converted time
52 */
53 virtual timeval conv_to_realtime(const timeval *tv) const = 0;
54
55 /** Convert a native time to the external time.
56 * When communicating with another instance which provides times in
57 * some timeformat native to the underlying time source (e.g. received
58 * from a simulation) it must be converted to a Fawkes time.
59 * @param tv time in external time source native format
60 * @return time in Fawkes comparable to other times generated using
61 * the external timesource.
62 */
63 virtual timeval conv_native_to_exttime(const timeval *tv) const = 0;
64};
65
66} // end namespace fawkes
67
68#endif /* UTILS_TIME_TIMESOURCE_H__ */
TimeSource interface.
Definition: timesource.h:37
virtual ~TimeSource()
Destructor.
Definition: timesource.h:40
virtual timeval conv_native_to_exttime(const timeval *tv) const =0
Convert a native time to the external time.
virtual timeval conv_to_realtime(const timeval *tv) const =0
Convert a time given w.r.t.
virtual void get_time(timeval *tv) const =0
Get the current time.
Fawkes library namespace.