2
/******************************************************
3
* Presage, an extensible predictive text entry system
4
* ---------------------------------------------------
6
* Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
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.
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.
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.
25
#ifndef PRESAGE_PROFILE
26
#define PRESAGE_PROFILE
36
typedef std::string Value;
37
#include "configuration.h"
38
#include "presageException.h"
40
/** Profile provides access to the active profile configuration variables.
42
* Profile only provides an accessor method to read configuration
43
* values. The class is immutable. It is not possible to modify
44
* configuration values. Configuration values are set when the Profile
47
* Profile acts as an interface to ProfileManager. It converts simple
48
* requests for configuration variable values from client objects
49
* (such as Plugin objects) into requests to ProfileManager. There is
50
* no need to have a map containing the variable, value pairs. It is
51
* sufficient to keep a reference to ProfileManager and have
52
* ProfileManager expose an interface that Profile can use to query
58
/** Profile constructor.
60
* \param filename where profile is saved to
62
Profile(const std::string& filename);
64
/** Profile destructor.
66
* Destructor deallocates the Configuration object passed in costructor.
71
/** Writes configuration from XML DOM document into configuration.
74
void read_into_configuration(Configuration* configuration);
76
/* Reads from configuration and writes to XML DOM document.
79
void read_from_configuration (Configuration* configuration);
81
bool file_read_ok () const;
83
bool write_to_file () const;
85
class ProfileException : public PresageException {
87
ProfileException(presage_error_code_t code, const std::string& desc) throw() : PresageException(code, desc) { }
88
virtual ~ProfileException() throw() { }
91
ProfileException() throw() : PresageException(PRESAGE_ERROR, "") { }
96
void init_configuration(Configuration* config, TiXmlDocument* node);
97
void visit_node(Configuration* config, TiXmlNode* node, std::vector<std::string> variable);
99
TiXmlDocument* xmlProfileDoc;
100
std::string xml_filename;
101
bool xml_profile_read_ok;
104
#endif // PRESAGE_PROFILE