Fawkes API  Fawkes Development Version
change_handler.cpp
1 
2 /***************************************************************************
3  * change_handler.h - Fawkes configuration change handler interface
4  *
5  * Created: Mon Dec 04 18:48:54 2006
6  * Copyright 2006-2007 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 <config/change_handler.h>
25 
26 #include <cstdlib>
27 #include <cstring>
28 
29 namespace fawkes {
30 
31 /** @class ConfigurationChangeHandler <config/change_handler.h>
32  * Interface for configuration change handling.
33  * One of the major flaws in the old software was that for each
34  * configuration change the software had to be restarted. To avoid this
35  * change handlers are introduced. Change handlers are called if a value
36  * for the given component changes so that appropriate adjustement of the
37  * behavior or a proper re-initialisation of a specific component can
38  * be conducted.
39  * @author Tim Niemueller
40  *
41  * @fn void ConfigurationChangeHandler::config_tag_changed(const char *new_tag)
42  * Called whenever the tag has changed.
43  * This function can be used to detect when data from another tag has been
44  * loaded.
45  * @param new_tag new tag
46  *
47  * @fn void ConfigurationChangeHandler::config_value_changed(const Configuration::ValueIterator *v)
48  * Called whenever a watched value has changed.
49  * @param v value iterator for the specific value
50  *
51  * @fn void ConfigurationChangeHandler::config_comment_changed(const Configuration::ValueIterator *v)
52  * Called whenever a comment of a watched value has changed.
53  * @param v value iterator for the specific value
54  *
55  * @fn void ConfigurationChangeHandler::config_value_erased(const char *path)
56  * Called whenever a value has been erased from the config.
57  * @param path path of value
58  */
59 
60 /** Constructor.
61  * @param path_prefix Path prefix to monitor. Use the empty string ("") to
62  * monitor all changes.
63  */
65 {
66  path_prefix_ = strdup(path_prefix);
67 }
68 
69 /** Destructor. */
71 {
72  free(path_prefix_);
73 }
74 
75 /** Which path prefix shall be monitored.
76  * Implement this method to return the name of the component whose values you
77  * want to monitor. If NULL or the empty string is returned all components
78  * will be monitored.
79  * @return monitored path prefix
80  */
81 const char *
83 {
84  return path_prefix_;
85 }
86 
87 } // end namespace fawkes
fawkes::ConfigurationChangeHandler::~ConfigurationChangeHandler
virtual ~ConfigurationChangeHandler()
Destructor.
Definition: change_handler.cpp:76
fawkes
fawkes::ConfigurationChangeHandler::config_monitor_prefix
const char * config_monitor_prefix()
Which path prefix shall be monitored.
Definition: change_handler.cpp:88
fawkes::ConfigurationChangeHandler::ConfigurationChangeHandler
ConfigurationChangeHandler(const char *path_prefix)
Constructor.
Definition: change_handler.cpp:70