Fawkes API Fawkes Development Version
configurable.cpp
1
2/***************************************************************************
3 * configurable.cpp - Configurable aspect for Fawkes
4 *
5 * Created: Fri Jan 12 14:34:12 2007
6 * Copyright 2006-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/configurable.h>
25
26namespace fawkes {
27
28/** @class ConfigurableAspect <aspect/configurable.h>
29 * Thread aspect to access configuration data.
30 * Give this aspect to your thread to gain access to the configuration.
31 * This aspects defines a thread as being configurable.
32 * It is guaranteed that if used properly from within plugins that
33 * setConfiguration() is called before the thread is started and that
34 * you can access the configuration via the config member.
35 *
36 * It is higly recommended to also implement ConfigurationChangeHandler
37 * to get notified about configuration changes as soon as they happen.
38 * All threads which are configurable shall react immediately to config
39 * changes and use the new configuration. Therefore all inner structures
40 * shall be updated as necessary and member reinitialized if needed.
41 * Only this way no restart or at least plugin load/unload cycle is needed
42 * anymore to change the configuration. This should tremendously help
43 * to decrease debugging, testing and parameter tuning time!
44 *
45 * @ingroup Aspects
46 * @author Tim Niemueller
47 */
48
49/** @var Configuration * ConfigurableAspect::config
50 * This is the Configuration member used to access the configuration.
51 * The configuration will remain valid for the whole lifetime of the
52 * thread.
53 */
54
55/** Constructor. */
57{
58 add_aspect("ConfigurableAspect");
59}
60
61/** Virtual empty Destructor. */
63{
64}
65
66/** Set the configuration
67 * It is guaranteed that this is called for a configurable thread before
68 * Thread::start() is called (when running regularly inside Fawkes).
69 * @param config Configuration instance to use.
70 */
71void
73{
74 this->config = config;
75}
76
77} // end namespace fawkes
void add_aspect(const char *name)
Add an aspect to a thread.
Definition: aspect.cpp:49
Configuration * config
This is the Configuration member used to access the configuration.
Definition: configurable.h:41
void init_ConfigurableAspect(Configuration *config)
Set the configuration It is guaranteed that this is called for a configurable thread before Thread::s...
virtual ~ConfigurableAspect()
Virtual empty Destructor.
ConfigurableAspect()
Constructor.
Interface for configuration handling.
Definition: config.h:68
Fawkes library namespace.