1 | /* |
---|
2 | * |
---|
3 | * Copyright (c) 2007-2016 The University of Waikato, Hamilton, New Zealand. |
---|
4 | * All rights reserved. |
---|
5 | * |
---|
6 | * This file is part of libtrace. |
---|
7 | * |
---|
8 | * This code has been developed by the University of Waikato WAND |
---|
9 | * research group. For further information please see http://www.wand.net.nz/ |
---|
10 | * |
---|
11 | * libtrace is free software; you can redistribute it and/or modify |
---|
12 | * it under the terms of the GNU Lesser General Public License as published by |
---|
13 | * the Free Software Foundation; either version 3 of the License, or |
---|
14 | * (at your option) any later version. |
---|
15 | * |
---|
16 | * libtrace is distributed in the hope that it will be useful, |
---|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 | * GNU Lesser General Public License for more details. |
---|
20 | * |
---|
21 | * You should have received a copy of the GNU Lesser General Public License |
---|
22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
23 | * |
---|
24 | * |
---|
25 | */ |
---|
26 | |
---|
27 | #ifndef OUTPUT_H |
---|
28 | #define OUTPUT_H |
---|
29 | #include <inttypes.h> |
---|
30 | |
---|
31 | typedef char *TYPE__str; |
---|
32 | typedef uint64_t TYPE__int; |
---|
33 | typedef double TYPE__float; |
---|
34 | typedef double TYPE__time; |
---|
35 | struct data_t { |
---|
36 | enum { TYPE_str, TYPE_int, TYPE_float, TYPE_time } type; |
---|
37 | union { |
---|
38 | TYPE__str d_str; |
---|
39 | TYPE__int d_int; |
---|
40 | TYPE__float d_float; |
---|
41 | TYPE__time d_time; |
---|
42 | } d; |
---|
43 | }; |
---|
44 | |
---|
45 | typedef struct output_data_t { |
---|
46 | char *title; |
---|
47 | int columns; |
---|
48 | char **labels; |
---|
49 | struct data_t *data; |
---|
50 | struct output_type_t *format; |
---|
51 | void *private_format_data; |
---|
52 | } output_data_t; |
---|
53 | |
---|
54 | struct output_type_t { |
---|
55 | char *name; |
---|
56 | void (*init)(struct output_data_t *); |
---|
57 | void (*flush)(struct output_data_t *); |
---|
58 | void (*destroy)(struct output_data_t *); |
---|
59 | }; |
---|
60 | extern struct output_type_t output_txt; |
---|
61 | extern struct output_type_t output_csv; |
---|
62 | extern struct output_type_t output_html; |
---|
63 | extern struct output_type_t output_png; |
---|
64 | |
---|
65 | |
---|
66 | struct output_data_t *output_init(char *title, char *format); |
---|
67 | void output_add_column(struct output_data_t *out, char *col); |
---|
68 | void output_flush_headings(struct output_data_t *out); |
---|
69 | void output_set_data_int(struct output_data_t *out,int col,uint64_t data); |
---|
70 | void output_set_data_str(struct output_data_t *out,int col,char *data); |
---|
71 | void output_set_data_float(struct output_data_t *out,int col,double data); |
---|
72 | void output_set_data_time(struct output_data_t *out,int col,double data); |
---|
73 | void output_flush_row(struct output_data_t *out); |
---|
74 | void output_destroy(struct output_data_t *out); |
---|
75 | |
---|
76 | #endif |
---|