predictorActivator.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_PREDICTORACTIVATOR
#define PRESAGE_PREDICTORACTIVATOR
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "configuration.h"
#include "predictorRegistry.h"
#include "context_tracker/contextTracker.h"
#include "prediction.h"
#include "logger.h"
#include "dispatcher.h"
#include "combiner.h"
#include "meritocracyCombiner.h"
#include "predictors/predictor.h"
#ifdef STDC_HEADERS
# include <stdlib.h> // needed for abort function
#endif
class PredictorActivator : public Observer {
public:
//PLUMP PredictorActivator(HistoryTracker&,
//PLUMP plump::Plump&);
PredictorActivator(Configuration* config, PredictorRegistry* registry, ContextTracker* contextTracker);
~PredictorActivator();
Prediction predict(unsigned int multiplier, const char** filter);
int getPredictTime() const;
void setPredictTime(const std::string& predictTime);
std::string getCombinationPolicy() const;
void setCombinationPolicy(const std::string& policy);
void setMaxPartialPredictionSize (const std::string& size);
void setLogger (const std::string& level);
void parse_internal_commands (Prediction& pred);
virtual void update (const Observable* variable);
static const char* LOGGER;
static const char* PREDICT_TIME;
static const char* MAX_PARTIAL_PREDICTION_SIZE;
static const char* COMBINATION_POLICY;
private:
// execute predictor function (invoked in thread)
void *execute(void *);
Configuration* config;
PredictorRegistry* predictorRegistry;
ContextTracker* contextTracker;
Logger<char> logger;
Combiner* combiner;
std::string combinationPolicy;
int max_partial_prediction_size;
std::vector<Prediction> predictions; // predictions computed by each predictor are returned here
int predict_time;
Dispatcher<PredictorActivator> dispatcher;
};
#endif // PRESAGE_PREDICTORACTIVATOR
Combiner
Definition combiner.h:40
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::Observer
Observer()
Definition observer.h:40
Prediction
Definition prediction.h:47
PredictorActivator::setMaxPartialPredictionSize
void setMaxPartialPredictionSize(const std::string &size)
Definition predictorActivator.cpp:146
PredictorActivator::parse_internal_commands
void parse_internal_commands(Prediction &pred)
Definition predictorActivator.cpp:160
PredictorActivator::setPredictTime
void setPredictTime(const std::string &predictTime)
Definition predictorActivator.cpp:101
PredictorActivator::getCombinationPolicy
std::string getCombinationPolicy() const
Definition predictorActivator.cpp:140
PredictorActivator::combiner
Combiner * combiner
Definition predictorActivator.h:165
PredictorActivator::logger
Logger< char > logger
Definition predictorActivator.h:163
PredictorActivator::getPredictTime
int getPredictTime() const
Definition predictorActivator.cpp:117
PredictorActivator::PredictorActivator
PredictorActivator(Configuration *config, PredictorRegistry *registry, ContextTracker *contextTracker)
Definition predictorActivator.cpp:33
PredictorActivator::contextTracker
ContextTracker * contextTracker
Definition predictorActivator.h:161
PredictorActivator::combinationPolicy
std::string combinationPolicy
Definition predictorActivator.h:166
PredictorActivator::MAX_PARTIAL_PREDICTION_SIZE
static const char * MAX_PARTIAL_PREDICTION_SIZE
Definition predictorActivator.h:151
PredictorActivator::setCombinationPolicy
void setCombinationPolicy(const std::string &policy)
Definition predictorActivator.cpp:123
PredictorActivator::dispatcher
Dispatcher< PredictorActivator > dispatcher
Definition predictorActivator.h:174
PredictorActivator::LOGGER
static const char * LOGGER
Definition predictorActivator.h:149
PredictorActivator::update
virtual void update(const Observable *variable)
Definition predictorActivator.cpp:153
PredictorActivator::PREDICT_TIME
static const char * PREDICT_TIME
Definition predictorActivator.h:150
PredictorActivator::predictorRegistry
PredictorRegistry * predictorRegistry
Definition predictorActivator.h:160
PredictorActivator::~PredictorActivator
~PredictorActivator()
Definition predictorActivator.cpp:52
PredictorActivator::setLogger
void setLogger(const std::string &level)
Definition predictorActivator.cpp:94
PredictorActivator::execute
void * execute(void *)
PredictorActivator::predict_time
int predict_time
Definition predictorActivator.h:172
PredictorActivator::max_partial_prediction_size
int max_partial_prediction_size
Definition predictorActivator.h:168
PredictorActivator::predictions
std::vector< Prediction > predictions
Definition predictorActivator.h:170
PredictorActivator::predict
Prediction predict(unsigned int multiplier, const char **filter)
Definition predictorActivator.cpp:57
PredictorActivator::COMBINATION_POLICY
static const char * COMBINATION_POLICY
Definition predictorActivator.h:152
PredictorActivator::config
Configuration * config
Definition predictorActivator.h:159
PredictorRegistry
Definition predictorRegistry.h:46
combiner.h
configuration.h
contextTracker.h
dispatcher.h
logger.h
meritocracyCombiner.h
prediction.h
predictorRegistry.h
predictor.h