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 <cstring>
27 #include <cstdlib>
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 
61 /** Constructor.
62  * @param path_prefix Path prefix to monitor. Use the empty string ("") to
63  * monitor all changes.
64  */
66 {
67  __path_prefix = strdup(path_prefix);
68 }
69 
70 
71 
72 /** Destructor. */
74 {
75  free(__path_prefix);
76 }
77 
78 
79 /** Which path prefix shall be monitored.
80  * Implement this method to return the name of the component whose values you
81  * want to monitor. If NULL or the empty string is returned all components
82  * will be monitored.
83  * @return monitored path prefix
84  */
85 const char *
87 {
88  return __path_prefix;
89 }
90 
91 } // end namespace fawkes
Fawkes library namespace.
virtual ~ConfigurationChangeHandler()
Destructor.
ConfigurationChangeHandler(const char *path_prefix)
Constructor.
const char * config_monitor_prefix()
Which path prefix shall be monitored.