presage  0.8.7
presage.h
Go to the documentation of this file.
00001 
00002 /******************************************************
00003  *  Presage, an extensible predictive text entry system
00004  *  ---------------------------------------------------
00005  *
00006  *  Copyright (C) 2008  Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
00007 
00008     This program is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     This program is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License along
00019     with this program; if not, write to the Free Software Foundation, Inc.,
00020     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00021                                                                              *
00022                                                                 **********(*)*/
00023 
00024 
00025 #ifndef PRESAGE
00026 #define PRESAGE
00027 
00028 #include "presageException.h"
00029 #include "presageCallback.h"
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 
00035 /*
00036  *    Presage C API starts here
00037  */
00038 
00039     typedef struct _presage* presage_t;
00040 
00041     presage_error_code_t presage_new                 (_presage_callback_get_past_stream past_stream_cb,
00042                                                       void* past_stream_cb_arg,
00043                                                       _presage_callback_get_future_stream future_stream_cb,
00044                                                       void* future_stream_cb_arg,
00045                                                       presage_t* result);
00046     
00047     presage_error_code_t presage_new_with_config     (_presage_callback_get_past_stream past,
00048                                                       void* past_stream_cb_arg,
00049                                                       _presage_callback_get_future_stream future_stream_cb,
00050                                                       void* future_stream_cb_arg,
00051                                                       const char* config,
00052                                                       presage_t* result);
00053     
00054     void                 presage_free                (presage_t prsg);
00055     
00056     void                 presage_free_string         (char* str);
00057     void                 presage_free_string_array   (char** str);
00058 
00059     presage_error_code_t presage_predict             (presage_t prsg,
00060                                                       char*** result);
00061     
00062     presage_error_code_t presage_completion          (presage_t prsg,
00063                                                       const char* token,
00064                                                       char** result);
00065 
00066     presage_error_code_t presage_context             (presage_t prsg, 
00067                                                       char** result);
00068 
00069     presage_error_code_t presage_context_change      (presage_t prsg,
00070                                                       int* result);
00071 
00072     presage_error_code_t presage_prefix              (presage_t prsg,
00073                                                       char** result);
00074 
00075     presage_error_code_t presage_config              (presage_t prsg,
00076                                                       const char* variable,
00077                                                       char** result);
00078 
00079     presage_error_code_t presage_config_set          (presage_t prsg,
00080                                                       const char* variable,
00081                                                       const char* value);
00082     
00083     presage_error_code_t presage_save_config         (presage_t prsg);
00084 
00085 
00086 /*
00087  *    Presage C API ends here
00088  */
00089 #ifdef __cplusplus
00090 }
00091 #endif
00092 
00093 
00094 #ifdef __cplusplus
00095 #ifndef _MSC_VER
00096 /*
00097  *    Presage C++ API starts here
00098  */
00099 
00100 
00101 #include <string>
00102 #include <vector>
00103 #include <map>
00104 
00105 /* Forward declarations, not part of presage C++ API */
00106 class Configuration;
00107 class ProfileManager;
00108 class Profile;
00109 class ContextTracker;
00110 class PredictorRegistry;
00111 class PredictorActivator;
00112 class Selector;
00113 
00116 class Presage {
00117 public:
00124     Presage(PresageCallback* callback) throw (PresageException);
00125 
00126 
00134     Presage(PresageCallback* callback, const std::string config) throw (PresageException);
00135 
00136 
00139     ~Presage();
00140 
00158     std::vector<std::string> predict() throw (PresageException);
00159 
00172     std::multimap<double, std::string> predict(std::vector<std::string> filter) throw (PresageException);
00173 
00181     PresageCallback* callback(PresageCallback* callback) throw (PresageException);
00182 
00195     std::string completion(std::string str) throw (PresageException);
00196 
00201     std::string context() const throw (PresageException);
00202 
00208     bool context_change() const throw (PresageException);
00209 
00214     std::string prefix() const throw (PresageException);
00215 
00223     std::string config(const std::string variable) const throw (PresageException);
00224 
00232     void config(const std::string variable, const std::string value) const throw (PresageException);
00233 
00241     void save_config() const throw (PresageException);
00242 
00243     /*
00244      * Presage public API ends here
00245      */
00246 
00247 private:
00248     ProfileManager*     profileManager;
00249     Configuration*      configuration;
00250     PredictorRegistry*     predictorRegistry;
00251     ContextTracker*     contextTracker;
00252     PredictorActivator* predictorActivator;
00253     Selector*           selector;
00254 
00255 };
00256 
00257 /*
00258  *    Presage C++ API ends here
00259  */
00260 #endif /* _MSC_VER */
00261 #endif /* __cplusplus */
00262 
00317 #endif /* PRESAGE */