presage  0.9.2~beta
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:
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 
69 
71  public:
72  PredictorRegistryException(presage_error_code_t code, const std::string& desc) throw() : PresageException(code, desc) { }
73  virtual ~PredictorRegistryException() throw() { }
74 
75  private:
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 
93 
94  std::string predictors_list;
95  std::vector<Predictor*> predictors; // active Predictors
96 
98 };
99 
100 #endif // PRESAGE_PREDICTORREGISTRY
presage_error_code_t
static const char * PREDICTORS
PresageException(presage_error_code_t code, const std::string &msg)
void removePredictor(const std::string &predictor_name)
std::vector< Predictor * >::iterator iter_curr
Configuration * config
Iterator(std::vector< Predictor *> &)
virtual void update(const Observable *variable)
Logger< char > logger
PredictorRegistry(Configuration *config)
std::vector< Predictor * > predictors
Dispatcher< PredictorRegistry > dispatcher
void addPredictor(const std::string &predictor_name)
static const char * LOGGER
std::string predictors_list
std::vector< Predictor * >::iterator iter_end
void setContextTracker(ContextTracker *ct)
void setLogger(const std::string &level)
virtual const presage_error_code_t code() const
Tracks user interaction and context.
PredictorRegistryException(presage_error_code_t code, const std::string &desc)
void setPredictors(const std::string &predictor_list)
ContextTracker * contextTracker