src/graph_ident.[ch]: Mark the inst argument to the "ident_get_*" functions as "const".
[collection4.git] / src / graph_ident.h
1 #ifndef GRAPH_IDENT_H
2 #define GRAPH_IDENT_H 1
3
4 #include <time.h>
5 #include "graph_types.h"
6
7 #define ANY_TOKEN "/any/"
8 #define ALL_TOKEN "/all/"
9
10 #define IS_ANY(str) (((str) != NULL) && (strcasecmp (ANY_TOKEN, (str)) == 0))
11 #define IS_ALL(str) (((str) != NULL) && (strcasecmp (ALL_TOKEN, (str)) == 0))
12
13 enum graph_ident_field_e
14 {
15   GIF_HOST,
16   GIF_PLUGIN,
17   GIF_PLUGIN_INSTANCE,
18   GIF_TYPE,
19   GIF_TYPE_INSTANCE,
20   _GIF_LAST
21 };
22 typedef enum graph_ident_field_e graph_ident_field_t;
23
24 graph_ident_t *ident_create (const char *host,
25     const char *plugin, const char *plugin_instance,
26     const char *type, const char *type_instance);
27 graph_ident_t *ident_clone (const graph_ident_t *ident);
28
29 #define IDENT_FLAG_REPLACE_ALL 0x01
30 #define IDENT_FLAG_REPLACE_ANY 0x02
31 graph_ident_t *ident_copy_with_selector (const graph_ident_t *selector,
32     const graph_ident_t *ident, unsigned int flags);
33
34 void ident_destroy (graph_ident_t *ident);
35
36 const char *ident_get_host (const graph_ident_t *ident);
37 const char *ident_get_plugin (const graph_ident_t *ident);
38 const char *ident_get_plugin_instance (const graph_ident_t *ident);
39 const char *ident_get_type (const graph_ident_t *ident);
40 const char *ident_get_type_instance (const graph_ident_t *ident);
41 const char *ident_get_field (const graph_ident_t *ident,
42     graph_ident_field_t field);
43
44 int ident_set_host (graph_ident_t *ident, const char *host);
45 int ident_set_plugin (graph_ident_t *ident, const char *plugin);
46 int ident_set_plugin_instance (graph_ident_t *ident,
47     const char *plugin_instance);
48 int ident_set_type (graph_ident_t *ident, const char *type);
49 int ident_set_type_instance (graph_ident_t *ident,
50     const char *type_instance);
51
52 int ident_compare (const graph_ident_t *i0,
53     const graph_ident_t *i1);
54
55 _Bool ident_matches (const graph_ident_t *selector,
56     const graph_ident_t *ident);
57
58 char *ident_to_string (const graph_ident_t *ident);
59 char *ident_to_file (const graph_ident_t *ident);
60 char *ident_to_json (const graph_ident_t *ident);
61
62 time_t ident_get_mtime (const graph_ident_t *ident);
63
64 /* vim: set sw=2 sts=2 et fdm=marker : */
65 #endif /* GRAPH_IDENT_H */