presage  0.9
presage.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
26 #define PRESAGE
27 
28 #include "presageException.h"
29 #include "presageCallback.h"
30 
85 /********************************
86  * Presage C++ API starts here
87  */
88 
89 #ifdef __cplusplus
90 #ifndef _MSC_VER
91 
92 #include <string>
93 #include <vector>
94 #include <map>
95 
96 /* Forward declarations, not part of presage C++ API */
97 class Configuration;
98 class ProfileManager;
99 class Profile;
100 class ContextTracker;
101 class PredictorRegistry;
102 class PredictorActivator;
103 class Selector;
104 
107 class Presage {
108 public:
116 
117 
125  Presage(PresageCallback* callback, const std::string config) throw (PresageException);
126 
127 
130  ~Presage();
131 
141  std::vector<std::string> predict() throw (PresageException);
142 
156  std::multimap<double, std::string> predict(std::vector<std::string> filter) throw (PresageException);
157 
166 
179  std::string completion(std::string str) throw (PresageException);
180 
185  std::string context() const throw (PresageException);
186 
192  bool context_change() const throw (PresageException);
193 
198  std::string prefix() const throw (PresageException);
199 
207  std::string config(const std::string variable) const throw (PresageException);
208 
216  void config(const std::string variable, const std::string value) const throw (PresageException);
217 
225  void save_config() const throw (PresageException);
226 
227  /*
228  * Presage public API ends here
229  */
230 
231 private:
238 
239 };
240 
241 #endif /* _MSC_VER */
242 #endif /* __cplusplus */
243 
244 /*
245  * Presage C++ API ends here
246  *******************************/
247 
248 
249 /*******************************
250  * Presage C API starts here
251  */
252 
253 #ifdef __cplusplus
254 extern "C" {
255 #endif
256 
257  typedef struct _presage* presage_t;
258 
260  void* past_stream_cb_arg,
261  _presage_callback_get_future_stream future_stream_cb,
262  void* future_stream_cb_arg,
263  presage_t* result);
264 
266  void* past_stream_cb_arg,
267  _presage_callback_get_future_stream future_stream_cb,
268  void* future_stream_cb_arg,
269  const char* config,
270  presage_t* result);
271 
272  void presage_free (presage_t prsg);
273 
274  void presage_free_string (char* str);
275  void presage_free_string_array (char** str);
276 
277  presage_error_code_t presage_predict (presage_t prsg,
278  char*** result);
279 
281  const char* token,
282  char** result);
283 
284  presage_error_code_t presage_context (presage_t prsg,
285  char** result);
286 
288  int* result);
289 
290  presage_error_code_t presage_prefix (presage_t prsg,
291  char** result);
292 
293  presage_error_code_t presage_config (presage_t prsg,
294  const char* variable,
295  char** result);
296 
298  const char* variable,
299  const char* value);
300 
301  presage_error_code_t presage_save_config (presage_t prsg);
302 
303 #ifdef __cplusplus
304 }
305 #endif
306 
307 /*
308  * Presage C API ends here
309  ****************************/
310 
311 
312 #endif /* PRESAGE */
PredictorRegistry * predictorRegistry
Definition: presage.h:234
presage_error_code_t
Selector * selector
Definition: presage.h:237
std::vector< std::string > predict()
Obtain a prediction.
Definition: presage.cpp:64
bool context_change() const
Returns true if a context change occured.
Definition: presage.cpp:199
PresageCallback * callback(PresageCallback *callback)
Callback getter/setter.
Definition: presage.cpp:139
presage_error_code_t presage_save_config(presage_t prsg)
Definition: presage.cpp:440
struct _presage * presage_t
Definition: presage.h:257
presage_error_code_t presage_new_with_config(_presage_callback_get_past_stream past, void *past_stream_cb_arg, _presage_callback_get_future_stream future_stream_cb, void *future_stream_cb_arg, const char *config, presage_t *result)
Definition: presage.cpp:318
void presage_free_string_array(char **str)
Definition: presage.cpp:356
void presage_free(presage_t prsg)
Definition: presage.cpp:340
Presage(PresageCallback *callback)
Definition: presage.cpp:33
presage_error_code_t presage_config_set(presage_t prsg, const char *variable, const char *value)
Definition: presage.cpp:432
presage_error_code_t presage_predict(presage_t prsg, char ***result)
Definition: presage.cpp:366
const char *(* _presage_callback_get_past_stream)(void *)
presage_error_code_t presage_new(_presage_callback_get_past_stream past_stream_cb, void *past_stream_cb_arg, _presage_callback_get_future_stream future_stream_cb, void *future_stream_cb_arg, presage_t *result)
Definition: presage.cpp:297
PredictorActivator * predictorActivator
Definition: presage.h:236
ContextTracker * contextTracker
Definition: presage.h:235
std::string config
Definition: presageDemo.cpp:70
std::string config(const std::string variable) const
Gets the value of specified configuration variable.
Definition: presage.cpp:211
presage_error_code_t presage_prefix(presage_t prsg, char **result)
Definition: presage.cpp:416
~Presage()
Definition: presage.cpp:55
const char *(* _presage_callback_get_future_stream)(void *)
presage_error_code_t presage_context_change(presage_t prsg, int *result)
Definition: presage.cpp:408
void save_config() const
Save current configuration to file.
Definition: presage.cpp:223
presage_error_code_t presage_context(presage_t prsg, char **result)
Definition: presage.cpp:400
std::string prefix() const
Returns the current prefix.
Definition: presage.cpp:205
ProfileManager * profileManager
Definition: presage.h:232
Presage, the intelligent predictive text entry platform.
Definition: presage.h:107
Configuration * configuration
Definition: presage.h:233
std::string context() const
Returns the text entered so far.
Definition: presage.cpp:193
presage_error_code_t presage_config(presage_t prsg, const char *variable, char **result)
Definition: presage.cpp:424
void presage_free_string(char *str)
Definition: presage.cpp:351
Tracks user interaction and context.
presage_error_code_t presage_completion(presage_t prsg, const char *token, char **result)
Definition: presage.cpp:392
std::string completion(std::string str)
Request presage to return the completion string for the given predicted token.
Definition: presage.cpp:145