Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * change_handler.h - Fawkes configuration change handler interface 00004 * 00005 * Created: Mon Dec 04 18:48:54 2006 00006 * Copyright 2006-2007 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 <config/change_handler.h> 00025 00026 #include <cstring> 00027 #include <cstdlib> 00028 00029 namespace fawkes { 00030 00031 /** @class ConfigurationChangeHandler <config/change_handler.h> 00032 * Interface for configuration change handling. 00033 * One of the major flaws in the old software was that for each 00034 * configuration change the software had to be restarted. To avoid this 00035 * change handlers are introduced. Change handlers are called if a value 00036 * for the given component changes so that appropriate adjustement of the 00037 * behavior or a proper re-initialisation of a specific component can 00038 * be conducted. 00039 * @author Tim Niemueller 00040 * 00041 * @fn void ConfigurationChangeHandler::config_tag_changed(const char *new_tag) 00042 * Called whenever the tag has changed. 00043 * This function can be used to detect when data from another tag has been 00044 * loaded. 00045 * @param new_tag new tag 00046 * 00047 * @fn void ConfigurationChangeHandler::config_value_changed(const char *path, bool is_default, int value) 00048 * Called whenever an int value has changed. 00049 * @param path path of value 00050 * @param is_default true if modified value is a default value, false otherwise 00051 * @param value new value 00052 * 00053 * @fn void ConfigurationChangeHandler::config_value_changed(const char *path, bool is_default, unsigned int value) 00054 * Called whenever an unsigned int value has changed. 00055 * @param path path of value 00056 * @param is_default true if modified value is a default value, false otherwise 00057 * @param value new value 00058 * 00059 * @fn void ConfigurationChangeHandler::config_value_changed(const char *path, bool is_default, float value) 00060 * Called whenever an float value has changed. 00061 * @param path path of value 00062 * @param is_default true if modified value is a default value, false otherwise 00063 * @param value new value 00064 * 00065 * @fn virtual void ConfigurationChangeHandler::config_value_changed(const char *path, bool is_default, bool value) 00066 * Called whenever an boolean value has changed. 00067 * @param path path of value 00068 * @param is_default true if modified value is a default value, false otherwise 00069 * @param value new value 00070 * 00071 * @fn void ConfigurationChangeHandler::config_value_changed(const char *path, bool is_default, const char *value) 00072 * Called whenever a string value has changed. 00073 * @param path path of value 00074 * @param is_default true if modified value is a default value, false otherwise 00075 * @param value new value 00076 * 00077 * @fn void ConfigurationChangeHandler::config_comment_changed(const char *path, bool is_default, const char *comment) 00078 * Called whenever a comment has changed. 00079 * @param path path of value 00080 * @param is_default true if modified comment is of a default value, false otherwise 00081 * @param comment new comment 00082 * 00083 * @fn void ConfigurationChangeHandler::config_value_erased(const char *path, bool is_default) 00084 * Called whenever a value has been erased from the config. 00085 * @param path path of value 00086 * @param is_default true if erased value was a default value, false otherwise 00087 */ 00088 00089 00090 /** Constructor. 00091 * @param path_prefix Path prefix to monitor. Use the empty string ("") to 00092 * monitor all changes. 00093 */ 00094 ConfigurationChangeHandler::ConfigurationChangeHandler(const char *path_prefix) 00095 { 00096 __path_prefix = strdup(path_prefix); 00097 } 00098 00099 00100 00101 /** Destructor. */ 00102 ConfigurationChangeHandler::~ConfigurationChangeHandler() 00103 { 00104 free(__path_prefix); 00105 } 00106 00107 00108 /** Which path prefix shall be monitored. 00109 * Implement this method to return the name of the component whose values you 00110 * want to monitor. If NULL or the empty string is returned all components 00111 * will be monitored. 00112 * @return monitored path prefix 00113 */ 00114 const char * 00115 ConfigurationChangeHandler::config_monitor_prefix() 00116 { 00117 return __path_prefix; 00118 } 00119 00120 } // end namespace fawkes