presage  0.9.2~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 
101  int getPredictTime() const;
102 
108  void setPredictTime(const std::string& predictTime);
109 
118  std::string getCombinationPolicy() const;
119 
131  void setCombinationPolicy(const std::string& policy);
132 
137  void setMaxPartialPredictionSize (const std::string& size);
138 
143  void setLogger (const std::string& level);
144 
145  void parse_internal_commands (Prediction& pred);
146 
147  virtual void update (const Observable* variable);
148 
149  static const char* LOGGER;
150  static const char* PREDICT_TIME;
151  static const char* MAX_PARTIAL_PREDICTION_SIZE;
152  static const char* COMBINATION_POLICY;
153 
154 private:
155  // execute predictor function (invoked in thread)
156  void *execute(void *);
157 
158 
162 
164 
166  std::string combinationPolicy;
167 
169 
170  std::vector<Prediction> predictions; // predictions computed by each predictor are returned here
171 
173 
175 };
176 
177 #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 parse_internal_commands(Prediction &pred)
static const char * MAX_PARTIAL_PREDICTION_SIZE
void setPredictTime(const std::string &predictTime)
void setCombinationPolicy(const std::string &policy)
virtual void update(const Observable *variable)
std::string getCombinationPolicy() const
PredictorActivator(Configuration *config, PredictorRegistry *registry, ContextTracker *contextTracker)
void setLogger(const std::string &level)
static const char * COMBINATION_POLICY
std::string combinationPolicy
ContextTracker * contextTracker
Tracks user interaction and context.
Dispatcher< PredictorActivator > dispatcher
PredictorRegistry * predictorRegistry
std::vector< Prediction > predictions
void * execute(void *)