summaryrefslogtreecommitdiff
path: root/include/gras
diff options
context:
space:
mode:
authorJosh Blum2012-11-17 20:22:13 -0800
committerJosh Blum2012-11-17 20:22:13 -0800
commiteba4d4bbec74e4daf3927e75950ea50efa99739a (patch)
tree674ac466351ab42b0da6471d6e49d5e02ee05a9d /include/gras
parenteecfc6800e08bf3eec1c8fd93e8b07baf06230b3 (diff)
downloadsandhi-eba4d4bbec74e4daf3927e75950ea50efa99739a.tar.gz
sandhi-eba4d4bbec74e4daf3927e75950ea50efa99739a.tar.bz2
sandhi-eba4d4bbec74e4daf3927e75950ea50efa99739a.zip
created some metadata for work buffer array
Diffstat (limited to 'include/gras')
-rw-r--r--include/gras/CMakeLists.txt1
-rw-r--r--include/gras/block.hpp4
-rw-r--r--include/gras/work_buffer.hpp46
-rw-r--r--include/gras/work_buffer.ipp65
4 files changed, 89 insertions, 27 deletions
diff --git a/include/gras/CMakeLists.txt b/include/gras/CMakeLists.txt
index a27ad37..0856942 100644
--- a/include/gras/CMakeLists.txt
+++ b/include/gras/CMakeLists.txt
@@ -18,6 +18,7 @@ install(FILES
thread_pool.hpp
top_block.hpp
work_buffer.hpp
+ work_buffer.ipp
DESTINATION include/gras
COMPONENT ${GRAS_COMP_DEVEL}
diff --git a/include/gras/block.hpp b/include/gras/block.hpp
index 65649b2..5ce207b 100644
--- a/include/gras/block.hpp
+++ b/include/gras/block.hpp
@@ -178,8 +178,8 @@ struct GRAS_API Block : Element
//! Called when the flow graph is stopped, can overload
virtual bool stop(void);
- typedef std::vector<WorkBuffer<const void *> > InputItems;
- typedef std::vector<WorkBuffer<void *> > OutputItems;
+ typedef WorkBufferArray<const void *> InputItems;
+ typedef WorkBufferArray<void *> OutputItems;
//! The official call into the work routine (overload please)
virtual void work(
diff --git a/include/gras/work_buffer.hpp b/include/gras/work_buffer.hpp
index 6695982..ba9972b 100644
--- a/include/gras/work_buffer.hpp
+++ b/include/gras/work_buffer.hpp
@@ -5,13 +5,15 @@
#include <gras/gras.hpp>
#include <cstdlib>
+#include <vector>
namespace gras
{
template <typename PtrType>
-struct WorkBuffer
+class WorkBuffer
{
+public:
//! get a pointer of the desired type to this buffer
template <typename T> T cast(void) const;
@@ -27,40 +29,34 @@ struct WorkBuffer
//! Get the buffer length reference
size_t &size(void);
+private:
PtrType _mem;
size_t _len;
};
-template <typename PtrType> template <typename T>
-inline T WorkBuffer<PtrType>::cast(void) const
-{
- return reinterpret_cast<T>(_mem);
-}
-
template <typename PtrType>
-inline PtrType WorkBuffer<PtrType>::get(void) const
+class WorkBufferArray : public std::vector<WorkBuffer<PtrType> >
{
- return _mem;
-}
+public:
+ //! Get the std::min all item sizes
+ size_t min_items(void) const;
-template <typename PtrType>
-inline PtrType &WorkBuffer<PtrType>::get(void)
-{
- return _mem;
-}
+ //! Get a reference to the min items
+ size_t &min_items(void);
-template <typename PtrType>
-inline size_t WorkBuffer<PtrType>::size(void) const
-{
- return _len;
-}
+ //! Get the std::max of all item sizes
+ size_t max_items(void) const;
-template <typename PtrType>
-inline size_t &WorkBuffer<PtrType>::size(void)
-{
- return _len;
-}
+ //! Get a reference to the max items
+ size_t &max_items(void);
+
+private:
+ size_t _min_items;
+ size_t _max_items;
+};
} //namespace gras
+#include <gras/work_buffer.ipp>
+
#endif /*INCLUDED_GRAS_WORK_BUFFER_HPP*/
diff --git a/include/gras/work_buffer.ipp b/include/gras/work_buffer.ipp
new file mode 100644
index 0000000..c6ca10e
--- /dev/null
+++ b/include/gras/work_buffer.ipp
@@ -0,0 +1,65 @@
+// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
+
+#ifndef INCLUDED_GRAS_WORK_BUFFER_IPP
+#define INCLUDED_GRAS_WORK_BUFFER_IPP
+
+namespace gras
+{
+
+template <typename PtrType> template <typename T>
+inline T WorkBuffer<PtrType>::cast(void) const
+{
+ return reinterpret_cast<T>(_mem);
+}
+
+template <typename PtrType>
+inline PtrType WorkBuffer<PtrType>::get(void) const
+{
+ return _mem;
+}
+
+template <typename PtrType>
+inline PtrType &WorkBuffer<PtrType>::get(void)
+{
+ return _mem;
+}
+
+template <typename PtrType>
+inline size_t WorkBuffer<PtrType>::size(void) const
+{
+ return _len;
+}
+
+template <typename PtrType>
+inline size_t &WorkBuffer<PtrType>::size(void)
+{
+ return _len;
+}
+
+template <typename PtrType>
+inline size_t WorkBufferArray<PtrType>::min_items(void) const
+{
+ return _min_items;
+}
+
+template <typename PtrType>
+inline size_t &WorkBufferArray<PtrType>::min_items(void)
+{
+ return _min_items;
+}
+
+template <typename PtrType>
+inline size_t WorkBufferArray<PtrType>::max_items(void) const
+{
+ return _max_items;
+}
+
+template <typename PtrType>
+inline size_t &WorkBufferArray<PtrType>::max_items(void)
+{
+ return _max_items;
+}
+
+} //namespace gras
+
+#endif /*INCLUDED_GRAS_WORK_BUFFER_IPP*/