1 #ifndef CONFIG_WATCHER_CLASS
2 #define CONFIG_WATCHER_CLASS
4 /*****************************************************************************\
6 * Name : config_watcher *
7 * Author : Chris Koeritz *
9 *******************************************************************************
10 * Copyright (c) 2008-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
18 #include "configurator.h"
19 #include "table_configurator.h"
21 #include <basis/contracts.h>
22 #include <structures/set.h>
24 namespace configuration {
26 //! an object that watches the contents of a configurator for changes.
28 when given a configurator object to check, this will initially build an
29 exact copy of the contents seen. when asked to look for changes to the
30 configurator, the previous version is compared with the current state and
31 any changed sections are reported.
37 config_watcher(configurator &to_watch);
38 //!< watches the configurator for changes and tracks them.
39 /*!< "to_watch" must exist for lifetime of this class. */
41 virtual ~config_watcher();
43 DEFINE_CLASS_NAME("config_watcher");
46 //!< updates the configurator snapshot and enables the comparison methods.
47 /*!< call this before testing the changed() method. */
49 // these lists describe how sections have changed, if at all.
50 structures::string_set new_sections() const;
51 structures::string_set deleted_sections() const;
52 structures::string_set changed_sections() const;
54 // methods for comparing changes within sections in the config.
55 structures::string_set new_items(const basis::astring §ion_name);
56 structures::string_set deleted_items(const basis::astring §ion_name);
57 structures::string_set changed_items(const basis::astring §ion_name);
60 configurator &_watching; //!< the config object we examine.
61 table_configurator *_current_config; //!< most current records.
62 table_configurator *_previous_config; //!< records we saw earlier.