X-Git-Url: https://git.octo.it/?p=collection4.git;a=blobdiff_plain;f=src%2Fgraph_instance.h;h=0279deb3da1781d49c860bb094f138b8db4b0782;hp=72ab66a657f8162b8340c16cb78e37e499d3cec9;hb=c4c851ce35ad88eff7f843dbced132f55b8a2f6c;hpb=580d18370af2cf4feb48d46ff7e50c0231323349 diff --git a/src/graph_instance.h b/src/graph_instance.h index 72ab66a..0279deb 100644 --- a/src/graph_instance.h +++ b/src/graph_instance.h @@ -1,23 +1,40 @@ +/** + * collection4 - graph_instance.h + * Copyright (C) 2010 Florian octo Forster + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authors: + * Florian octo Forster + **/ + #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 -#include "graph.h" +#include + +#include "graph_types.h" +#include "data_provider.h" +#include "graph_ident.h" +#include "rrd_args.h" #include "utils_array.h" /* - * Callback types - */ -/* * Methods */ graph_instance_t *inst_create (graph_config_t *cfg, @@ -29,21 +46,44 @@ 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); int inst_get_rrdargs (graph_config_t *cfg, graph_instance_t *inst, - str_array_t *args); + rrd_args_t *args); graph_ident_t *inst_get_selector (graph_instance_t *inst); -int inst_append (graph_instance_t *head, graph_instance_t *inst); +int inst_compare (const graph_instance_t *i0, const graph_instance_t *i1); + +int inst_compare_ident (graph_instance_t *inst, const graph_ident_t *ident); + +/* Returns true if "ident" matches the instance's selector. */ +_Bool inst_ident_matches (graph_instance_t *inst, const graph_ident_t *ident); + +/* Returns true if the instance's selector matches the (more general) + * "selector" ident. */ +_Bool inst_matches_ident (graph_instance_t *inst, + const graph_ident_t *selector); + +_Bool inst_matches_string (graph_config_t *cfg, graph_instance_t *inst, + const char *term); -int inst_foreach (graph_instance_t *inst, - inst_callback_t cb, void *user_data); +/* 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); -graph_instance_t *inst_find_matching (graph_instance_t *inst, - const graph_ident_t *ident); +int inst_to_json (const graph_instance_t *inst, yajl_gen handler); +int inst_data_to_json (const graph_instance_t *inst, + dp_time_t begin, dp_time_t end, + yajl_gen handler); int inst_describe (graph_config_t *cfg, graph_instance_t *inst, char *buffer, size_t buffer_size);