presage  0.9.1
profileManager.h
Go to the documentation of this file.
1 
2 /******************************************************
3  * Presage, an extensible predictive text entry system
4  * ---------------------------------------------------
5  *
6  * Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License along
19  with this program; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  *
22  **********(*)*/
23 
24 
25 #ifndef PRESAGE_PROFILEMANAGER
26 #define PRESAGE_PROFILEMANAGER
27 
28 #include "profile.h"
29 #include "defaultProfile.h"
30 #include "combiner.h"
31 #include "logger.h"
32 #include "dispatcher.h"
33 
34 #include <string>
35 #include <list>
36 #include <sstream> // for std::ostringstream
37 #include <stdio.h> // for int remove( const char* ) to remove files/dirs
38 
39 
51 class ProfileManager {
52 public:
53  ProfileManager(const std::string = "");
55 
56  void save_profile() const;
57 
59 
60  void set_autopersist (const std::string& value);
61 
62  static const char* LOGGER;
63  static const char* AUTOPERSIST;
64 
65 private:
66  void init_profiles (const std::string& profilename);
67 
68  Profile* create_profile_from_xml (const std::string& filename);
69 
70  std::string get_user_home_dir() const;
71  std::string get_system_etc_dir() const;
72 
74 
77  void cache_log_message(Logger<char>::Level level, const std::string& message);
83  void refresh_config();
84 
85  struct CachedLogMessage {
86  // Level is commented out because it gets translated to
87  // numeric value of enum, instead of acting as templatized
88  // function type switching the logger level as intended. This
89  // is not an issue however since all cached log messages need
90  // to be logged at same level, so we can hardcode level in
91  // flush method.
92  //
93  //Logger<char>::Level level;
94  std::string message;
95  };
96 
97  std::list<CachedLogMessage> cached_log_messages;
98 
100  Profile* rw_profile; // readable-writable profile
101  bool autopersist_config;
102 
104 
105 };
106 
107 
108 #endif // PRESAGE_PROFILEMANAGER
profile.h
ProfileManager::loaded_at_least_one_profile
bool loaded_at_least_one_profile
Definition: profileManager.h:91
logger.h
ProfileManager::cache_log_message
void cache_log_message(Logger< char >::Level level, const std::string &message)
Definition: profileManager.cpp:288
ProfileManager::create_profile_from_xml
Profile * create_profile_from_xml(const std::string &filename)
Definition: profileManager.cpp:84
Profile
Definition: profile.h:55
dispatcher.h
ProfileManager
Definition: profileManager.h:50
defaultProfile.h
ProfileManager::flush_cached_log_messages
void flush_cached_log_messages()
Definition: profileManager.cpp:297
ProfileManager::logger
Logger< char > logger
Definition: profileManager.h:121
ProfileManager::LOGGER
static const char * LOGGER
Definition: profileManager.h:80
ProfileManager::refresh_config
void refresh_config()
Definition: profileManager.cpp:308
ProfileManager::AUTOPERSIST
static const char * AUTOPERSIST
Definition: profileManager.h:81
ProfileManager::autopersist_config
bool autopersist_config
Definition: profileManager.h:119
ProfileManager::get_system_etc_dir
std::string get_system_etc_dir() const
Definition: profileManager.cpp:158
ProfileManager::init_profiles
void init_profiles(const std::string &profilename)
Definition: profileManager.cpp:113
ProfileManager::CachedLogMessage
Definition: profileManager.h:103
ProfileManager::CachedLogMessage::message
std::string message
Definition: profileManager.h:112
ProfileManager::save_profile
void save_profile() const
Definition: profileManager.cpp:267
Configuration
Definition: configuration.h:35
ProfileManager::get_user_home_dir
std::string get_user_home_dir() const
Definition: profileManager.cpp:220
ProfileManager::ProfileManager
ProfileManager(const std::string="")
Definition: profileManager.cpp:55
combiner.h
ProfileManager::rw_profile
Profile * rw_profile
Definition: profileManager.h:118
ProfileManager::cached_log_messages
std::list< CachedLogMessage > cached_log_messages
Definition: profileManager.h:115
Logger
Definition: logger.h:55
ProfileManager::set_autopersist
void set_autopersist(const std::string &value)
Definition: profileManager.cpp:321
ProfileManager::get_configuration
Configuration * get_configuration()
Definition: profileManager.cpp:276
ProfileManager::config
Configuration * config
Definition: profileManager.h:117
ProfileManager::~ProfileManager
~ProfileManager()
Definition: profileManager.cpp:70