yast2-core
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ModulesConf Class Reference

The modules.conf file. More...

#include <ModulesConf.h>

Classes

struct  ModuleLine
 

Public Types

typedef list< string > ModulesConfIndex
 
typedef map< const string,
ModuleEntry
ModuleEntryMap
 
typedef map< const string,
ModuleEntryMap
ModulesConfMap
 

Public Member Functions

 ModulesConf (const string &fname)
 
 ~ModulesConf ()
 
ModulesConfMap getDirectives ()
 
ModuleEntryMap getModules (const string directive)
 
ModuleEntry::EntryArg getOptions (const string module)
 
string getOptionsAsString (const string module)
 
string getOption (const string module, const string option)
 
string getArgument (const string directive, const string module)
 
string getComment (const string directive, const string module)
 
bool setOption (const string module, const string option, const string value, ModuleEntry::Mode m)
 
bool setOptions (const string module, const ModuleEntry::EntryArg arg, ModuleEntry::Mode m)
 
bool setArgument (const string directive, const string module, const string arg, ModuleEntry::Mode m)
 
bool setComment (const string directive, const string module, const string arg, ModuleEntry::Mode m)
 
bool removeEntry (const string directive, const string module)
 
bool writeFile (const string fname="")
 

Private Types

typedef time_t TimeStamp
 

Private Member Functions

TimeStamp getTimeStamp (const string &fname)
 
bool isDirective (const string directive) const
 
bool isModule (const string directive, const string module)
 
bool isOption (const string module, const string option)
 
bool updateIfModified ()
 
bool updateTimeStamp ()
 
bool updateIndex (const string directive, const string module)
 
bool parseLine (const string &line, ModuleLine &l) const
 
bool parseFile (const string &file_name, ModuleEntry::Mode m, const bool with_comment=true)
 

Private Attributes

string file_name
 
ModulesConfMap modules_conf_map
 
ModulesConfIndex modules_conf_index
 
bool modified
 
TimeStamp time_stamp
 

Detailed Description

The modules.conf file.

This class contains the modules.conf file.

Author
Michal Svec msvec.nosp@m.@sus.nosp@m.e.cz
Dan Vesely dan@s.nosp@m.use..nosp@m.cz
See Also
ModuleEntry

Member Typedef Documentation

typedef map<const string, ModuleEntry> ModulesConf::ModuleEntryMap
typedef list<string> ModulesConf::ModulesConfIndex
typedef map<const string, ModuleEntryMap> ModulesConf::ModulesConfMap
typedef time_t ModulesConf::TimeStamp
private

The return type of getTimeStamp()

Constructor & Destructor Documentation

ModulesConf::ModulesConf ( const string &  fname)

Default constructor.

Parameters
fnameA path to the modules.conf file (usually /etc/modules.conf)

Constructor

References ModuleEntry::INIT, parseFile(), y2debug, and y2warning.

ModulesConf::~ModulesConf ( )

Destructor

References writeFile(), and y2error.

Member Function Documentation

string ModulesConf::getArgument ( const string  directive,
const string  module 
)

For the given directive and module returns the entry argument.

Parameters
directiveA directive for which the argument is returned.
moduleA module for which the argument is returned.
Returns
an entry argument

References getOptionsAsString(), isModule(), MAGIC_ENTRY, modules_conf_map, updateIfModified(), Y2_RETURN_STR, y2debug, and y2warning.

Referenced by ModulesAgent::Read(), and writeFile().

string ModulesConf::getComment ( const string  directive,
const string  module 
)

For the given directive and module returns the entry comment.

Parameters
directiveA directive for which the comment is returned.
moduleA module for which the comment is returned.
Returns
an entry comment

References isModule(), modules_conf_map, updateIfModified(), and Y2_RETURN_STR.

Referenced by ModulesAgent::Read(), and writeFile().

ModulesConf::ModulesConfMap ModulesConf::getDirectives ( )

Returns map of all directives present in the current modules.conf.

Returns
a map of all directives

References modules_conf_map, and updateIfModified().

Referenced by ModulesAgent::Dir(), and ModulesAgent::Read().

ModulesConf::ModuleEntryMap ModulesConf::getModules ( const string  directive)

For the given directive returns all modules in a map.

Parameters
directiveA directive for which the modules are returned.
Returns
a map of all modules for the given directive

References isDirective(), modules_conf_map, updateIfModified(), and y2error.

Referenced by ModulesAgent::Dir(), and ModulesAgent::Read().

string ModulesConf::getOption ( const string  module,
const string  option 
)

For the given module and option returns the option parameter.

Parameters
moduleA module for which the parameter is returned.
optionAn option for which the parameter is returned.
Returns
an option parameter

References isOption(), MAGIC_ENTRY, modules_conf_map, updateIfModified(), Y2_RETURN_STR, and y2debug.

Referenced by ModulesAgent::Read().

ModuleEntry::EntryArg ModulesConf::getOptions ( const string  module)

For the given module returns all options in a map.

Parameters
moduleA module for which the options are returned.
Returns
a map of all options for the given module

References isModule(), MAGIC_ENTRY, modules_conf_map, updateIfModified(), and y2error.

Referenced by ModulesAgent::Dir(), getOptionsAsString(), and ModulesAgent::Read().

string ModulesConf::getOptionsAsString ( const string  module)

For the given module returns all options as one string.

Parameters
moduleA module for which the options are returned.
Returns
all options for the given module in one string

References getOptions().

Referenced by getArgument(), and writeFile().

ModulesConf::TimeStamp ModulesConf::getTimeStamp ( const string &  fname)
private

Return a time stamp of the file.

Parameters
fnameA file name of the file to be stamped.
Returns
the file time stamp

References y2error.

Referenced by updateIfModified(), and updateTimeStamp().

bool ModulesConf::isDirective ( const string  directive) const
private

Test the existence of directive.

Parameters
directiveThe tested directive.
Returns
if the directive exists

References modules_conf_map.

Referenced by getModules(), and isModule().

bool ModulesConf::isModule ( const string  directive,
const string  module 
)
private

Test the existence of module.

Parameters
directiveThe directive of the tested module.
moduleThe tested module.
Returns
if the module exists

References isDirective(), and modules_conf_map.

Referenced by getArgument(), getComment(), getOptions(), isOption(), removeEntry(), updateIndex(), and writeFile().

bool ModulesConf::isOption ( const string  module,
const string  option 
)
private

Test the existence of option.

Parameters
directiveThe directive of the tested option.
moduleThe module of the tested option.
Returns
if the option exists

References isModule(), and modules_conf_map.

Referenced by getOption().

bool ModulesConf::parseFile ( const string &  fname,
ModuleEntry::Mode  m,
const bool  with_comment = true 
)
private

Parse the modules.conf.

Parameters
file_nameThe name of the parsed file.
mIndicates if the option is set during (re)initialization or by an agent.
with_commentIf the comment should be parsed.
Returns
if the operation was successful

Parse the file ...

References ModulesConf::ModuleLine::argument, ModulesConf::ModuleLine::comment, comment, ModulesConf::ModuleLine::directive, FINAL_COMMENT, stringutil::getline(), ModulesConf::ModuleLine::module, ModulesConf::ModuleLine::options, parseLine(), setArgument(), setComment(), setOptions(), updateTimeStamp(), WHITESPACE, and y2debug.

Referenced by ModulesConf(), and updateIfModified().

bool ModulesConf::parseLine ( const string &  line,
ModuleLine l 
) const
private

Parse one line of modules.conf.

Parameters
lineThe line to be parsed.
lThe parsed line.
Returns
if the operation was successful

Parse one line

References ModulesConf::ModuleLine::argument, ModulesConf::ModuleLine::comment, ModulesConf::ModuleLine::directive, killspaces(), ModulesConf::ModuleLine::module, ModulesConf::ModuleLine::options, and Y2_STRING.

Referenced by parseFile().

bool ModulesConf::removeEntry ( const string  directive,
const string  module 
)

Remove one entry from the modules.conf.

Parameters
directiveA removed entry directive.
moduleA removed entry module.
mIndicates if the option is set during (re)initialization or by an agent.
Returns
if the operation was successful

remove one entry ...

References isModule(), modified, modules_conf_index, modules_conf_map, Y2_RETURN_FALSE, and y2warning.

Referenced by ModulesAgent::Write().

bool ModulesConf::setArgument ( const string  directive,
const string  module,
const string  arg,
ModuleEntry::Mode  m 
)

For the given directive and module set the entry argument.

Parameters
directiveA directive for which the argument is set.
moduleA module for which the argument is set.
mIndicates if the option is set during (re)initialization or by an agent.
argAn entry argument.
Returns
if the operation was successful

References modified, modules_conf_map, ModuleEntry::SET, updateIndex(), and y2error.

Referenced by parseFile(), and ModulesAgent::Write().

bool ModulesConf::setComment ( const string  directive,
const string  module,
const string  arg,
ModuleEntry::Mode  m 
)

For the given directive and module set the entry comment.

Parameters
directiveA directive for which the comment is set.
moduleA module for which the comment is set.
mIndicates if the option is set during (re)initialization or by an agent.
argAn entry comment.
Returns
if the operation was successful

References modified, modules_conf_map, and ModuleEntry::SET.

Referenced by parseFile(), and ModulesAgent::Write().

bool ModulesConf::setOption ( const string  module,
const string  option,
const string  value,
ModuleEntry::Mode  m 
)

For the given module and options set the option parameter.

Parameters
moduleA module for which the parameter is set.
optionAn option for which the parameter is set.
valueThe option value.
Returns
if the operation was successful

References modified, modules_conf_map, ModuleEntry::SET, updateIndex(), and y2error.

Referenced by ModulesAgent::Write().

bool ModulesConf::setOptions ( const string  module,
const ModuleEntry::EntryArg  arg,
ModuleEntry::Mode  m 
)

For the given module set all options as a map.

Parameters
moduleA module for which the options are set.
valueThe options as a map.
mIndicates if the option is set during (re)initialization or by an agent.
Returns
if the operation was successful

References modified, modules_conf_map, ModuleEntry::SET, updateIndex(), and Y2_RETURN_FALSE.

Referenced by parseFile(), and ModulesAgent::Write().

bool ModulesConf::updateIfModified ( )
private

Update internal structures if the file has been modified.

Returns
if file has been modified

References file_name, getTimeStamp(), parseFile(), ModuleEntry::REINIT, time_stamp, Y2_RETURN_FALSE, and y2warning.

Referenced by getArgument(), getComment(), getDirectives(), getModules(), getOption(), getOptions(), and writeFile().

bool ModulesConf::updateIndex ( const string  directive,
const string  module 
)
private

Update the file index.

Parameters
directiveA directive for which the index is updated.
moduleA module for which the index is updated.
Returns
if the operation was successful

References isModule(), and modules_conf_index.

Referenced by setArgument(), setOption(), and setOptions().

bool ModulesConf::updateTimeStamp ( )
private

Update the file time stamp.

Returns
if the operation was successful

References file_name, getTimeStamp(), and time_stamp.

Referenced by parseFile(), and writeFile().

bool ModulesConf::writeFile ( const string  fname = "")

Write the modules.conf file to the disk.

Parameters
fnameA file name of the written file.
Returns
if the operation was successful

write the file ...

References BACKUP_EXTENSION, file_name, FINAL_COMMENT, getArgument(), getComment(), getOptionsAsString(), ModuleEntry::INIT, isModule(), modified, modules_conf_index, modules_conf_map, updateIfModified(), updateTimeStamp(), Y2_RETURN_FALSE, y2debug, y2error, y2milestone, and y2warning.

Referenced by ModulesAgent::Write(), and ~ModulesConf().

Member Data Documentation

string ModulesConf::file_name
private
bool ModulesConf::modified
private
ModulesConfIndex ModulesConf::modules_conf_index
private

Referenced by removeEntry(), updateIndex(), and writeFile().

ModulesConfMap ModulesConf::modules_conf_map
private
TimeStamp ModulesConf::time_stamp
private

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

Generated on a sunny day for yast2-core by doxygen 1.8.5