a5e9c76dca25796bf742233d4de3a4c2347d6bdd
[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
29 #include <time.h>
30
31 typedef struct timespec dp_time_t;
32
33 struct dp_data_point_s
34 {
35   dp_time_t time;
36   double value;
37 };
38 typedef struct dp_data_point_s dp_data_point_t;
39
40 /* Callback passed to the "get_idents" function. */
41 typedef int (*dp_get_idents_callback) (const graph_ident_t *, void *);
42
43 /* Callback passed to the "get_ident_ds_names" function. */
44 typedef int (*dp_list_get_ident_ds_names_callback) (const graph_ident_t *,
45     const char *ds_name, void *);
46
47 /* Callback passed to the "get_ident_data" function. */
48 typedef int (*dp_get_ident_data_callback) (graph_ident_t *, const char *ds_name,
49     const dp_data_point_t *, void *);
50
51 struct data_provider_s
52 {
53   int (*get_idents) (void *priv, dp_get_idents_callback, void *);
54   int (*get_ident_ds_names) (void *priv, graph_ident_t *,
55       dp_list_get_ident_ds_names_callback, void *);
56   int (*get_ident_data) (void *priv,
57       graph_ident_t *, const char *ds_name,
58       dp_time_t begin, dp_time_t end,
59       dp_get_ident_data_callback, void *);
60   /* Optional method: Prints graph to STDOUT, including HTTP header. */
61   int (*print_graph) (void *priv, graph_config_t *cfg, graph_instance_t *inst);
62   void *private_data;
63 };
64 typedef struct data_provider_s data_provider_t;
65
66 #endif /* DATA_PROVIDER_H */
67 /* vim: set sw=2 sts=2 et fdm=marker : */