Fawkes API  Fawkes Development Version
time_source.cpp
00001 
00002 /***************************************************************************
00003  *  time_source.cpp - Time source aspect for Fawkes
00004  *
00005  *  Created: Sun Feb 24 13:34:37 2008
00006  *  Copyright  2008-2010  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #include <aspect/aspect.h>
00025 #include <aspect/time_source.h>
00026 
00027 namespace fawkes {
00028 #if 0 /* just to make Emacs auto-indent happy */
00029 }
00030 #endif
00031 
00032 /** @class TimeSourceAspect <aspect/time_source.h>
00033  * Thread aspect that allows to provide a time source to the Fawkes clock.
00034  * There may be at most one external time source provided by a thread with
00035  * the TimeSourceAspect at any given time. This is ensured by aspect
00036  * initializer.
00037  * This aspect can be used for example to attach Fawkes to a simulator and
00038  * provide the simulated time to the system.
00039  *
00040  * @ingroup Aspects
00041  * @author Tim Niemueller
00042  */
00043 
00044 
00045 /** Constructor.
00046  * @param timesource the time source to provide to Fawkes
00047  */
00048 TimeSourceAspect::TimeSourceAspect(TimeSource *timesource)
00049 {
00050   add_aspect("TimeSourceAspect");
00051   __time_source = timesource;
00052 }
00053 
00054 /** Virtual empty destructor. */
00055 TimeSourceAspect::~TimeSourceAspect()
00056 {
00057 }
00058 
00059 
00060 /** Get time source.
00061  * This method is called by the aspect initializer to get the time source
00062  * the thread with this aspect provides.
00063  * @return time source provided by the thread with this aspect
00064  */
00065 TimeSource *
00066 TimeSourceAspect::get_timesource() const
00067 {
00068   return __time_source;
00069 }
00070 
00071 } // end namespace fawkes