GNU Radio C++ API Reference g90d26cb
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
tags.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2011,2013 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11#ifndef INCLUDED_GR_TAGS_H
12#define INCLUDED_GR_TAGS_H
13
14#include <gnuradio/api.h>
15#include <pmt/pmt.h>
16
17/* ensure that tweakme.h is included before the bundled spdlog/fmt header, see
18 * https://github.com/gabime/spdlog/issues/2922 */
19#include <spdlog/tweakme.h>
20
21#include <gnuradio/api.h>
22#include <pmt/pmt.h>
23#include <spdlog/fmt/fmt.h>
24#include <string_view>
25
26namespace gr {
27
29 //! the item \p tag occurred at (as a uint64_t)
30 uint64_t offset = 0;
31
32 //! the key of \p tag (as a PMT symbol)
33 pmt::pmt_t key = pmt::PMT_NIL;
34
35 //! the value of \p tag (as a PMT)
36 pmt::pmt_t value = pmt::PMT_NIL;
37
38 //! the source ID of \p tag (as a PMT)
39 pmt::pmt_t srcid = pmt::PMT_F;
40
41 //! Comparison function to test which tag, \p x or \p y, came first in time
42 friend inline bool operator<(const tag_t& x, const tag_t& y)
43 {
44 return x.offset < y.offset;
45 }
46 //! Comparison function to test which tag, \p x or \p y, came first in time
47 static inline bool offset_compare(const tag_t& x, const tag_t& y) { return x < y; }
48
49 //! equality comparison. Compares all details, except marked_delete
50 inline bool operator==(const tag_t& t) const
51 {
52 return (t.key == key) && (t.value == value) && (t.srcid == srcid) &&
53 (t.offset == offset);
54 }
55};
56
57} /* namespace gr */
58
59//!\brief enables gr::tag to be formatted with fmt
60template <>
61struct GR_RUNTIME_API fmt::formatter<gr::tag_t> : formatter<std::string_view> {
62 fmt::format_context::iterator format(const gr::tag_t& tag, format_context& ctx) const;
63};
64#endif /*INCLUDED_GR_TAGS_H*/
#define GR_RUNTIME_API
Definition gnuradio-runtime/include/gnuradio/api.h:18
GNU Radio logging wrapper.
Definition basic_block.h:29
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition pmt.h:85
fmt::format_context::iterator format(const gr::tag_t &tag, format_context &ctx) const
Definition tags.h:28
static bool offset_compare(const tag_t &x, const tag_t &y)
Comparison function to test which tag, x or y, came first in time.
Definition tags.h:47
friend bool operator<(const tag_t &x, const tag_t &y)
Comparison function to test which tag, x or y, came first in time.
Definition tags.h:42
uint64_t offset
the item tag occurred at (as a uint64_t)
Definition tags.h:30
pmt::pmt_t srcid
the source ID of tag (as a PMT)
Definition tags.h:39
bool operator==(const tag_t &t) const
equality comparison. Compares all details, except marked_delete
Definition tags.h:50
pmt::pmt_t value
the value of tag (as a PMT)
Definition tags.h:36
pmt::pmt_t key
the key of tag (as a PMT symbol)
Definition tags.h:33