actf 0.0.1
An acute CTF reader
Loading...
Searching...
No Matches
/home/adwe/code/actf/metadata.h
Go to the documentation of this file.
1/*
2 * This file is a part of ACTF.
3 *
4 * Copyright (C) 2024 Adam Wendelin <adwe live se>
5 *
6 * ACTF is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * ACTF is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 * Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with ACTF. If not, see
18 * <https://www.gnu.org/licenses/>.
19 */
20
37#ifndef ACTF_METADATA_H
38#define ACTF_METADATA_H
39
40#include <stdbool.h>
41#include <stdint.h>
42#include <unistd.h>
43
44#include "fld.h"
45#include "fld_cls.h"
46#include "types.h"
47
66
69 ACTF_CLK_ORIGIN_TYPE_NONE,
70 ACTF_CLK_ORIGIN_TYPE_UNIX_EPOCH,
71 ACTF_CLK_ORIGIN_TYPE_CUSTOM,
72 ACTF_CLK_ORIGIN_N_TYPES,
73};
74
75/*****************************************************************************/
76/* Metadata */
77/*****************************************************************************/
78
85
93int actf_metadata_parse_file(actf_metadata *metadata, const char *path);
94
103
111int actf_metadata_parse(actf_metadata *metadata, const char *str);
112
122int actf_metadata_nparse(struct actf_metadata *metadata, const char *str, size_t len);
123
135
141
142/*****************************************************************************/
143/* Preamble */
144/*****************************************************************************/
145
152
158const struct actf_uuid *actf_preamble_uuid(const actf_preamble *preamble);
159
166
173
174/*****************************************************************************/
175/* Trace Class */
176/*****************************************************************************/
177
184
191
197const char *actf_trace_cls_name(const actf_trace_cls *tc);
198
204const char *actf_trace_cls_uid(const actf_trace_cls *tc);
205
212
219
226
233
234/*****************************************************************************/
235/* Field Class Alias */
236/*****************************************************************************/
237
244
252
258const char *actf_fld_cls_alias_name(const actf_fld_cls_alias *fc_alias);
259
266
273
280
281/*****************************************************************************/
282/* Clock Class */
283/*****************************************************************************/
284
291
299
305const char *actf_clk_cls_id(const actf_clk_cls *clkc);
306
312const char *actf_clk_cls_namespace(const actf_clk_cls *clkc);
313
319const char *actf_clk_cls_name(const actf_clk_cls *clkc);
320
326const char *actf_clk_cls_uid(const actf_clk_cls *clkc);
327
334
341
348
355
362
368uint64_t actf_clk_cls_accuracy(const struct actf_clk_cls *clkc);
369
376
382const char *actf_clk_cls_description(const actf_clk_cls *clkc);
383
390
397
409 const struct actf_clk_cls *clkc2);
410
424 const struct actf_clk_cls *clkc2);
425
433 uint64_t tstamp_cc);
434
441
448
455
462
469
476
477/*****************************************************************************/
478/* Data Stream Class */
479/*****************************************************************************/
480
487
496 actf_it *it);
497
504
511
518
525
532
539
546
553
560
567
574
581
590 actf_it *it);
591
598
599/*****************************************************************************/
600/* Event Record Class */
601/*****************************************************************************/
602
609
616
623
630
636const char *actf_event_cls_name(const actf_event_cls *evc);
637
643const char *actf_event_cls_uid(const actf_event_cls *evc);
644
651
658
665
672
673#endif /* ACTF_METADATA_H */
Field related methods.
Field class related methods.
const actf_clk_cls * actf_dstream_cls_clk_cls(const actf_dstream_cls *dsc)
Get the data stream class clock class.
const actf_fld * actf_dstream_cls_attributes(const actf_dstream_cls *dsc)
Get the data stream class attributes.
const actf_fld * actf_clk_cls_attributes(const actf_clk_cls *clkc)
Get the clock class attributes.
struct actf_clk_offset actf_clk_offset
A clock class offset.
Definition metadata.h:59
const actf_fld_cls * actf_dstream_cls_event_hdr(const actf_dstream_cls *dsc)
Get the data stream class event header.
int actf_metadata_parse_fd(actf_metadata *metadata, int fd)
Parse the metadata from a file descriptor.
int actf_metadata_parse_file(actf_metadata *metadata, const char *path)
Parse the metadata of a file.
const char * actf_event_cls_uid(const actf_event_cls *evc)
Get the event class uid.
const actf_fld * actf_preamble_attributes(const actf_preamble *preamble)
Get the attributes of a preamble.
bool actf_clk_cls_eq_identities_strict(const struct actf_clk_cls *clkc1, const struct actf_clk_cls *clkc2)
Check whether two clock classes have the same identity in a stricter fashion than actf_clk_cls_eq_ide...
struct actf_metadata actf_metadata
A CTF2 metadata.
Definition metadata.h:49
const char * actf_event_cls_name(const actf_event_cls *evc)
Get the event class name.
const char * actf_trace_cls_uid(const actf_trace_cls *tc)
Get the uid of a trace class.
void actf_metadata_free(actf_metadata *metadata)
Free a metadata.
const actf_clk_cls * actf_metadata_clk_clses_idx(const actf_metadata *metadata, size_t i)
Get the ith clock class of the metadata.
bool actf_clk_cls_eq_identities(const struct actf_clk_cls *clkc1, const struct actf_clk_cls *clkc2)
Check whether two clock classes have the same identity.
struct actf_clk_origin actf_clk_origin
A clock class origin.
Definition metadata.h:57
struct actf_preamble actf_preamble
A preamble.
Definition metadata.h:51
const char * actf_event_cls_namespace(const actf_event_cls *evc)
Get the event class namespace.
struct actf_trace_cls actf_trace_cls
A trace class.
Definition metadata.h:53
uint64_t actf_dstream_cls_id(const actf_dstream_cls *dsc)
Get the data stream class id.
struct actf_event_cls actf_event_cls
An event class.
Definition metadata.h:65
bool actf_clk_cls_has_precision(const actf_clk_cls *clkc)
Check whether the clock class has a precision.
const char * actf_dstream_cls_uid(const actf_dstream_cls *dsc)
Get the data stream class uid.
const char * actf_clk_cls_name(const actf_clk_cls *clkc)
Get the clock class name.
const actf_fld * actf_dstream_cls_extensions(const actf_dstream_cls *dsc)
Get the data stream class extensions.
const actf_fld * actf_preamble_extensions(const actf_preamble *preamble)
Get the extensions of a preamble.
const actf_metadata * actf_dstream_cls_metadata(const actf_dstream_cls *dsc)
Get the metadata of the data stream class.
size_t actf_metadata_fld_cls_aliases_len(const actf_metadata *metadata)
Get the number of field class aliases of the metadata.
const actf_fld_cls * actf_dstream_cls_event_common_ctx(const actf_dstream_cls *dsc)
Get the data stream class event common context.
const actf_fld_cls * actf_trace_cls_pkt_hdr(const actf_trace_cls *tc)
Get the packet header field class of a trace class.
const actf_dstream_cls * actf_event_cls_dstream_cls(const actf_event_cls *evc)
Get the event class data stream class.
const char * actf_metadata_last_error(actf_metadata *metadata)
Get the last error message of the metadata A metadata method returning an error can store an error me...
const char * actf_clk_cls_uid(const actf_clk_cls *clkc)
Get the clock class uid.
uint64_t actf_event_cls_id(const actf_event_cls *evc)
Get the event class id.
const char * actf_dstream_cls_clk_cls_id(const actf_dstream_cls *dsc)
Get the data stream class clock class id.
const actf_fld_cls * actf_event_cls_payload(const actf_event_cls *evc)
Get the event class payload.
const actf_dstream_cls * actf_metadata_dstream_clses_next(const actf_metadata *metadata, actf_it *it)
Iterate over the data stream classes.
const char * actf_dstream_cls_name(const actf_dstream_cls *dsc)
Get the data stream class name.
const actf_fld * actf_trace_cls_environment(const actf_trace_cls *tc)
Get the environment of a trace class.
const actf_fld * actf_event_cls_extensions(const actf_event_cls *evc)
Get the event class extensions.
const actf_fld * actf_fld_cls_alias_attributes(const actf_fld_cls_alias *fc_alias)
Get the field class alias attributes.
const char * actf_trace_cls_name(const actf_trace_cls *tc)
Get the name of a trace class.
uint64_t actf_clk_cls_precision(const actf_clk_cls *clkc)
Get the clock class precision.
const actf_fld_cls * actf_event_cls_spec_ctx(const actf_event_cls *evc)
Get the event class specific context.
const char * actf_dstream_cls_namespace(const actf_dstream_cls *dsc)
Get the data stream class namespace.
const actf_clk_offset * actf_clk_cls_offset(const actf_clk_cls *clkc)
Get the clock class offset.
const struct actf_uuid * actf_preamble_uuid(const actf_preamble *preamble)
Get the UUID of a preamble.
size_t actf_metadata_dstream_clses_len(const actf_metadata *metadata)
Get the number of data stream classes of the metadata.
const actf_fld_cls * actf_dstream_cls_pkt_ctx(const actf_dstream_cls *dsc)
Get the data stream class packet context.
int actf_metadata_parse(actf_metadata *metadata, const char *str)
Parse the metadata from a string.
uint64_t actf_event_cls_dstream_cls_id(const actf_event_cls *evc)
Get the event class data stream class id.
actf_clk_origin_type
Clock origin types.
Definition metadata.h:68
const char * actf_clk_cls_namespace(const actf_clk_cls *clkc)
Get the clock class namespace.
const char * actf_trace_cls_namespace(const actf_trace_cls *tc)
Get the namespace of a trace class.
int64_t actf_clk_cls_cc_to_ns_from_origin(const struct actf_clk_cls *clkc, uint64_t tstamp_cc)
Convert a timestamp in cycles to nanoseconds from origin.
const char * actf_clk_origin_custom_uid(const actf_clk_origin *origin)
Get the clock origin custom uid.
const actf_fld_cls * actf_fld_cls_alias_fld_cls(const actf_fld_cls_alias *fc_alias)
Get the aliased field class of a field class alias.
size_t actf_dstream_cls_event_clses_len(const actf_dstream_cls *dsc)
Get the number of event classes of the data stream class.
const char * actf_fld_cls_alias_name(const actf_fld_cls_alias *fc_alias)
Get the field class alias name.
bool actf_clk_cls_has_accuracy(const struct actf_clk_cls *clkc)
Check whether the clock class has an accuracy.
const actf_fld * actf_trace_cls_attributes(const actf_trace_cls *tc)
Get the attributes of a trace class.
const actf_fld * actf_clk_cls_extensions(const actf_clk_cls *clkc)
Get the clock class extensions.
int actf_metadata_nparse(struct actf_metadata *metadata, const char *str, size_t len)
Parse the metadata from a string with explicit length.
const actf_trace_cls * actf_metadata_trace_cls(const actf_metadata *metadata)
Get the trace class of a metadata.
uint64_t actf_clk_cls_frequency(const actf_clk_cls *clkc)
Get the clock class frequency.
struct actf_dstream_cls actf_dstream_cls
A data stream class.
Definition metadata.h:63
actf_metadata * actf_metadata_init(void)
Initialize a metadata.
struct actf_clk_cls actf_clk_cls
A clock class.
Definition metadata.h:55
const actf_preamble * actf_metadata_preamble(const actf_metadata *metadata)
Get the preamble of a metadata.
size_t actf_metadata_clk_clses_len(const actf_metadata *metadata)
Get the number of clock classes of the metadata.
const actf_fld_cls_alias * actf_metadata_fld_cls_aliases_idx(const actf_metadata *metadata, size_t i)
Get the ith field class alias of the metadata.
const char * actf_clk_cls_description(const actf_clk_cls *clkc)
Get the clock class description.
const char * actf_clk_origin_custom_name(const actf_clk_origin *origin)
Get the clock origin custom name.
const char * actf_clk_cls_id(const actf_clk_cls *clkc)
Get the clock class id.
const char * actf_clk_origin_custom_namespace(const actf_clk_origin *origin)
Get the clock origin custom namespace.
struct actf_fld_cls_alias actf_fld_cls_alias
A field class alias.
Definition metadata.h:61
const actf_clk_origin * actf_clk_cls_origin(const actf_clk_cls *clkc)
Get the clock class origin.
const actf_fld * actf_event_cls_attributes(const actf_event_cls *evc)
Get the event class attributes.
const actf_event_cls * actf_dstream_cls_event_clses_next(const actf_dstream_cls *dsc, actf_it *it)
Iterate over the event classes.
uint64_t actf_clk_cls_accuracy(const struct actf_clk_cls *clkc)
Get the clock class accuracy.
const actf_fld * actf_fld_cls_alias_extensions(const actf_fld_cls_alias *fc_alias)
Get the field class alias extensions.
uint64_t actf_clk_offset_cycles(const actf_clk_offset *offset)
Get the cycles component of the clock offset.
const actf_fld * actf_trace_cls_extensions(const actf_trace_cls *tc)
Get the extensions of a trace class.
int64_t actf_clk_offset_seconds(const actf_clk_offset *offset)
Get the seconds component of the clock offset.
An iterator.
Definition types.h:136
A UUID.
Definition types.h:129
Basic types used by ACTF.
struct actf_fld actf_fld
A field.
Definition types.h:91
struct actf_fld_cls actf_fld_cls
A field class.
Definition types.h:93