GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
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 namespace gr {
18 
20  //! the item \p tag occurred at (as a uint64_t)
21  uint64_t offset;
22 
23  //! the key of \p tag (as a PMT symbol)
25 
26  //! the value of \p tag (as a PMT)
28 
29  //! the source ID of \p tag (as a PMT)
31 
32  //! Used by gr_buffer to mark a tagged as deleted by a specific block. You can usually
33  //! ignore this.
34  std::vector<long> marked_deleted;
35 
36  //! Comparison function to test which tag, \p x or \p y, came first in time
37  friend inline bool operator<(const tag_t& x, const tag_t& y)
38  {
39  return x.offset < y.offset;
40  }
41  //! Comparison function to test which tag, \p x or \p y, came first in time
42  static inline bool offset_compare(const tag_t& x, const tag_t& y) { return x < y; }
43 
44  //! equality comparison. Compares all details, except marked_delete
45  inline bool operator==(const tag_t& t) const
46  {
47  return (t.key == key) && (t.value == value) && (t.srcid == srcid) &&
48  (t.offset == offset);
49  }
50 
52  : offset(0),
53  key(pmt::PMT_NIL),
54  value(pmt::PMT_NIL),
55  srcid(pmt::PMT_F) // consistent with default srcid value in block::add_item_tag
56  {
57  }
58 
59  //! Copy constructor; constructs identical tag, but doesn't copy marked_delete
60  tag_t(const tag_t& rhs)
61  : offset(rhs.offset), key(rhs.key), value(rhs.value), srcid(rhs.srcid)
62  {
63  }
64  tag_t& operator=(const tag_t& rhs)
65  {
66  if (this != &rhs) {
67  offset = rhs.offset;
68  key = rhs.key;
69  value = rhs.value;
70  srcid = rhs.srcid;
71  }
72  return (*this);
73  }
74 
75  ~tag_t() {}
76 };
77 
78 } /* namespace gr */
79 
80 #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
Definition: pmt.h:38
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition: pmt.h:83
#define PMT_F
Definition: pmt.h:123
#define PMT_NIL
Definition: pmt.h:121
Definition: tags.h:19
std::vector< long > marked_deleted
Used by gr_buffer to mark a tagged as deleted by a specific block. You can usually ignore this.
Definition: tags.h:34
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:42
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:37
tag_t()
Definition: tags.h:51
~tag_t()
Definition: tags.h:75
uint64_t offset
the item tag occurred at (as a uint64_t)
Definition: tags.h:21
tag_t(const tag_t &rhs)
Copy constructor; constructs identical tag, but doesn't copy marked_delete.
Definition: tags.h:60
pmt::pmt_t srcid
the source ID of tag (as a PMT)
Definition: tags.h:30
bool operator==(const tag_t &t) const
equality comparison. Compares all details, except marked_delete
Definition: tags.h:45
pmt::pmt_t value
the value of tag (as a PMT)
Definition: tags.h:27
pmt::pmt_t key
the key of tag (as a PMT symbol)
Definition: tags.h:24
tag_t & operator=(const tag_t &rhs)
Definition: tags.h:64