profileManager.h
Go to the documentation of this file.
/******************************************************
* Presage, an extensible predictive text entry system
* ---------------------------------------------------
*
* Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
**********(*)*/
#ifndef PRESAGE_PROFILEMANAGER
#define PRESAGE_PROFILEMANAGER
#include "profile.h"
#include "defaultProfile.h"
#include "combiner.h"
#include "logger.h"
#include "dispatcher.h"
#include <string>
#include <list>
#include <sstream> // for std::ostringstream
#include <stdio.h> // for int remove( const char* ) to remove files/dirs
class ProfileManager {
public:
ProfileManager(const std::string = "");
~ProfileManager();
void save_profile() const;
Configuration* get_configuration();
void set_autopersist (const std::string& value);
static const char* LOGGER;
static const char* AUTOPERSIST;
private:
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;
bool loaded_at_least_one_profile;
void cache_log_message(Logger<char>::Level level, const std::string& message);
void flush_cached_log_messages();
void refresh_config();
struct CachedLogMessage {
// Level is commented out because it gets translated to
// numeric value of enum, instead of acting as templatized
// function type switching the logger level as intended. This
// is not an issue however since all cached log messages need
// to be logged at same level, so we can hardcode level in
// flush method.
//
//Logger<char>::Level level;
std::string message;
};
std::list<CachedLogMessage> cached_log_messages;
Configuration* config;
Profile* rw_profile; // readable-writable profile
bool autopersist_config;
Logger<char> logger;
};
#endif // PRESAGE_PROFILEMANAGER
Logger
Definition: logger.h:56
ProfileManager::config
Configuration * config
Definition: profileManager.h:99
ProfileManager::autopersist_config
bool autopersist_config
Definition: profileManager.h:101
ProfileManager::get_configuration
Configuration * get_configuration()
Definition: profileManager.cpp:276
ProfileManager::get_system_etc_dir
std::string get_system_etc_dir() const
Definition: profileManager.cpp:158
ProfileManager::logger
Logger< char > logger
Definition: profileManager.h:103
ProfileManager::LOGGER
static const char * LOGGER
Definition: profileManager.h:62
ProfileManager::save_profile
void save_profile() const
Definition: profileManager.cpp:267
ProfileManager::cached_log_messages
std::list< CachedLogMessage > cached_log_messages
Definition: profileManager.h:97
ProfileManager::refresh_config
void refresh_config()
Definition: profileManager.cpp:308
ProfileManager::rw_profile
Profile * rw_profile
Definition: profileManager.h:100
defaultProfile.h
ProfileManager::CachedLogMessage
Definition: profileManager.h:85
ProfileManager::loaded_at_least_one_profile
bool loaded_at_least_one_profile
Definition: profileManager.h:73
ProfileManager::set_autopersist
void set_autopersist(const std::string &value)
Definition: profileManager.cpp:321
combiner.h
ProfileManager::init_profiles
void init_profiles(const std::string &profilename)
Definition: profileManager.cpp:113
dispatcher.h
Configuration
Definition: configuration.h:36
ProfileManager
Definition: profileManager.h:51
ProfileManager::cache_log_message
void cache_log_message(Logger< char >::Level level, const std::string &message)
Definition: profileManager.cpp:288
ProfileManager::CachedLogMessage::message
std::string message
Definition: profileManager.h:94
logger.h
profile.h
ProfileManager::AUTOPERSIST
static const char * AUTOPERSIST
Definition: profileManager.h:63
Profile
Definition: profile.h:56
ProfileManager::flush_cached_log_messages
void flush_cached_log_messages()
Definition: profileManager.cpp:297
ProfileManager::create_profile_from_xml
Profile * create_profile_from_xml(const std::string &filename)
Definition: profileManager.cpp:84
ProfileManager::~ProfileManager
~ProfileManager()
Definition: profileManager.cpp:70
ProfileManager::ProfileManager
ProfileManager(const std::string="")
Definition: profileManager.cpp:55
ProfileManager::get_user_home_dir
std::string get_user_home_dir() const
Definition: profileManager.cpp:220