sensor: unified numeric datatypes
[oweals/gnunet.git] / src / sensor / plugin_sensor_model_gaussian.c
1 /*
2  * This file is part of GNUnet
3  * (C) 2013 Christian Grothoff (and other contributing authors)
4  *
5  * GNUnet is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published
7  * by the Free Software Foundation; either version 3, or (at your
8  * option) any later version.
9  *
10  * GNUnet is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with GNUnet; see the file COPYING.  If not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 /*
22  * @file sensor/plugin_sensor_model_gaussian.c
23  * @brief Gaussian model for sensor analysis
24  * @author Omar Tarabai
25  */
26
27 #include "platform.h"
28 #include "gnunet_sensor_model_plugin.h"
29 #include "gnunet_sensor_service.h"
30 #include "sensor.h"
31
32 #define LOG(kind,...) GNUNET_log_from (kind, "sensor-model-gaussian", __VA_ARGS__)
33
34 /*
35  * Plugin state information
36  */
37 struct Plugin
38 {
39
40   /*
41    * Configuration handle
42    */
43   const struct GNUNET_CONFIGURATION_Handle *cfg;
44
45 };
46
47 /*
48  * State of single model instance
49  */
50 struct Model
51 {
52
53   /*
54    * Pointer to the plugin state
55    */
56   struct Plugin *plugin;
57
58 };
59
60 static void *
61 sensor_gaussian_model_create_model (void *cls)
62 {
63   struct Plugin *plugin = cls;
64   struct Model *model;
65
66   model = GNUNET_new(struct Model);
67   model->plugin = plugin;
68   return model;
69 }
70
71 /*
72  * Entry point for the plugin.
73  *
74  * @param cls The struct GNUNET_CONFIGURATION_Handle.
75  * @return NULL on error, otherwise the plugin context
76  */
77 void *
78 libgnunet_plugin_sensor_model_gaussian_init (void *cls)
79 {
80   static struct Plugin plugin;
81   const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
82   struct GNUNET_SENSOR_ModelFunctions *api;
83
84   if (NULL != plugin.cfg)
85     return NULL;                /* can only initialize once! */
86   memset (&plugin, 0, sizeof (struct Plugin));
87   plugin.cfg = cfg;
88   api = GNUNET_new (struct GNUNET_SENSOR_ModelFunctions);
89   api->cls = &plugin;
90   LOG(GNUNET_ERROR_TYPE_DEBUG, "Guassian model plugin is running\n");
91   return api;
92 }
93
94 /*
95  * Exit point from the plugin.
96  *
97  * @param cls The plugin context (as returned by "init")
98  * @return Always NULL
99  */
100 void *
101 libgnunet_plugin_sensor_model_gaussian_done (void *cls)
102 {
103   struct GNUNET_SENSOR_ModelFunctions *api = cls;
104   struct Plugin *plugin = api->cls;
105
106   plugin->cfg = NULL;
107   GNUNET_free (api);
108   LOG (GNUNET_ERROR_TYPE_DEBUG, "Guassian model plugin is finished\n");
109   return NULL;
110
111 }
112
113 /* end of plugin_sensor_model_gaussian.c */