feisty meow concerns codebase  2.140
configuration::ini_roller Class Reference

Implements an id generator that interacts with a configuration file. More...

#include <ini_roller.h>

Inheritance diagram for configuration::ini_roller:
Collaboration diagram for configuration::ini_roller:

Public Member Functions

 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. 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ini_roller()

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().

◆ ~ini_roller()

configuration::ini_roller::~ini_roller ( )
virtual

Member Function Documentation

◆ current_id()

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().

◆ DEFINE_CLASS_NAME()

configuration::ini_roller::DEFINE_CLASS_NAME ( "ini_roller"  )

◆ next_id()

int configuration::ini_roller::next_id ( )

The documentation for this class was generated from the following files: