22 using namespace basis;
28 : _watching(to_watch),
37 WHACK(_current_config);
38 WHACK(_previous_config);
44 *_previous_config = *_current_config;
46 _current_config->
reset();
51 for (
int sectindy = 0; sectindy < sects.
length(); sectindy++) {
53 astring curr_section = sects[sectindy];
56 _current_config->
put_section(curr_section, entries);
68 return after - before;
77 return before - after;
88 for (
int i = 0; i < possible_changes.
elements(); i++) {
89 const astring §_name = possible_changes[i];
91 _previous_config->
get_section(sect_name, previous_section);
93 _current_config->
get_section(sect_name, current_section);
94 if (current_section != previous_section)
95 definite_changes += sect_name;
97 return definite_changes;
103 _previous_config->
get_section(section_name, previous_section);
105 previous_section.
names(previous_names);
107 _current_config->
get_section(section_name, current_section);
109 current_section.
names(current_names);
110 return previous_names - current_names;
116 _previous_config->
get_section(section_name, previous_section);
118 previous_section.
names(previous_names);
120 _current_config->
get_section(section_name, current_section);
122 current_section.
names(current_names);
123 return current_names - previous_names;
129 _previous_config->
get_section(section_name, previous_section);
131 previous_section.
names(previous_names);
133 _current_config->
get_section(section_name, current_section);
135 current_section.
names(current_names);
139 for (
int i = 0; i < possible_changes.
elements(); i++) {
140 const astring &curr_item = possible_changes[i];
142 _previous_config->
get(section_name, curr_item, prev_value);
144 _current_config->
get(section_name, curr_item, curr_value);
145 if (prev_value != curr_value)
146 definite_changes += curr_item;
148 return definite_changes;
int length() const
Returns the current reported length of the allocated C array.
Provides a dynamically resizable ASCII character string.
structures::string_set changed_sections() const
structures::string_set new_sections() const
virtual ~config_watcher()
bool rescan()
updates the configurator snapshot and enables the comparison methods.
structures::string_set deleted_items(const basis::astring §ion_name)
structures::string_set new_items(const basis::astring §ion_name)
structures::string_set deleted_sections() const
structures::string_set changed_items(const basis::astring §ion_name)
Provides a base class for configuration repositories.
virtual bool get_section(const basis::astring &formal(section), structures::string_table &formal(found))
retrieves an entire "section", if supported by the derived object.
void section_set(structures::string_set &list)
similar to above, but stores section names into a set.
Supports the configurator interface using a collection of string tables.
virtual bool get(const basis::astring §ion, const basis::astring &entry, basis::astring &found)
implements the configurator retrieval function.
virtual bool put_section(const basis::astring §ion, const structures::string_table &info)
writes a table called "info" into the "section" held here.
virtual bool get_section(const basis::astring §ion, structures::string_table &info)
reads the entire table held under "section" into a table called "info".
int elements() const
Returns the number of elements in this set.
set intersection(const set &intersect_with) const
Returns the intersection of "this" with the set in "intersect_with".
A simple object that wraps a templated set of strings.
Provides a symbol_table that holds strings as the content.
void names(string_set &to_fill) const
returns the names of all the symbols currently held.
The guards collection helps in testing preconditions and reporting errors.
void WHACK(contents *&ptr)
deletion with clearing of the pointer.
A dynamic container class that holds any kind of object via pointers.