Fawkes API  Fawkes Development Version
time_source.cpp
1 
2 /***************************************************************************
3  * time_source.cpp - Time source aspect for Fawkes
4  *
5  * Created: Sun Feb 24 13:34:37 2008
6  * Copyright 2008-2010 Tim Niemueller [www.niemueller.de]
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 #include <aspect/aspect.h>
25 #include <aspect/time_source.h>
26 
27 namespace fawkes {
28 #if 0 /* just to make Emacs auto-indent happy */
29 }
30 #endif
31 
32 /** @class TimeSourceAspect <aspect/time_source.h>
33  * Thread aspect that allows to provide a time source to the Fawkes clock.
34  * There may be at most one external time source provided by a thread with
35  * the TimeSourceAspect at any given time. This is ensured by aspect
36  * initializer.
37  * This aspect can be used for example to attach Fawkes to a simulator and
38  * provide the simulated time to the system.
39  *
40  * @ingroup Aspects
41  * @author Tim Niemueller
42  */
43 
44 
45 /** Constructor.
46  * @param timesource the time source to provide to Fawkes
47  */
49 {
50  add_aspect("TimeSourceAspect");
51  __time_source = timesource;
52 }
53 
54 /** Virtual empty destructor. */
56 {
57 }
58 
59 
60 /** Get time source.
61  * This method is called by the aspect initializer to get the time source
62  * the thread with this aspect provides.
63  * @return time source provided by the thread with this aspect
64  */
65 TimeSource *
67 {
68  return __time_source;
69 }
70 
71 } // end namespace fawkes
Fawkes library namespace.
TimeSource interface.
Definition: timesource.h:36
void add_aspect(const char *name)
Add an aspect to a thread.
Definition: aspect.cpp:52
TimeSource * get_timesource() const
Get time source.
Definition: time_source.cpp:66
virtual ~TimeSourceAspect()
Virtual empty destructor.
Definition: time_source.cpp:55
TimeSourceAspect(TimeSource *timesource) __attribute__((nonnull))
Constructor.
Definition: time_source.cpp:48