summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/include/gnuradio/block.h
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/include/gnuradio/block.h')
-rw-r--r--gnuradio-runtime/include/gnuradio/block.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/gnuradio-runtime/include/gnuradio/block.h b/gnuradio-runtime/include/gnuradio/block.h
index 0e25509d00..ee90a35d2c 100644
--- a/gnuradio-runtime/include/gnuradio/block.h
+++ b/gnuradio-runtime/include/gnuradio/block.h
@@ -11,8 +11,11 @@
#ifndef INCLUDED_GR_RUNTIME_BLOCK_H
#define INCLUDED_GR_RUNTIME_BLOCK_H
+#include <memory>
+
#include <gnuradio/api.h>
#include <gnuradio/basic_block.h>
+#include <gnuradio/buffer_type.h>
#include <gnuradio/config.h>
#include <gnuradio/logger.h>
#include <gnuradio/tags.h>
@@ -514,6 +517,78 @@ public:
*/
void set_min_output_buffer(int port, long min_output_buffer);
+ /*!
+ * \brief Allocate the block_detail and necessary output buffers for this
+ * block.
+ */
+ void allocate_detail(int ninputs,
+ int noutputs,
+ const std::vector<int>& downstream_max_nitems_vec,
+ const std::vector<uint64_t>& downstream_lcm_nitems_vec);
+
+ // --------------- Custom buffer-related functions -------------
+
+ /*!
+ * \brief Replace the block's buffer with a new one owned by the block_owner
+ * parameter
+ *
+ * \details
+ * This function is used to replace the buffer on the specified output port
+ * of the block with a new buffer that is "owned" by the specified block. This
+ * function will only be called if a downstream block is using a custom buffer
+ * that is incompatible with the default buffer type created by this block.
+ *
+ */
+ buffer_sptr replace_buffer(uint32_t out_port, block_sptr block_owner);
+
+ /*!
+ * \brief Return the type of custom buffer used by the block
+ *
+ * \details
+ * Blocks that wish to allocate custom buffers should override this function.
+ */
+ virtual buffer_type_t get_buffer_type()
+ {
+#if DEBUG_SINGLE_MAPPED
+ return buftype_CUSTOM_HOST::get();
+#else
+ return buftype_DEFAULT_NON_CUSTOM::get();
+#endif
+ }
+
+ /*!
+ * \brief Allocate a custom buffer for the block
+ *
+ * \details
+ * Blocks that wish to allocate custom buffers should override this function.
+ *
+ * \param size the size of the buffer to allocate in bytes
+ */
+ virtual char* allocate_custom_buffer(size_t size)
+ {
+#if DEBUG_SINGLE_MAPPED
+ return new char[size]();
+#else
+ return nullptr;
+#endif
+ }
+
+ /*!
+ * \brief Free a custom buffer previously allocated by allocate_custom_buffer()
+ *
+ * \details
+ * Blocks that wish to allocate custom buffers should override this function.
+ *
+ * \param buffer a pointer to the buffer
+ */
+ virtual void free_custom_buffer(char* buffer)
+ {
+#if DEBUG_SINGLE_MAPPED
+ delete[] buffer;
+#endif
+ }
+
+
// --------------- Performance counter functions -------------
/*!
@@ -909,6 +984,14 @@ protected:
void enable_update_rate(bool en);
+ /*!
+ * \brief Allocate a buffer for the given output port of this block. Note
+ * that the downstream max number of items must be passed in to this
+ * function for consideration.
+ */
+ buffer_sptr
+ allocate_buffer(int port, int downstream_max_nitems, uint64_t downstream_lcm_nitems);
+
std::vector<long> d_max_output_buffer;
std::vector<long> d_min_output_buffer;