presage  0.8.8
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 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * Presage C API starts here
37  */
38 
39  typedef struct _presage* presage_t;
40 
42  void* past_stream_cb_arg,
43  _presage_callback_get_future_stream future_stream_cb,
44  void* future_stream_cb_arg,
45  presage_t* result);
46 
48  void* past_stream_cb_arg,
49  _presage_callback_get_future_stream future_stream_cb,
50  void* future_stream_cb_arg,
51  const char* config,
52  presage_t* result);
53 
54  void presage_free (presage_t prsg);
55 
56  void presage_free_string (char* str);
57  void presage_free_string_array (char** str);
58 
59  presage_error_code_t presage_predict (presage_t prsg,
60  char*** result);
61 
63  const char* token,
64  char** result);
65 
66  presage_error_code_t presage_context (presage_t prsg,
67  char** result);
68 
70  int* result);
71 
72  presage_error_code_t presage_prefix (presage_t prsg,
73  char** result);
74 
75  presage_error_code_t presage_config (presage_t prsg,
76  const char* variable,
77  char** result);
78 
80  const char* variable,
81  const char* value);
82 
84 
85 
86 /*
87  * Presage C API ends here
88  */
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 
94 #ifdef __cplusplus
95 #ifndef _MSC_VER
96 /*
97  * Presage C++ API starts here
98  */
99 
100 
101 #include <string>
102 #include <vector>
103 #include <map>
104 
105 /* Forward declarations, not part of presage C++ API */
106 class Configuration;
107 class ProfileManager;
108 class Profile;
109 class ContextTracker;
110 class PredictorRegistry;
111 class PredictorActivator;
112 class Selector;
113 
116 class Presage {
117 public:
125 
126 
134  Presage(PresageCallback* callback, const std::string config) throw (PresageException);
135 
136 
139  ~Presage();
140 
150  std::vector<std::string> predict() throw (PresageException);
151 
165  std::multimap<double, std::string> predict(std::vector<std::string> filter) throw (PresageException);
166 
175 
188  std::string completion(std::string str) throw (PresageException);
189 
194  std::string context() const throw (PresageException);
195 
201  bool context_change() const throw (PresageException);
202 
207  std::string prefix() const throw (PresageException);
208 
216  std::string config(const std::string variable) const throw (PresageException);
217 
225  void config(const std::string variable, const std::string value) const throw (PresageException);
226 
234  void save_config() const throw (PresageException);
235 
236  /*
237  * Presage public API ends here
238  */
239 
240 private:
247 
248 };
249 
250 /*
251  * Presage C++ API ends here
252  */
253 #endif /* _MSC_VER */
254 #endif /* __cplusplus */
255 
310 #endif /* PRESAGE */
PredictorRegistry * predictorRegistry
Definition: presage.h:243
presage_error_code_t
Selector * selector
Definition: presage.h:246
void presage_free(presage_t prsg)
Definition: presage.cpp:335
presage_error_code_t presage_save_config(presage_t prsg)
Definition: presage.cpp:431
presage_error_code_t presage_prefix(presage_t prsg, char **result)
Definition: presage.cpp:407
presage_error_code_t presage_predict(presage_t prsg, char ***result)
Definition: presage.cpp:361
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
struct _presage * presage_t
Definition: presage.h:39
presage_error_code_t presage_config(presage_t prsg, const char *variable, char **result)
Definition: presage.cpp:415
Presage(PresageCallback *callback)
Definition: presage.cpp:33
void presage_free_string_array(char **strs)
Definition: presage.cpp:351
const char *(* _presage_callback_get_past_stream)(void *)
presage_error_code_t presage_context(presage_t prsg, char **result)
Definition: presage.cpp:391
PredictorActivator * predictorActivator
Definition: presage.h:245
presage_error_code_t presage_context_change(presage_t prsg, int *result)
Definition: presage.cpp:399
ContextTracker * contextTracker
Definition: presage.h:244
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_new_with_config(_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, const char *config, presage_t *result)
Definition: presage.cpp:316
presage_error_code_t presage_config_set(presage_t prsg, const char *variable, const char *value)
Definition: presage.cpp:423
~Presage()
Definition: presage.cpp:55
const char *(* _presage_callback_get_future_stream)(void *)
void save_config() const
Save current configuration to file.
Definition: presage.cpp:223
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
std::string prefix() const
Returns the current prefix.
Definition: presage.cpp:205
ProfileManager * profileManager
Definition: presage.h:241
Presage, the intelligent predictive text entry platform.
Definition: presage.h:116
Configuration * configuration
Definition: presage.h:242
std::string context() const
Returns the text entered so far.
Definition: presage.cpp:193
presage_error_code_t presage_completion(presage_t prsg, const char *token, char **result)
Definition: presage.cpp:383
Tracks user interaction and context.
void presage_free_string(char *str)
Definition: presage.cpp:346
std::string completion(std::string str)
Request presage to return the completion string for the given predicted token.
Definition: presage.cpp:145