ProfileManager Class Reference

`#include <profileManager.h>`

Collaboration diagram for ProfileManager:

## Classes

struct | CachedLogMessage

## Public Member Functions

| ProfileManager (const std::string="")
| ~ProfileManager ()
void | save_profile () const
Configuration * | get_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)
Profile * | create_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< CachedLogMessage > | cached_log_messages
Configuration * | config
Profile * | rw_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, logger, 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, flush_cached_log_messages(), 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 288 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(), and logger.

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 297 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 276 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 158 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 220 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 308 of file profileManager.cpp.

References config, flush_cached_log_messages(), 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 267 of file profileManager.cpp.

References config, endl(), logger, and rw_profile.

Referenced by ~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 321 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

Definition at line 99 of file profileManager.h.

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

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

Definition at line 103 of file profileManager.h.

Referenced by create_profile_from_xml(), flush_cached_log_messages(), ProfileManager(), refresh_config(), save_profile(), and set_autopersist().

## 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:

- /build/presage-XwIsB9/presage-0.9.1/src/lib/core/profileManager.h
- /build/presage-XwIsB9/presage-0.9.1/src/lib/core/profileManager.cpp