summaryrefslogtreecommitdiff
path: root/include/gnuradio/io_signature.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/gnuradio/io_signature.hpp')
-rw-r--r--include/gnuradio/io_signature.hpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/include/gnuradio/io_signature.hpp b/include/gnuradio/io_signature.hpp
index 5473721..6cab2d6 100644
--- a/include/gnuradio/io_signature.hpp
+++ b/include/gnuradio/io_signature.hpp
@@ -18,30 +18,52 @@
#define INCLUDED_GNURADIO_IO_SIGNATURE_HPP
#include <vector>
+#include <stdexcept>
namespace gnuradio
{
+/*!
+ * An IO signature describes the input or output specifications
+ * for the streaming input or output ports of a block.
+ * Properties are a maximum and minimum number of ports,
+ * and an item size in bytes for each port.
+ */
struct IOSignature : std::vector<int>
{
static const int IO_INFINITE = -1;
+ //! Create an empty signature with infinite IO
IOSignature(void)
{
- this->set_min_streams(0);
- this->set_max_streams(0);
+ this->set_min_streams(IO_INFINITE);
+ this->set_max_streams(IO_INFINITE);
}
+ //! Create a signature with the specified min and max streams
+ IOSignature(const int min_streams, const int max_streams)
+ {
+ if (min_streams > max_streams and max_streams != IO_INFINITE)
+ {
+ throw std::invalid_argument("io signature fail: min_streams > max_streams");
+ }
+ this->set_min_streams(min_streams);
+ this->set_max_streams(max_streams);
+ }
+
+ //! Construct from pointer for backwards compatible shared_ptr usage.
IOSignature(const IOSignature *sig)
{
*this = *sig;
}
+ //! Overloaded arrow operator for backwards compatible shared_ptr usage.
IOSignature* operator->(void)
{
return this;
};
+ //! Overloaded arrow operator for backwards compatible shared_ptr usage.
const IOSignature* operator->(void) const
{
return this;
@@ -69,11 +91,11 @@ struct IOSignature : std::vector<int>
int sizeof_stream_item(const int index) const
{
- if (int(this->size()) >= index)
+ if (this->size() > unsigned(index))
{
- return this->at(0);
+ return this->at(index);
}
- return this->at(index);
+ return this->back();
}
std::vector<int> sizeof_stream_items(void) const