1 /* rec_engine.h -- generic stroke recognition engine interface
2 
3    Copyright (C) 2000 Carl Worth
4 
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9 
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14 */
15 
16 #ifndef REC_ENGINE_H
17 #define REC_ENGINE_H
18 
19 #include "stroke.h"
20 
21 #define REC_LIB_PREFIX "rec_"
22 #define REC_ENGINE_FUNCS_SYMBOL "engine_funcs"
23 
24 struct rec_engine;
25 
26 struct rec_engine_funcs
27 {
28     int    (*priv_alloc)(struct rec_engine *engine);
29     void   (*priv_free)(struct rec_engine *engine);
30     void * (*feature_data_alloc)(struct rec_engine *engine,
31 				 char *feature_data_str);
32     void   (*feature_data_free)(struct rec_engine *engine, void *feature_data);
33     void   (*classify_stroke)(struct rec_engine *engine, stroke_t *stroke);
34     char * (*classification_str_alloc)(struct rec_engine *engine, stroke_t *stroke);
35     void   (*free_classification)(struct rec_engine *engine, stroke_t *stroke);
36     double (*recognize_stroke)(struct rec_engine *engine, stroke_t *stroke,
37 			       void *feature_data);
38     int    (*set_option)(struct rec_engine *engine, char *option, char *value);
39 };
40 typedef struct rec_engine_funcs rec_engine_funcs_t;
41 
42 struct rec_engine
43 {
44     struct rec *rec;
45     char *name;
46     int num;
47     rec_engine_funcs_t *funcs;
48     void *priv;
49 };
50 typedef struct rec_engine rec_engine_t;
51 
52 struct rec_engine_list
53 {
54     int num_engines;
55     rec_engine_t **engines;
56 };
57 typedef struct rec_engine_list rec_engine_list_t;
58 
59 int rec_engine_init(rec_engine_t *engine, struct rec *rec, char *engine_name);
60 void rec_engine_deinit(rec_engine_t *engine);
61 
62 void *rec_engine_feature_data_alloc(rec_engine_t *engine, char *feature_data_str);
63 void rec_engine_feature_data_free(rec_engine_t *engine, void *feature_data);
64 
65 void rec_engine_classify_stroke(rec_engine_t *engine, stroke_t *stroke);
66 char *rec_engine_classification_str_alloc(rec_engine_t *engine, stroke_t *stroke);
67 void rec_engine_free_classification(rec_engine_t *engine, stroke_t *stroke);
68 
69 double rec_engine_recognize_stroke(rec_engine_t *engine, stroke_t *stroke,
70 				   void *feature_data);
71 
72 int rec_engine_set_option(rec_engine_t *engine, char *name, char *value);
73 
74 int rec_engine_list_init(rec_engine_list_t *list);
75 void rec_engine_list_deinit_shallow(rec_engine_list_t *list);
76 int rec_engine_list_append(rec_engine_list_t *list, rec_engine_t *engine);
77 
78 #endif
79