summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2021-06-12 01:01:04 +0200
committermormj <34754695+mormj@users.noreply.github.com>2021-06-28 14:59:46 -0400
commitae586c92d7ccb945fb994c29571c257d02e5f6ee (patch)
tree6b44be32aa6faea1f4f4c51dbd70d5971872120c
parent84ba8636f4449e2d74d9bceaebba7c4afa756d60 (diff)
runtime: tags can be compared with < instead of offset_compare
Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
-rw-r--r--gnuradio-runtime/include/gnuradio/tags.h11
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/bindings/tags_python.cc6
2 files changed, 11 insertions, 6 deletions
diff --git a/gnuradio-runtime/include/gnuradio/tags.h b/gnuradio-runtime/include/gnuradio/tags.h
index 7e779173ea..51c662ab2f 100644
--- a/gnuradio-runtime/include/gnuradio/tags.h
+++ b/gnuradio-runtime/include/gnuradio/tags.h
@@ -33,15 +33,15 @@ struct GR_RUNTIME_API tag_t {
//! ignore this.
std::vector<long> marked_deleted;
- /*!
- * Comparison function to test which tag, \p x or \p y, came
- * first in time
- */
- static inline bool offset_compare(const tag_t& x, const tag_t& y)
+ //! Comparison function to test which tag, \p x or \p y, came first in time
+ friend inline bool operator<(const tag_t& x, const tag_t& y)
{
return x.offset < y.offset;
}
+ //! Comparison function to test which tag, \p x or \p y, came first in time
+ static inline bool offset_compare(const tag_t& x, const tag_t& y) { return x < y; }
+ //! equality comparison. Compares all details, except marked_delete
inline bool operator==(const tag_t& t) const
{
return (t.key == key) && (t.value == value) && (t.srcid == srcid) &&
@@ -56,6 +56,7 @@ struct GR_RUNTIME_API tag_t {
{
}
+ //! Copy constructor; constructs identical tag, but doesn't copy marked_delete
tag_t(const tag_t& rhs)
: offset(rhs.offset), key(rhs.key), value(rhs.value), srcid(rhs.srcid)
{
diff --git a/gnuradio-runtime/python/gnuradio/gr/bindings/tags_python.cc b/gnuradio-runtime/python/gnuradio/gr/bindings/tags_python.cc
index 2487be0100..aaa97b3879 100644
--- a/gnuradio-runtime/python/gnuradio/gr/bindings/tags_python.cc
+++ b/gnuradio-runtime/python/gnuradio/gr/bindings/tags_python.cc
@@ -1,5 +1,6 @@
/*
* Copyright 2020 Free Software Foundation, Inc.
+ * Copyright 2021 Marcus Müller
*
* This file is part of GNU Radio
*
@@ -14,10 +15,11 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(tags.h) */
-/* BINDTOOL_HEADER_FILE_HASH(73eb73e445943e224cdbae24b0b0ab76) */
+/* BINDTOOL_HEADER_FILE_HASH(25435955fa46de2924e0b648c4f8dd43) */
/***********************************************************************************/
#include <pybind11/complex.h>
+#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
@@ -44,6 +46,8 @@ void bind_tags(py::module& m)
py::arg("y"),
D(tag_t, offset_compare))
+ .def(py::self < py::self, D(tag_t, offset_compare))
+
.def_readwrite("offset", &tag_t::offset)
.def_readwrite("key", &tag_t::key)
.def_readwrite("value", &tag_t::value)