4eced2de4d074261f60e0fd8ac6d7f48010742a7
[collection4.git] / src / graph_ident.h
1 /**
2  * collection4 - graph_ident.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_IDENT_H
25 #define GRAPH_IDENT_H 1
26
27 #include <time.h>
28 #include "graph_types.h"
29
30 #define ANY_TOKEN "/any/"
31 #define ALL_TOKEN "/all/"
32
33 #define IS_ANY(str) (((str) != NULL) && (strcasecmp (ANY_TOKEN, (str)) == 0))
34 #define IS_ALL(str) (((str) != NULL) && (strcasecmp (ALL_TOKEN, (str)) == 0))
35
36 enum graph_ident_field_e
37 {
38   GIF_HOST,
39   GIF_PLUGIN,
40   GIF_PLUGIN_INSTANCE,
41   GIF_TYPE,
42   GIF_TYPE_INSTANCE,
43   _GIF_LAST
44 };
45 typedef enum graph_ident_field_e graph_ident_field_t;
46
47 graph_ident_t *ident_create (const char *host,
48     const char *plugin, const char *plugin_instance,
49     const char *type, const char *type_instance);
50 graph_ident_t *ident_clone (const graph_ident_t *ident);
51
52 #define IDENT_FLAG_REPLACE_ALL 0x01
53 #define IDENT_FLAG_REPLACE_ANY 0x02
54 graph_ident_t *ident_copy_with_selector (const graph_ident_t *selector,
55     const graph_ident_t *ident, unsigned int flags);
56
57 void ident_destroy (graph_ident_t *ident);
58
59 const char *ident_get_host (const graph_ident_t *ident);
60 const char *ident_get_plugin (const graph_ident_t *ident);
61 const char *ident_get_plugin_instance (const graph_ident_t *ident);
62 const char *ident_get_type (const graph_ident_t *ident);
63 const char *ident_get_type_instance (const graph_ident_t *ident);
64 const char *ident_get_field (const graph_ident_t *ident,
65     graph_ident_field_t field);
66
67 int ident_set_host (graph_ident_t *ident, const char *host);
68 int ident_set_plugin (graph_ident_t *ident, const char *plugin);
69 int ident_set_plugin_instance (graph_ident_t *ident,
70     const char *plugin_instance);
71 int ident_set_type (graph_ident_t *ident, const char *type);
72 int ident_set_type_instance (graph_ident_t *ident,
73     const char *type_instance);
74
75 int ident_compare (const graph_ident_t *i0,
76     const graph_ident_t *i1);
77
78 _Bool ident_matches (const graph_ident_t *selector,
79     const graph_ident_t *ident);
80
81 char *ident_to_string (const graph_ident_t *ident);
82 char *ident_to_file (const graph_ident_t *ident);
83 char *ident_to_json (const graph_ident_t *ident);
84
85 time_t ident_get_mtime (const graph_ident_t *ident);
86
87 /* vim: set sw=2 sts=2 et fdm=marker : */
88 #endif /* GRAPH_IDENT_H */