1 /**
2 * collection4 - graph_instance.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 **/
24 #ifndef GRAPH_INSTANCE_H
25 #define GRAPH_INSTANCE_H 1
27 #include <time.h>
29 #include <yajl/yajl_gen.h>
31 #include "graph_types.h"
32 #include "data_provider.h"
33 #include "graph_ident.h"
34 #include "rrd_args.h"
35 #include "utils_array.h"
37 /*
38 * Methods
39 */
40 graph_instance_t *inst_create (graph_config_t *cfg,
41 const graph_ident_t *ident);
43 void inst_destroy (graph_instance_t *inst);
45 int inst_add_file (graph_instance_t *inst, const graph_ident_t *file);
47 graph_instance_t *inst_get_selected (graph_config_t *cfg);
49 int inst_get_all_selected (graph_config_t *cfg,
50 graph_inst_callback_t callback, void *user_data);
52 int inst_get_params (graph_config_t *cfg, graph_instance_t *inst,
53 char *buffer, size_t buffer_size);
55 int inst_get_rrdargs (graph_config_t *cfg, graph_instance_t *inst,
56 rrd_args_t *args);
58 graph_ident_t *inst_get_selector (graph_instance_t *inst);
60 int inst_compare (const graph_instance_t *i0, const graph_instance_t *i1);
62 int inst_compare_ident (graph_instance_t *inst, const graph_ident_t *ident);
64 /* Returns true if "ident" matches the instance's selector. */
65 _Bool inst_ident_matches (graph_instance_t *inst, const graph_ident_t *ident);
67 /* Returns true if the instance's selector matches the (more general)
68 * "selector" ident. */
69 _Bool inst_matches_ident (graph_instance_t *inst,
70 const graph_ident_t *selector);
72 _Bool inst_matches_string (graph_config_t *cfg, graph_instance_t *inst,
73 const char *term);
75 /* Compares the given string with the appropriate field of the selector or, if
76 * the selector field is "/all/", iterates over all the files of the instance
77 * and checks the appropriate field. Returns true if the field of the selector
78 * or of one of the files matches. The string must match entirely but
79 * comparison is done case-insensitive. */
80 _Bool inst_matches_field (graph_instance_t *inst,
81 graph_ident_field_t field, const char *field_value);
83 int inst_to_json (const graph_instance_t *inst, yajl_gen handler);
84 int inst_data_to_json (const graph_instance_t *inst,
85 dp_time_t begin, dp_time_t end,
86 yajl_gen handler);
88 int inst_describe (graph_config_t *cfg, graph_instance_t *inst,
89 char *buffer, size_t buffer_size);
91 time_t inst_get_mtime (graph_instance_t *inst);
93 #endif /* GRAPH_INSTANCE_H */
94 /* vim: set sw=2 sts=2 et fdm=marker : */