diff options
m--------- | Theron | 0 | ||||
m--------- | gnuradio | 0 | ||||
m--------- | grextras | 0 | ||||
-rw-r--r-- | include/gras/CMakeLists.txt | 2 | ||||
-rw-r--r-- | include/gras/block.hpp | 16 | ||||
-rw-r--r-- | include/gras/element.hpp | 9 | ||||
-rw-r--r-- | include/gras/element.i | 1 | ||||
-rw-r--r-- | include/gras/io_signature.hpp | 129 | ||||
-rw-r--r-- | include/gras/io_signature.i | 27 | ||||
-rw-r--r-- | lib/block.cpp | 22 | ||||
-rw-r--r-- | lib/element.cpp | 25 | ||||
-rw-r--r-- | lib/element_impl.hpp | 2 | ||||
-rw-r--r-- | lib/topology_handler.cpp | 19 | ||||
-rw-r--r-- | python/gras/CMakeLists.txt | 2 | ||||
-rw-r--r-- | python/gras/GRAS_Block.i | 5 | ||||
-rw-r--r-- | python/gras/GRAS_HierBlock.i | 19 | ||||
-rw-r--r-- | python/gras/GRAS_IOSignature.i | 3 |
17 files changed, 47 insertions, 234 deletions
diff --git a/Theron b/Theron -Subproject 5adee7218d2b574743cc874e2684181fd53ea69 +Subproject bca3174ae410767c283742cebbb996b745fc40e diff --git a/gnuradio b/gnuradio -Subproject 9ecb12014a646f67b428f9415a5f186c59537db +Subproject eb05abff6d3ba1f593e3f33fe2eb455d0824a7a diff --git a/grextras b/grextras -Subproject 9050a1b5766725fbead2bef4da6c290505a1143 +Subproject c721d3eeb3b678e1f657e25b8397857b3200c6a diff --git a/include/gras/CMakeLists.txt b/include/gras/CMakeLists.txt index f0b0d3a..15651c4 100644 --- a/include/gras/CMakeLists.txt +++ b/include/gras/CMakeLists.txt @@ -10,8 +10,6 @@ install(FILES gras.hpp hier_block.hpp hier_block.i - io_signature.hpp - io_signature.i sbuffer.hpp sbuffer.i tags.hpp diff --git a/include/gras/block.hpp b/include/gras/block.hpp index 8baecfd..f00a6f7 100644 --- a/include/gras/block.hpp +++ b/include/gras/block.hpp @@ -109,6 +109,22 @@ struct GRAS_API Block : Element Block(const std::string &name); /******************************************************************* + * Item sizes for ports + ******************************************************************/ + + //! Get the input item size for this port in bytes + size_t get_input_size(const size_t which_input) const; + + //! Set the input item size for this port in bytes + void set_input_size(const size_t which_input, const size_t bytes); + + //! Get the output item size for this port in bytes + size_t get_output_size(const size_t which_output) const; + + //! Set the output item size for this port in bytes + void set_output_size(const size_t which_output, const size_t bytes); + + /******************************************************************* * Deal with input and output port configuration ******************************************************************/ diff --git a/include/gras/element.hpp b/include/gras/element.hpp index 423053e..e6da881 100644 --- a/include/gras/element.hpp +++ b/include/gras/element.hpp @@ -4,7 +4,6 @@ #define INCLUDED_GRAS_ELEMENT_HPP #include <gras/gras.hpp> -#include <gras/io_signature.hpp> #include <boost/shared_ptr.hpp> #include <boost/enable_shared_from_this.hpp> @@ -33,14 +32,6 @@ struct GRAS_API Element : ElementBase, boost::enable_shared_from_this<Element> //! get a canonical name for this element std::string to_string(void) const; - void set_output_signature(const gras::IOSignature &sig); - - void set_input_signature(const gras::IOSignature &sig); - - const gras::IOSignature &input_signature(void) const; - - const gras::IOSignature &output_signature(void) const; - /******************************************************************* * Compatibility for dealing with shared ptrs of Elements ******************************************************************/ diff --git a/include/gras/element.i b/include/gras/element.i index f826ca8..1408eac 100644 --- a/include/gras/element.i +++ b/include/gras/element.i @@ -29,7 +29,6 @@ //////////////////////////////////////////////////////////////////////// %include <std_string.i> %include <gras/gras.hpp> -%import <gras/io_signature.i> %include <gras/element.hpp> //////////////////////////////////////////////////////////////////////// diff --git a/include/gras/io_signature.hpp b/include/gras/io_signature.hpp deleted file mode 100644 index 1d102e4..0000000 --- a/include/gras/io_signature.hpp +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. - -#ifndef INCLUDED_GRAS_IO_SIGNATURE_HPP -#define INCLUDED_GRAS_IO_SIGNATURE_HPP - -#include <gras/gras.hpp> -#include <vector> -#include <stdexcept> - -namespace gras -{ - -/*! - * 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<unsigned> -{ - static const int IO_INFINITE = ~0; - - //! Create an empty signature - IOSignature(void) - { - this->set_min_streams(IO_INFINITE); - this->set_max_streams(IO_INFINITE); - } - - //! Create a signature with a single item size - IOSignature(const unsigned size) - { - this->push_back(size); - 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); - } - - //! Create a signature from a vector of IO widths - IOSignature(const std::vector<unsigned> &sig) - { - this->assign(sig.begin(), sig.end()); - this->set_min_streams(IO_INFINITE); - this->set_max_streams(IO_INFINITE); - } - - //! Construct from pointer for backwards compatible shared_ptr usage. - explicit 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; - }; - - const unsigned &at(const unsigned index) const - { - if (this->empty()) - { - throw std::invalid_argument("io signature fail: indexing empty vector"); - } - if (this->size() > index) - { - return std::vector<unsigned>::at(index); - } - return this->back(); - } - - const unsigned &operator[](const unsigned index) const - { - return this->at(index); - } - - void set_min_streams(const int val) - { - _min_streams = val; - } - - void set_max_streams(const int val) - { - _max_streams = val; - } - - int min_streams(void) const - { - return _min_streams; - } - - int max_streams(void) const - { - return _max_streams; - } - - int sizeof_stream_item(const unsigned index) const - { - return this->at(index); - } - - const std::vector<unsigned> &sizeof_stream_items(void) const - { - return *this; - } - - int _min_streams; - int _max_streams; -}; - -} //namespace gras - -#endif /*INCLUDED_GRAS_IO_SIGNATURE_HPP*/ diff --git a/include/gras/io_signature.i b/include/gras/io_signature.i deleted file mode 100644 index be9a3fd..0000000 --- a/include/gras/io_signature.i +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. - -#ifndef INCLUDED_GRAS_IO_SIGNATURE_I -#define INCLUDED_GRAS_IO_SIGNATURE_I - -%{ -#include <gras/io_signature.hpp> -%} - -%ignore gras::IOSignature::operator->(); -%ignore gras::IOSignature::operator->() const; -%ignore gras::IOSignature::operator[]; //ignore warnings about %extend - -%include <std_vector.i> -%template (std_vector_gras_io_signature_unsigned) std::vector<unsigned>; - -%include <gras/io_signature.hpp> - -%extend gras::IOSignature -{ - const unsigned &__getitem__(const unsigned index) - { - return ($self)->at(index); - } -} - -#endif /*INCLUDED_GRAS_IO_SIGNATURE_I*/ diff --git a/lib/block.cpp b/lib/block.cpp index 128a9b8..330e1a6 100644 --- a/lib/block.cpp +++ b/lib/block.cpp @@ -38,6 +38,8 @@ Block::Block(const std::string &name): (*this)->block->block_state = BlockActor::BLOCK_STATE_INIT; //call block methods to init stuff + this->set_input_size(0, 1); + this->set_output_size(0, 1); this->set_input_config(0, InputPortConfig()); this->set_output_config(0, OutputPortConfig()); this->set_interruptible_work(false); @@ -80,6 +82,26 @@ typename V::value_type vector_get(const V &v, const size_t index) return v[index]; } +size_t Block::get_input_size(const size_t which_input) const +{ + return vector_get((*this)->block->input_items_sizes, which_input); +} + +void Block::set_input_size(const size_t which_input, const size_t bytes) +{ + vector_set((*this)->block->input_items_sizes, bytes, which_input); +} + +size_t Block::get_output_size(const size_t which_output) const +{ + return vector_get((*this)->block->output_items_sizes, which_output); +} + +void Block::set_output_size(const size_t which_output, const size_t bytes) +{ + vector_set((*this)->block->output_items_sizes, bytes, which_output); +} + InputPortConfig Block::get_input_config(const size_t which_input) const { return vector_get((*this)->block->input_configs, which_input); diff --git a/lib/element.cpp b/lib/element.cpp index a10e298..71e4e69 100644 --- a/lib/element.cpp +++ b/lib/element.cpp @@ -21,11 +21,6 @@ Element::Element(const std::string &name) (*this)->unique_id = ++unique_id_pool; if (GENESIS) std::cerr << "New element: " << to_string() << std::endl; - - //default io signature to something - IOSignature sig; sig.push_back(1); - this->set_input_signature(sig); - this->set_output_signature(sig); } ElementImpl::~ElementImpl(void) @@ -49,23 +44,3 @@ std::string Element::to_string(void) const { return str(boost::format("%s(%d)") % this->name() % this->unique_id()); } - -void Element::set_output_signature(const IOSignature &sig) -{ - (*this)->output_signature = sig; -} - -void Element::set_input_signature(const IOSignature &sig) -{ - (*this)->input_signature = sig; -} - -const IOSignature &Element::input_signature(void) const -{ - return (*this)->input_signature; -} - -const IOSignature &Element::output_signature(void) const -{ - return (*this)->output_signature; -} diff --git a/lib/element_impl.hpp b/lib/element_impl.hpp index 5c2d998..9e3c9b3 100644 --- a/lib/element_impl.hpp +++ b/lib/element_impl.hpp @@ -26,8 +26,6 @@ struct ElementImpl //common element properties std::string name; long unique_id; - IOSignature input_signature; - IOSignature output_signature; //top block stuff SharedThreadGroup thread_group; diff --git a/lib/topology_handler.cpp b/lib/topology_handler.cpp index f813b57..af4dead 100644 --- a/lib/topology_handler.cpp +++ b/lib/topology_handler.cpp @@ -4,19 +4,6 @@ using namespace gras; -template <typename V, typename Sig> -void fill_item_sizes_from_sig(V &v, const Sig &s, const size_t size) -{ - //default item size of 1 in case we cant set - v.resize(size, 1); - - //empty signature? maybe it was a message port - if (s.empty()) return; - - //fill v by copying signature (with back extend mode) - for (size_t i = 0; i < v.size(); i++) v[i] = s[i]; -} - template <typename V, typename T> void resize_fill_grow(V &v, const size_t new_len, const T &fill) { @@ -43,9 +30,9 @@ void BlockActor::handle_topology( //call notify_topology on block before committing settings this->block_ptr->notify_topology(num_inputs, num_outputs); - //fill the item sizes from the IO signatures - fill_item_sizes_from_sig(this->input_items_sizes, block_ptr->input_signature(), num_inputs); - fill_item_sizes_from_sig(this->output_items_sizes, block_ptr->output_signature(), num_outputs); + //fill the item sizes per port + resize_fill_back(this->input_items_sizes, num_inputs); + resize_fill_back(this->output_items_sizes, num_outputs); //resize and fill port properties resize_fill_back(this->input_configs, num_inputs); diff --git a/python/gras/CMakeLists.txt b/python/gras/CMakeLists.txt index ca38324..8171e7f 100644 --- a/python/gras/CMakeLists.txt +++ b/python/gras/CMakeLists.txt @@ -23,7 +23,6 @@ GR_SWIG_MAKE(GRAS_Block GRAS_Block.i) GR_SWIG_MAKE(GRAS_HierBlock GRAS_HierBlock.i) GR_SWIG_MAKE(GRAS_ThreadPool GRAS_ThreadPool.i) GR_SWIG_MAKE(GRAS_SBuffer GRAS_SBuffer.i) -GR_SWIG_MAKE(GRAS_IOSignature GRAS_IOSignature.i) GR_SWIG_INSTALL( TARGETS GRAS_Tags @@ -31,7 +30,6 @@ GR_SWIG_INSTALL( GRAS_HierBlock GRAS_ThreadPool GRAS_SBuffer - GRAS_IOSignature DESTINATION ${GR_PYTHON_DIR}/gras COMPONENT ${GRAS_COMP_PYTHON} ) diff --git a/python/gras/GRAS_Block.i b/python/gras/GRAS_Block.i index 1cf226e..9e7299c 100644 --- a/python/gras/GRAS_Block.i +++ b/python/gras/GRAS_Block.i @@ -186,7 +186,6 @@ struct BlockPython : Block import numpy import traceback from GRAS_Utils import pointer_to_ndarray -from GRAS_IOSignature import IOSignature from PMC import * def sig_to_dtype_sig(sig): @@ -205,11 +204,11 @@ class Block(BlockPython): def set_input_signature(self, sig): self.__in_sig = sig_to_dtype_sig(sig) - BlockPython.set_input_signature(self, IOSignature([s.itemsize for s in self.__in_sig])) + for i, n in enumerate(self.__in_sig): self.set_input_size(i, n.itemsize) def set_output_signature(self, sig): self.__out_sig = sig_to_dtype_sig(sig) - BlockPython.set_output_signature(self, IOSignature([s.itemsize for s in self.__out_sig])) + for i, n in enumerate(self.__out_sig): self.set_output_size(i, n.itemsize) def input_signature(self): return self.__in_sig def output_signature(self): return self.__out_sig diff --git a/python/gras/GRAS_HierBlock.i b/python/gras/GRAS_HierBlock.i index 9cd705e..f2a9b5a 100644 --- a/python/gras/GRAS_HierBlock.i +++ b/python/gras/GRAS_HierBlock.i @@ -104,17 +104,6 @@ struct HierBlockPython : HierBlock { //NOP } - - HierBlockPython( - const std::string &name, - const IOSignature &input_signature, - const IOSignature &output_signature - ): - HierBlock(name) - { - this->set_input_signature(input_signature); - this->set_output_signature(output_signature); - } }; } @@ -151,8 +140,8 @@ def internal_connect__(fcn, obj, *args): fcn(obj, src, src_index, sink, sink_index) class TopBlock(TopBlockPython): - def __init__(self, *args, **kwargs): - TopBlockPython.__init__(self, *args, **kwargs) + def __init__(self, name="Top", *args, **kwargs): + TopBlockPython.__init__(self, name) def connect(self, *args): return internal_connect__(TopBlockPython.connect, self, *args) @@ -161,8 +150,8 @@ class TopBlock(TopBlockPython): return internal_connect__(TopBlockPython.disconnect, self, *args) class HierBlock(HierBlockPython): - def __init__(self, *args, **kwargs): - HierBlockPython.__init__(self, *args, **kwargs) + def __init__(self, name="Hier", *args, **kwargs): + HierBlockPython.__init__(self, name) #backwards compatible silliness import weakref diff --git a/python/gras/GRAS_IOSignature.i b/python/gras/GRAS_IOSignature.i deleted file mode 100644 index 36f51dd..0000000 --- a/python/gras/GRAS_IOSignature.i +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. - -%include <gras/io_signature.i> |