src/graph_def.c: Use "ident_describe" to generate a legend entry …
[collection4.git] / src / graph_instance.h
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  **/
23
24 #ifndef GRAPH_INSTANCE_H
25 #define GRAPH_INSTANCE_H 1
26
27 #include <time.h>
28
29 #include "graph_types.h"
30 #include "graph_ident.h"
31 #include "rrd_args.h"
32 #include "utils_array.h"
33
34 /*
35  * Methods
36  */
37 graph_instance_t *inst_create (graph_config_t *cfg,
38                 const graph_ident_t *ident);
39
40 void inst_destroy (graph_instance_t *inst);
41
42 int inst_add_file (graph_instance_t *inst, const graph_ident_t *file);
43
44 graph_instance_t *inst_get_selected (graph_config_t *cfg);
45
46 int inst_get_all_selected (graph_config_t *cfg,
47     graph_inst_callback_t callback, void *user_data);
48
49 int inst_get_params (graph_config_t *cfg, graph_instance_t *inst,
50     char *buffer, size_t buffer_size);
51
52 int inst_get_rrdargs (graph_config_t *cfg, graph_instance_t *inst,
53     rrd_args_t *args);
54
55 graph_ident_t *inst_get_selector (graph_instance_t *inst);
56
57 int inst_compare (const graph_instance_t *i0, const graph_instance_t *i1);
58
59 int inst_compare_ident (graph_instance_t *inst, const graph_ident_t *ident);
60
61 /* Returns true if "ident" matches the instance's selector. */
62 _Bool inst_ident_matches (graph_instance_t *inst, const graph_ident_t *ident);
63
64 /* Returns true if the instance's selector matches the (more general)
65  * "selector" ident. */
66 _Bool inst_matches_ident (graph_instance_t *inst,
67     const graph_ident_t *selector);
68
69 _Bool inst_matches_string (graph_config_t *cfg, graph_instance_t *inst,
70     const char *term);
71
72 /* Compares the given string with the appropriate field of the selector or, if
73  * the selector field is "/all/", iterates over all the files of the instance
74  * and checks the appropriate field. Returns true if the field of the selector
75  * or of one of the files matches. The string must match entirely but
76  * comparison is done case-insensitive. */
77 _Bool inst_matches_field (graph_instance_t *inst,
78     graph_ident_field_t field, const char *field_value);
79
80 int inst_describe (graph_config_t *cfg, graph_instance_t *inst,
81     char *buffer, size_t buffer_size);
82
83 time_t inst_get_mtime (graph_instance_t *inst);
84
85 #endif /* GRAPH_INSTANCE_H */
86 /* vim: set sw=2 sts=2 et fdm=marker : */