predictorRegistry.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_PREDICTORREGISTRY
#define PRESAGE_PREDICTORREGISTRY
#include "dispatcher.h"
#include "../predictors/predictor.h"
class ContextTracker;
class PredictorRegistry : public Observer {
public:
PredictorRegistry(Configuration* config);
~PredictorRegistry();
virtual void update (const Observable* variable);
class Iterator {
public:
Iterator(std::vector<Predictor*>&);
~Iterator();
bool hasNext() const;
Predictor* next();
private:
std::vector<Predictor*>::iterator iter_end;
std::vector<Predictor*>::iterator iter_curr;
};
Iterator iterator();
void setContextTracker(ContextTracker* ct);
class PredictorRegistryException : public PresageException {
public:
PredictorRegistryException(presage_error_code_t code, const std::string& desc) throw() : PresageException(code, desc) { }
virtual ~PredictorRegistryException() throw() { }
private:
PredictorRegistryException() throw() : PresageException(PRESAGE_ERROR, "") { }
};
static const char* LOGGER;
static const char* PREDICTORS;
private:
void setLogger (const std::string& level);
void setPredictors(const std::string& predictor_list);
void addPredictor(const std::string& predictor_name);
void removePredictor(const std::string& predictor_name);
void removePredictors();
Configuration* config;
ContextTracker* contextTracker;
Logger<char> logger;
std::string predictors_list;
std::vector<Predictor*> predictors; // active Predictors
Dispatcher<PredictorRegistry> dispatcher;
};
#endif // PRESAGE_PREDICTORREGISTRY
PredictorRegistry::contextTracker
ContextTracker * contextTracker
Definition: predictorRegistry.h:91
PredictorRegistry::PredictorRegistryException::PredictorRegistryException
PredictorRegistryException(presage_error_code_t code, const std::string &desc)
Definition: predictorRegistry.h:72
PredictorRegistry::~PredictorRegistry
~PredictorRegistry()
Definition: predictorRegistry.cpp:55
Observer
Definition: observer.h:34
PredictorRegistry::PredictorRegistryException
Definition: predictorRegistry.h:70
presage_error_code_t
presage_error_code_t
Definition: presageException.h:32
PRESAGE_ERROR
@ PRESAGE_ERROR
Definition: presageException.h:55
PredictorRegistry::PredictorRegistryException::PredictorRegistryException
PredictorRegistryException()
Definition: predictorRegistry.h:76
dispatcher.h
PresageException::code
virtual const presage_error_code_t code() const
Definition: presageException.h:86
PredictorRegistry::Iterator::iter_curr
std::vector< Predictor * >::iterator iter_curr
Definition: predictorRegistry.h:63
PredictorRegistry::config
Configuration * config
Definition: predictorRegistry.h:90
Predictor
Definition: predictor.h:46
PredictorRegistry::Iterator::hasNext
bool hasNext() const
Definition: predictorRegistry.cpp:248
PredictorRegistry::Iterator::iter_end
std::vector< Predictor * >::iterator iter_end
Definition: predictorRegistry.h:62
PredictorRegistry::predictors_list
std::string predictors_list
Definition: predictorRegistry.h:94
ContextTracker
Tracks user interaction and context.
Definition: contextTracker.h:155
PredictorRegistry::update
virtual void update(const Observable *variable)
Definition: predictorRegistry.cpp:262
PredictorRegistry::Iterator::~Iterator
~Iterator()
Definition: predictorRegistry.cpp:245
PredictorRegistry
Definition: predictorRegistry.h:46
PresageException::PresageException
PresageException(presage_error_code_t code, const std::string &msg)
Definition: presageException.h:69
PredictorRegistry::logger
Logger< char > logger
Definition: predictorRegistry.h:92
PredictorRegistry::Iterator
Definition: predictorRegistry.h:53
PredictorRegistry::setLogger
void setLogger(const std::string &level)
Definition: predictorRegistry.cpp:60
PresageException
Definition: presageException.h:67
PredictorRegistry::predictors
std::vector< Predictor * > predictors
Definition: predictorRegistry.h:95
PredictorRegistry::iterator
Iterator iterator()
Definition: predictorRegistry.cpp:232
PredictorRegistry::LOGGER
static const char * LOGGER
Definition: predictorRegistry.h:80
Configuration
Definition: configuration.h:36
PredictorRegistry::setContextTracker
void setContextTracker(ContextTracker *ct)
Definition: predictorRegistry.cpp:67
PredictorRegistry::removePredictor
void removePredictor(const std::string &predictor_name)
Definition: predictorRegistry.cpp:204
PredictorRegistry::PredictorRegistryException::~PredictorRegistryException
virtual ~PredictorRegistryException()
Definition: predictorRegistry.h:73
Logger< char >
PredictorRegistry::setPredictors
void setPredictors(const std::string &predictor_list)
Definition: predictorRegistry.cpp:75
Observable
Definition: observable.h:37
PredictorRegistry::PREDICTORS
static const char * PREDICTORS
Definition: predictorRegistry.h:81
Dispatcher< PredictorRegistry >
PredictorRegistry::Iterator::Iterator
Iterator(std::vector< Predictor * > &)
Definition: predictorRegistry.cpp:240
PredictorRegistry::PredictorRegistry
PredictorRegistry(Configuration *config)
Definition: predictorRegistry.cpp:43
PredictorRegistry::dispatcher
Dispatcher< PredictorRegistry > dispatcher
Definition: predictorRegistry.h:97
PredictorRegistry::removePredictors
void removePredictors()
Definition: predictorRegistry.cpp:223
PredictorRegistry::Iterator::next
Predictor * next()
Definition: predictorRegistry.cpp:255
PredictorRegistry::addPredictor
void addPredictor(const std::string &predictor_name)
Definition: predictorRegistry.cpp:131