presage  0.9.2~beta
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 
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 
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
102 
104 
105 };
106 
107 
108 #endif // PRESAGE_PROFILEMANAGER
Definition: logger.h:56
Configuration * config
Configuration * get_configuration()
std::string get_system_etc_dir() const
Logger< char > logger
static const char * LOGGER
void save_profile() const
std::list< CachedLogMessage > cached_log_messages
Profile * rw_profile
bool loaded_at_least_one_profile
void set_autopersist(const std::string &value)
void init_profiles(const std::string &profilename)
void cache_log_message(Logger< char >::Level level, const std::string &message)
static const char * AUTOPERSIST
void flush_cached_log_messages()
Profile * create_profile_from_xml(const std::string &filename)
ProfileManager(const std::string="")
std::string get_user_home_dir() const