src/graph_instance.[ch]: Implement "inst_get_all_selected".
[collection4.git] / src / graph_instance.h
index 72ab66a..a6e7462 100644 (file)
@@ -1,23 +1,13 @@
 #ifndef GRAPH_INSTANCE_H
 #define GRAPH_INSTANCE_H 1
 
-/*
- * Data types
- */
-struct graph_instance_s;
-typedef struct graph_instance_s graph_instance_t;
-
-typedef int (*inst_callback_t) (graph_instance_t *inst, void *user_data);
-
 #include <time.h>
 
-#include "graph.h"
+#include "graph_types.h"
+#include "graph_ident.h"
 #include "utils_array.h"
 
 /*
- * Callback types
- */
-/*
  * Methods
  */
 graph_instance_t *inst_create (graph_config_t *cfg,
@@ -29,6 +19,9 @@ int inst_add_file (graph_instance_t *inst, const graph_ident_t *file);
 
 graph_instance_t *inst_get_selected (graph_config_t *cfg);
 
+int inst_get_all_selected (graph_config_t *cfg,
+    graph_inst_callback_t callback, void *user_data);
+
 int inst_get_params (graph_config_t *cfg, graph_instance_t *inst,
     char *buffer, size_t buffer_size);
 
@@ -37,13 +30,20 @@ int inst_get_rrdargs (graph_config_t *cfg, graph_instance_t *inst,
 
 graph_ident_t *inst_get_selector (graph_instance_t *inst);
 
-int inst_append (graph_instance_t *head, graph_instance_t *inst);
+int inst_compare_ident (graph_instance_t *inst, const graph_ident_t *ident);
+
+_Bool inst_matches_ident (graph_instance_t *inst, const graph_ident_t *ident);
 
-int inst_foreach (graph_instance_t *inst,
-               inst_callback_t cb, void *user_data);
+_Bool inst_matches_string (graph_config_t *cfg, graph_instance_t *inst,
+    const char *term);
 
-graph_instance_t *inst_find_matching (graph_instance_t *inst,
-    const graph_ident_t *ident);
+/* Compares the given string with the appropriate field of the selector or, if
+ * the selector field is "/all/", iterates over all the files of the instance
+ * and checks the appropriate field. Returns true if the field of the selector
+ * or of one of the files matches. The string must match entirely but
+ * comparison is done case-insensitive. */
+_Bool inst_matches_field (graph_instance_t *inst,
+    graph_ident_field_t field, const char *field_value);
 
 int inst_describe (graph_config_t *cfg, graph_instance_t *inst,
     char *buffer, size_t buffer_size);