presage  0.9.1
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
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