feisty meow concerns codebase
2.140
|
Implements an id generator that interacts with a configuration file. More...
#include <ini_roller.h>
Public Member Functions | |
ini_roller (configurator &config, const basis::astring §ion, const basis::astring &entry, int min, int max) | |
creates a roller that updates "config" with the current id value. More... | |
virtual | ~ini_roller () |
DEFINE_CLASS_NAME ("ini_roller") | |
int | next_id () |
returns the next number to be issued. More... | |
int | current_id () const |
returns the current id; this is the one that was last issued. More... | |
Implements an id generator that interacts with a configuration file.
This provides an int_roller (which provides rolling ids given a range to issue them from) that is stored in a configurator. The instantiated object is the real source of the ids, but the configurator file is periodically updated to reflect the current id state. If a program is restarted later, then it will start using ids that it had not already issued in its last run, as long as the configurator is a persistent object. Note that the range of ids had better be quite large; otherwise the program could still have live entries under an id that is about to be reissued due to wrap-around.
Definition at line 39 of file ini_roller.h.
configuration::ini_roller::ini_roller | ( | configurator & | config, |
const basis::astring & | section, | ||
const basis::astring & | entry, | ||
int | min, | ||
int | max | ||
) |
creates a roller that updates "config" with the current id value.
the updates are not continuous, but are done periodically to avoid constantly writing to the "config". the "section" and "entry" dictate where the entry is saved in the "config". the "min" and "max" provide the range of the id, where it will start at "min", increment by one until it reaches at most "max", and then it will start back at "min" again. note that "config" must exist for the duration of the ini_roller.
Definition at line 33 of file ini_roller.cpp.
References structures::roller< contents >::current(), configuration::ID_FACTOR, configuration::configurator::load(), structures::roller< contents >::set_current(), and configuration::configurator::store().
|
virtual |
Definition at line 48 of file ini_roller.cpp.
References structures::roller< contents >::current(), configuration::configurator::store(), and basis::WHACK().
int configuration::ini_roller::current_id | ( | ) | const |
returns the current id; this is the one that was last issued.
Definition at line 58 of file ini_roller.cpp.
References structures::roller< contents >::current().
configuration::ini_roller::DEFINE_CLASS_NAME | ( | "ini_roller" | ) |
int configuration::ini_roller::next_id | ( | ) |
returns the next number to be issued.
Definition at line 64 of file ini_roller.cpp.
References structures::roller< contents >::current(), FUNCDEF, configuration::ID_FACTOR, LOG, structures::roller< contents >::maximum(), structures::roller< contents >::next_id(), and configuration::configurator::store().