src/data_provider.[ch]: Implement "data_provider_get_ident_ds_names".
[collection4.git] / src / data_provider.h
1 /**
2  * collection4 - data_provider.h
3  * Copyright (C) 2010  Florian octo Forster
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) 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 GNU
13  * Lesser General Public License for more details.
14  * 
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA  02110-1301  USA
19  *
20  * Authors:
21  *   Florian octo Forster <ff at octo.it>
22  **/
23
24 #ifndef DATA_PROVIDER_H
25 #define DATA_PROVIDER_H 1
26
27 #include "graph_types.h"
28 #include "oconfig.h"
29
30 #include <time.h>
31
32 typedef struct timespec dp_time_t;
33
34 struct dp_data_point_s
35 {
36   dp_time_t time;
37   double value;
38 };
39 typedef struct dp_data_point_s dp_data_point_t;
40
41 /* Callback passed to the "get_idents" function. */
42 typedef int (*dp_get_idents_callback) (const graph_ident_t *, void *);
43
44 /* Callback passed to the "get_ident_ds_names" function. */
45 typedef int (*dp_list_get_ident_ds_names_callback) (const graph_ident_t *,
46     const char *ds_name, void *);
47
48 /* Callback passed to the "get_ident_data" function. */
49 typedef int (*dp_get_ident_data_callback) (graph_ident_t *, const char *ds_name,
50     const dp_data_point_t *dp, size_t dp_num,
51     void *);
52
53 struct data_provider_s
54 {
55   int (*get_idents) (void *priv, dp_get_idents_callback, void *);
56   int (*get_ident_ds_names) (void *priv, graph_ident_t *,
57       dp_list_get_ident_ds_names_callback, void *);
58   int (*get_ident_data) (void *priv,
59       graph_ident_t *, const char *ds_name,
60       dp_time_t begin, dp_time_t end,
61       dp_get_ident_data_callback, void *);
62   /* Optional method: Prints graph to STDOUT, including HTTP header. */
63   int (*print_graph) (void *priv, graph_config_t *cfg, graph_instance_t *inst);
64   void *private_data;
65 };
66 typedef struct data_provider_s data_provider_t;
67
68 int data_provider_config (const oconfig_item_t *ci);
69
70 int data_provider_register (const char *name, data_provider_t *p);
71 int data_provider_get_idents (dp_get_idents_callback callback, void *user_data);
72 int data_provider_get_ident_ds_names (graph_ident_t *ident,
73     dp_list_get_ident_ds_names_callback callback, void *user_data);
74 int data_provider_get_ident_data (graph_ident_t *ident,
75     const char *ds_name,
76     dp_time_t begin, dp_time_t end,
77     dp_get_ident_data_callback callback, void *user_data);
78
79 #endif /* DATA_PROVIDER_H */
80 /* vim: set sw=2 sts=2 et fdm=marker : */