presage
0.9.1
src
lib
core
predictorRegistry.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_PREDICTORREGISTRY
26
#define PRESAGE_PREDICTORREGISTRY
27
28
#include "
dispatcher.h
"
29
#include "
../predictors/predictor.h
"
30
31
class
ContextTracker
;
32
46
class
PredictorRegistry
:
public
Observer
{
47
public
:
48
PredictorRegistry
(
Configuration
*
config
);
49
~PredictorRegistry
();
50
51
virtual
void
update
(
const
Observable
* variable);
52
53
class
Iterator
{
54
public
:
55
Iterator
(std::vector<Predictor*>&);
56
~Iterator
();
57
58
bool
hasNext
()
const
;
59
Predictor
*
next
();
60
61
private
:
62
std::vector<Predictor*>::iterator
iter_end
;
63
std::vector<Predictor*>::iterator
iter_curr
;
64
65
};
66
67
Iterator
iterator
();
68
void
setContextTracker
(
ContextTracker
* ct);
69
70
class
PredictorRegistryException
:
public
PresageException
{
71
public
:
72
PredictorRegistryException
(
presage_error_code_t
code
,
const
std::string& desc)
throw
() :
PresageException
(
code
, desc) { }
73
virtual
~PredictorRegistryException
() throw() { }
74
75
private
:
76
PredictorRegistryException
() throw() :
PresageException
(
PRESAGE_ERROR
, "") { }
77
78
};
79
80
static
const
char
*
LOGGER
;
81
static
const
char
*
PREDICTORS
;
82
83
private
:
84
void
setLogger
(
const
std::string& level);
85
void
setPredictors
(
const
std::string& predictor_list);
86
void
addPredictor
(
const
std::string& predictor_name);
87
void
removePredictor
(
const
std::string& predictor_name);
88
void
removePredictors
();
89
90
Configuration
*
config
;
91
ContextTracker
*
contextTracker
;
92
Logger<char>
logger
;
93
94
std::string
predictors_list
;
95
std::vector<Predictor*>
predictors
;
// active Predictors
96
97
Dispatcher<PredictorRegistry>
dispatcher
;
98
};
99
100
#endif
// PRESAGE_PREDICTORREGISTRY
Configuration
Definition
configuration.h:36
ContextTracker
Tracks user interaction and context.
Definition
contextTracker.h:155
Dispatcher
Definition
dispatcher.h:42
Logger
Definition
logger.h:57
Observable
Definition
observable.h:37
Observer
Definition
observer.h:34
PredictorRegistry::Iterator
Definition
predictorRegistry.h:53
PredictorRegistry::Iterator::Iterator
Iterator(std::vector< Predictor * > &)
Definition
predictorRegistry.cpp:240
PredictorRegistry::Iterator::next
Predictor * next()
Definition
predictorRegistry.cpp:255
PredictorRegistry::Iterator::~Iterator
~Iterator()
Definition
predictorRegistry.cpp:245
PredictorRegistry::Iterator::iter_end
std::vector< Predictor * >::iterator iter_end
Definition
predictorRegistry.h:62
PredictorRegistry::Iterator::hasNext
bool hasNext() const
Definition
predictorRegistry.cpp:248
PredictorRegistry::Iterator::iter_curr
std::vector< Predictor * >::iterator iter_curr
Definition
predictorRegistry.h:63
PredictorRegistry::PredictorRegistryException
Definition
predictorRegistry.h:70
PredictorRegistry::PredictorRegistryException::PredictorRegistryException
PredictorRegistryException()
Definition
predictorRegistry.h:76
PredictorRegistry::PredictorRegistryException::PredictorRegistryException
PredictorRegistryException(presage_error_code_t code, const std::string &desc)
Definition
predictorRegistry.h:72
PredictorRegistry::PredictorRegistryException::~PredictorRegistryException
virtual ~PredictorRegistryException()
Definition
predictorRegistry.h:73
PredictorRegistry
Definition
predictorRegistry.h:46
PredictorRegistry::PredictorRegistry
PredictorRegistry(Configuration *config)
Definition
predictorRegistry.cpp:43
PredictorRegistry::setLogger
void setLogger(const std::string &level)
Definition
predictorRegistry.cpp:60
PredictorRegistry::setContextTracker
void setContextTracker(ContextTracker *ct)
Definition
predictorRegistry.cpp:67
PredictorRegistry::predictors
std::vector< Predictor * > predictors
Definition
predictorRegistry.h:95
PredictorRegistry::~PredictorRegistry
~PredictorRegistry()
Definition
predictorRegistry.cpp:55
PredictorRegistry::logger
Logger< char > logger
Definition
predictorRegistry.h:92
PredictorRegistry::LOGGER
static const char * LOGGER
Definition
predictorRegistry.h:80
PredictorRegistry::PREDICTORS
static const char * PREDICTORS
Definition
predictorRegistry.h:81
PredictorRegistry::addPredictor
void addPredictor(const std::string &predictor_name)
Definition
predictorRegistry.cpp:131
PredictorRegistry::contextTracker
ContextTracker * contextTracker
Definition
predictorRegistry.h:91
PredictorRegistry::iterator
Iterator iterator()
Definition
predictorRegistry.cpp:232
PredictorRegistry::removePredictor
void removePredictor(const std::string &predictor_name)
Definition
predictorRegistry.cpp:204
PredictorRegistry::predictors_list
std::string predictors_list
Definition
predictorRegistry.h:94
PredictorRegistry::config
Configuration * config
Definition
predictorRegistry.h:90
PredictorRegistry::setPredictors
void setPredictors(const std::string &predictor_list)
Definition
predictorRegistry.cpp:75
PredictorRegistry::update
virtual void update(const Observable *variable)
Definition
predictorRegistry.cpp:262
PredictorRegistry::removePredictors
void removePredictors()
Definition
predictorRegistry.cpp:223
PredictorRegistry::dispatcher
Dispatcher< PredictorRegistry > dispatcher
Definition
predictorRegistry.h:97
Predictor
Definition
predictor.h:46
PresageException
Definition
presageException.h:67
PresageException::code
virtual const presage_error_code_t code() const
Definition
presageException.h:86
PresageException::PresageException
PresageException(presage_error_code_t code, const std::string &msg)
Definition
presageException.h:69
dispatcher.h
predictor.h
presage_error_code_t
presage_error_code_t
Definition
presageException.h:33
PRESAGE_ERROR
@ PRESAGE_ERROR
Definition
presageException.h:35
Generated by
1.10.0