Fawkes API  Fawkes Development Version
configurable.cpp
00001 
00002 /***************************************************************************
00003  *  configurable.cpp - Configurable aspect for Fawkes
00004  *
00005  *  Created: Fri Jan 12 14:34:12 2007
00006  *  Copyright  2006-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/configurable.h>
00025 
00026 namespace fawkes {
00027 #if 0 /* just to make Emacs auto-indent happy */
00028 }
00029 #endif
00030 
00031 /** @class ConfigurableAspect <aspect/configurable.h>
00032  * Thread aspect to access configuration data.
00033  * Give this aspect to your thread to gain access to the configuration.
00034  * This aspects defines a thread as being configurable.
00035  * It is guaranteed that if used properly from within plugins that
00036  * setConfiguration() is called before the thread is started and that
00037  * you can access the configuration via the config member.
00038  *
00039  * It is higly recommended to also implement ConfigurationChangeHandler
00040  * to get notified about configuration changes as soon as they happen.
00041  * All threads which are configurable shall react immediately to config
00042  * changes and use the new configuration. Therefore all inner structures
00043  * shall be updated as necessary and member reinitialized if needed.
00044  * Only this way no restart or at least plugin load/unload cycle is needed
00045  * anymore to change the configuration. This should tremendously help
00046  * to decrease debugging, testing and parameter tuning time!
00047  *
00048  * @ingroup Aspects
00049  * @author Tim Niemueller
00050  */
00051 
00052 
00053 /** @var Configuration *  ConfigurableAspect::config
00054  * This is the Configuration member used to access the configuration.
00055  * The configuration will remain valid for the whole lifetime of the
00056  * thread.
00057  */
00058 
00059 /** Constructor. */
00060 ConfigurableAspect::ConfigurableAspect()
00061 {
00062   add_aspect("ConfigurableAspect");
00063 }
00064 
00065 /** Virtual empty Destructor. */
00066 ConfigurableAspect::~ConfigurableAspect()
00067 {
00068 }
00069 
00070 
00071 /** Set the configuration
00072  * It is guaranteed that this is called for a configurable thread before
00073  * Thread::start() is called (when running regularly inside Fawkes).
00074  * @param config Configuration instance to use.
00075  */
00076 void
00077 ConfigurableAspect::init_ConfigurableAspect(Configuration *config)
00078 {
00079   this->config = config;
00080 }
00081 
00082 } // end namespace fawkes