presage  0.8.9~beta
predictorActivator.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_PREDICTORACTIVATOR
26 #define PRESAGE_PREDICTORACTIVATOR
27 
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31 
32 #include "configuration.h"
33 #include "predictorRegistry.h"
35 #include "prediction.h"
36 #include "logger.h"
37 #include "dispatcher.h"
38 
39 #include "combiner.h"
40 #include "meritocracyCombiner.h"
41 
42 #include "predictors/predictor.h"
43 
44 
45 #ifdef STDC_HEADERS
46 # include <stdlib.h> // needed for abort function
47 #endif
48 
49 
62 class PredictorActivator : public Observer {
63 public:
64 //PLUMP PredictorActivator(HistoryTracker&,
65 //PLUMP plump::Plump&);
66 
78 
83 
92  Prediction predict(unsigned int multiplier, const char** filter);
93 
98  void setPredictors(const std::string& predictorList);
99 
104  void addPredictor(const std::string& predictorName);
105 
109  void removePredictors();
110 
118  int getPredictTime() const;
119 
125  void setPredictTime(const std::string& predictTime);
126 
135  std::string getCombinationPolicy() const;
136 
148  void setCombinationPolicy(const std::string& policy);
149 
154  void setMaxPartialPredictionSize (const std::string& size);
155 
160  void setLogger (const std::string& level);
161 
162  void parse_internal_commands (Prediction& pred);
163 
164  virtual void update (const Observable* variable);
165 
166  static const char* LOGGER;
167  static const char* PREDICT_TIME;
168  static const char* MAX_PARTIAL_PREDICTION_SIZE;
169  static const char* COMBINATION_POLICY;
170 
171 private:
172  // execute predictor function (invoked in thread)
173  void *execute(void *);
174 
175 
179 
181 
183  std::string combinationPolicy;
184 
186 
187  std::vector<Prediction> predictions; // predictions computed by each predictor are returned here
188 
190 
192 };
193 
194 #endif // PRESAGE_PREDICTORACTIVATOR
Prediction predict(unsigned int multiplier, const char **filter)
static const char * LOGGER
Configuration * config
void setMaxPartialPredictionSize(const std::string &size)
static const char * PREDICT_TIME
void setPredictors(const std::string &predictorList)
void parse_internal_commands(Prediction &pred)
static const char * MAX_PARTIAL_PREDICTION_SIZE
void setPredictTime(const std::string &predictTime)
void setCombinationPolicy(const std::string &policy)
std::string getCombinationPolicy() const
virtual void update(const Observable *variable)
PredictorActivator(Configuration *config, PredictorRegistry *registry, ContextTracker *contextTracker)
void setLogger(const std::string &level)
static const char * COMBINATION_POLICY
void addPredictor(const std::string &predictorName)
std::string combinationPolicy
ContextTracker * contextTracker
Tracks user interaction and context.
Dispatcher< PredictorActivator > dispatcher
PredictorRegistry * predictorRegistry
std::vector< Prediction > predictions
void * execute(void *)