presage  0.9.2~beta
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
ProfileManager Class Reference

#include <profileManager.h>

Collaboration diagram for ProfileManager:
Collaboration graph

Classes

struct  CachedLogMessage
 

Public Member Functions

 ProfileManager (const std::string="")
 
 ~ProfileManager ()
 
void save_profile () const
 
Configurationget_configuration ()
 
void set_autopersist (const std::string &value)
 

Static Public Attributes

static const char * LOGGER = "Presage.ProfileManager.LOGGER"
 
static const char * AUTOPERSIST = "Presage.ProfileManager.AUTOPERSIST"
 

Private Member Functions

void init_profiles (const std::string &profilename)
 
Profilecreate_profile_from_xml (const std::string &filename)
 
std::string get_user_home_dir () const
 
std::string get_system_etc_dir () const
 
void cache_log_message (Logger< char >::Level level, const std::string &message)
 
void flush_cached_log_messages ()
 
void refresh_config ()
 

Private Attributes

bool loaded_at_least_one_profile
 
std::list< CachedLogMessagecached_log_messages
 
Configurationconfig
 
Profilerw_profile
 
bool autopersist_config
 
Logger< char > logger
 

Detailed Description

Juggles configuration files and presage system initialization.

ProfileManager loads up a bunch of xml files containing configuration data and initializes a configuration object.

  1. write config with data from /etc/presage.xml if it exists
  2. overwrite config with data from /presage.xml if it exists
  3. overwrite config with data from ~/.presage/presage.xml if it exists
  4. overwrite config with data from profile passed to constructor (if non-empty string)

Definition at line 51 of file profileManager.h.

Constructor & Destructor Documentation

◆ ProfileManager()

ProfileManager::ProfileManager ( const std::string  profilename = "")

Constructor.

Initialises other modules.

Definition at line 55 of file profileManager.cpp.

References autopersist_config, config, init_profiles(), loaded_at_least_one_profile, and rw_profile.

Here is the call graph for this function:

◆ ~ProfileManager()

ProfileManager::~ProfileManager ( )

Destructor.

Definition at line 70 of file profileManager.cpp.

References AUTOPERSIST, autopersist_config, config, Configuration::find(), flush_cached_log_messages(), Variable::get_value(), rw_profile, save_profile(), and set_autopersist().

Here is the call graph for this function:

Member Function Documentation

◆ cache_log_message()

void ProfileManager::cache_log_message ( Logger< char >::Level  level,
const std::string &  message 
)
private

Cache log message until logger level is read from configuration.

Definition at line 282 of file profileManager.cpp.

References cached_log_messages, and ProfileManager::CachedLogMessage::message.

Referenced by create_profile_from_xml().

Here is the caller graph for this function:

◆ create_profile_from_xml()

Profile * ProfileManager::create_profile_from_xml ( const std::string &  filename)
private

Definition at line 84 of file profileManager.cpp.

References cache_log_message(), Profile::file_read_ok(), logger, and Logger< _charT, _Traits >::NOTICE.

Referenced by init_profiles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flush_cached_log_messages()

void ProfileManager::flush_cached_log_messages ( )
private

Flush cached log messages.

Definition at line 291 of file profileManager.cpp.

References cached_log_messages, endl(), and logger.

Referenced by refresh_config(), and ~ProfileManager().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_configuration()

Configuration * ProfileManager::get_configuration ( )

Definition at line 270 of file profileManager.cpp.

References config, and refresh_config().

Here is the call graph for this function:

◆ get_system_etc_dir()

std::string ProfileManager::get_system_etc_dir ( ) const
private

Definition at line 152 of file profileManager.cpp.

Referenced by init_profiles().

Here is the caller graph for this function:

◆ get_user_home_dir()

std::string ProfileManager::get_user_home_dir ( ) const
private

Definition at line 214 of file profileManager.cpp.

References HOME.

Referenced by init_profiles().

Here is the caller graph for this function:

◆ init_profiles()

void ProfileManager::init_profiles ( const std::string &  profilename)
private

Definition at line 113 of file profileManager.cpp.

References config, create_profile_from_xml(), DefaultProfile::DEFAULT_PROFILE_FILENAME, Profile::file_read_ok(), get_system_etc_dir(), get_user_home_dir(), loaded_at_least_one_profile, Profile::read_into_configuration(), and rw_profile.

Referenced by ProfileManager().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ refresh_config()

void ProfileManager::refresh_config ( )
private

Refresh configuration variables

Definition at line 302 of file profileManager.cpp.

References config, Configuration::find(), flush_cached_log_messages(), Variable::get_value(), LOGGER, logger, and setlevel().

Referenced by get_configuration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_profile()

void ProfileManager::save_profile ( ) const

Write profile to disk.

Returns true is file was saved successfully, false otherwise.

Definition at line 261 of file profileManager.cpp.

References config, endl(), logger, Profile::read_from_configuration(), rw_profile, and Profile::write_to_file().

Referenced by Presage::save_config(), and ~ProfileManager().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_autopersist()

void ProfileManager::set_autopersist ( const std::string &  value)

Definition at line 315 of file profileManager.cpp.

References autopersist_config, endl(), Utility::isTrue(), and logger.

Referenced by ~ProfileManager().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ AUTOPERSIST

const char * ProfileManager::AUTOPERSIST = "Presage.ProfileManager.AUTOPERSIST"
static

Definition at line 63 of file profileManager.h.

Referenced by ~ProfileManager().

◆ autopersist_config

bool ProfileManager::autopersist_config
private

Definition at line 101 of file profileManager.h.

Referenced by ProfileManager(), set_autopersist(), and ~ProfileManager().

◆ cached_log_messages

std::list<CachedLogMessage> ProfileManager::cached_log_messages
private

Definition at line 97 of file profileManager.h.

Referenced by cache_log_message(), and flush_cached_log_messages().

◆ config

Configuration* ProfileManager::config
private

◆ loaded_at_least_one_profile

bool ProfileManager::loaded_at_least_one_profile
private

Definition at line 73 of file profileManager.h.

Referenced by init_profiles(), and ProfileManager().

◆ LOGGER

const char * ProfileManager::LOGGER = "Presage.ProfileManager.LOGGER"
static

Definition at line 62 of file profileManager.h.

Referenced by refresh_config().

◆ logger

Logger<char> ProfileManager::logger
private

◆ rw_profile

Profile* ProfileManager::rw_profile
private

Definition at line 100 of file profileManager.h.

Referenced by init_profiles(), ProfileManager(), save_profile(), and ~ProfileManager().


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