Main Page   Compound List   File List   Compound Members   File Members  

AltStorage Class Reference

Collaboration diagram for AltStorage:

Collaboration graph
[legend]
List of all members.

Public Methods

 AltStorage (const std::string &currdir, Ing::FileLock::access_mode _mode)
virtual ~AltStorage ()
void parse ()
bool setup (Alternative *old_alt, Alternative *new_alt)
void ignore (const char *name)

Public Attributes

alternative_list alternatives
alternative_list candidates

Protected Methods

virtual void begin_group (const std::string &group)
virtual void end_group (const std::string &group)
virtual void setup_option (const std::string &group, const std::string &name, const std::string &value, const std::string &type)

Private Methods

std::string fill_from (const std::string &path)
std::string check (bool during_test=false)
void setup_slaves (const std::string &candidate_name, Alternative *curr_item)
void dump ()
void check_exists (void *pointer, const std::string &errstr)
void check_exists (bool pointer, const std::string &errstr)
std::string prepare_path (const std::string &str)

Static Private Methods

std::string xmlsafe (std::string str)

Private Attributes

Candidatecurr_prop
Ing::FileLock::access_mode mode
std::string current_dir
Ing::FileLock locker

Detailed Description

General alternatives subsystem representation, Using this class you can change any alternatives settings. However, you also need alternatives-update routine to recreate symlinks


Constructor & Destructor Documentation

AltStorage::AltStorage const std::string &    currdir,
Ing::FileLock::access_mode    _mode
 

A constructor setup general internal structures, made database locking

Parameters:
currdir  directory where all alternatives configs live
_mode  locking mode, default lockfile name is hard compilled

AltStorage::~AltStorage   [virtual]
 

A destructor unlock database, delete all internal structures, dump static information into /etc/alternatives/auto/dump.xml

See also:
dump()


Member Function Documentation

void AltStorage::begin_group const std::string &    group [protected, virtual]
 

implementation of Ing::Config method. Creates new Candidates objects, setup general internal configurations

Parameters:
group  name of the group

std::string AltStorage::check bool    during_test = false [private]
 

Made a consistency checking in all available alternatives

Parameters:
during_test  in non testing mode alternative item will be reset into auto mode on problems
Returns:
empty string on success, otherwise problem description

void AltStorage::check_exists bool    pointer,
const std::string &    errstr
[private]
 

Helper function, checks are this pointer is false, raise exception otherwise

Parameters:
pointer  to check
errstr  error string for exception
Exceptions:
Ing::internal_error 

void AltStorage::check_exists void *    pointer,
const std::string &    errstr
[private]
 

Helper function, checks are this pointer is null, raise exception otherwise

Parameters:
pointer  pointer for check
errstr  error string for exception
Exceptions:
Ing::internal_error 

void AltStorage::dump   [private]
 

Dump all alternatives in manual mode into special dump.xml file

Exceptions:
Ing::internal_error 

void AltStorage::end_group const std::string &    group [protected, virtual]
 

implementation of Ing::Config method. Creates or update existing Alternatives object, fill object with data, also setup slaves if exists

Parameters:
group  name of the group

std::string AltStorage::fill_from const std::string &    path [private]
 

Fill internal biffer with xml from files under selected directory

Parameters:
path  path to the directory with configuration files
See also:
buffer

void AltStorage::ignore const char *    name
 

delete candidate and all it's slave candidates from alternatives structures

Parameters:
name  name of candidate

void AltStorage::parse  
 

subconstructor, parse all alternatives configuration files, create internal structures, made consistency checkings

See also:
check()
Exceptions:
Ing::internal_error 

std::string AltStorage::prepare_path const std::string &    str [private]
 

Helper function, checks are path valid alternatives link name. Alternatives link name must begin with slash

Parameters:
str  link path
Exceptions:
Ing::internal_error 

bool AltStorage::setup Alternative   old_alt,
Alternative   new_alt
 

change settings of one alternatives item we try to replace item, then made consistency checking and rollback if it's fail.

Parameters:
old_alt  previos alternative item
new_alt  updated alternative item
Returns:
true on success, otherwise false
See also:
check()

void AltStorage::setup_option const std::string &    group,
const std::string &    name,
const std::string &    value,
const std::string &    type
[protected, virtual]
 

implementation of Ing::Config method. Check are paths and weights of the alternative items correct, setup some internal data structures

Parameters:
group  name of the group
name  name of the option
value  value of the option
type  type of the option
Exceptions:
Ing::internal_error 

void AltStorage::setup_slaves const std::string &    candidate_name,
Alternative   curr_item
[private]
 

setup all slave items for the current alternative, founded during previos setup_option() functions. Check for consistency, setup as new slave alternative item with candidates

Parameters:
candidate_name  real name of master candidate, we setup now in end_group()
curr_item  current master alternative
Exceptions:
Ing::internal_error 
See also:
setup_option , end_group()

std::string AltStorage::xmlsafe std::string    str [static, private]
 

Helper function, replace some symbols with entities (e.g. '&' with amp;), for safe using with xml

Parameters:
str  string to convert
Returns:
string ready to place into xml file


Member Data Documentation

alternative_list AltStorage::alternatives
 

list of all possible alternatives

alternative_list AltStorage::candidates
 

all possible candidates list and it's alternatives

Candidate* AltStorage::curr_prop [private]
 

current candidate item

std::string AltStorage::current_dir [private]
 

working directory with alternatives config files

Ing::FileLock AltStorage::locker [private]
 

File Locker

Ing::FileLock::access_mode AltStorage::mode [private]
 

locking mode


The documentation for this class was generated from the following files:
Generated on Thu Jun 26 15:28:38 2003 for Alternatives by doxygen1.2.18