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 Configuration::ValueIterator *v) 00048 * Called whenever a watched value has changed. 00049 * @param v value iterator for the specific value 00050 * 00051 * @fn void ConfigurationChangeHandler::config_comment_changed(const Configuration::ValueIterator *v) 00052 * Called whenever a comment of a watched value has changed. 00053 * @param v value iterator for the specific value 00054 * 00055 * @fn void ConfigurationChangeHandler::config_value_erased(const char *path) 00056 * Called whenever a value has been erased from the config. 00057 * @param path path of value 00058 */ 00059 00060 00061 /** Constructor. 00062 * @param path_prefix Path prefix to monitor. Use the empty string ("") to 00063 * monitor all changes. 00064 */ 00065 ConfigurationChangeHandler::ConfigurationChangeHandler(const char *path_prefix) 00066 { 00067 __path_prefix = strdup(path_prefix); 00068 } 00069 00070 00071 00072 /** Destructor. */ 00073 ConfigurationChangeHandler::~ConfigurationChangeHandler() 00074 { 00075 free(__path_prefix); 00076 } 00077 00078 00079 /** Which path prefix shall be monitored. 00080 * Implement this method to return the name of the component whose values you 00081 * want to monitor. If NULL or the empty string is returned all components 00082 * will be monitored. 00083 * @return monitored path prefix 00084 */ 00085 const char * 00086 ConfigurationChangeHandler::config_monitor_prefix() 00087 { 00088 return __path_prefix; 00089 } 00090 00091 } // end namespace fawkes