Pothos  0.7.0-gf7fbae99
The Pothos dataflow programming software suite
BufferManager.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
15 #include <memory> //shared_ptr
16 #include <string>
17 #include <functional>
18 
19 namespace Pothos {
20 
25 {
26  BufferManagerArgs(void);
27 
35  size_t numBuffers;
36 
41  size_t bufferSize;
42 
49 };
50 
57 {
58 public:
59 
60  typedef std::shared_ptr<BufferManager> Sptr;
61 
63  virtual ~BufferManager(void);
64 
74  static Sptr make(const std::string &name);
75 
85  static Sptr make(const std::string &name, const BufferManagerArgs &args);
86 
90  virtual void init(const BufferManagerArgs &args);
91 
96  virtual bool empty(void) const = 0;
97 
105  const BufferChunk &front(void) const;
106 
120  virtual void pop(const size_t numBytes) = 0;
121 
129  virtual void push(const ManagedBuffer &buff) = 0;
130 
136  void pushExternal(const ManagedBuffer &buff);
137 
141  void setCallback(const std::function<void(const ManagedBuffer &)> &callback);
142 
144  bool isInitialized(void) const;
145 
146 protected:
148  BufferManager(void);
149 
151  void setFrontBuffer(const BufferChunk &buff);
152 
153 private:
154  bool _initialized;
155  BufferChunk _frontBuffer;
156  std::function<void(const ManagedBuffer &)> _callback;
157 };
158 
159 } //namespace Pothos
160 
162 {
163  return _frontBuffer;
164 }
165 
167 {
168  _frontBuffer = buff;
169 }
170 
172 {
173  if (_callback) _callback(buff);
174  else this->push(buff);
175 }
176 
178 {
179  return _initialized;
180 }
size_t numBuffers
Definition: BufferManager.hpp:35
#define POTHOS_API
Definition: Config.hpp:41
void pushExternal(const ManagedBuffer &buff)
Definition: BufferManager.hpp:171
long nodeAffinity
Definition: BufferManager.hpp:48
Definition: ArchiveEntry.hpp:20
Definition: BufferManager.hpp:56
Definition: ManagedBuffer.hpp:31
void setFrontBuffer(const BufferChunk &buff)
Called by derived classes to set the buffer for front()
Definition: BufferManager.hpp:166
bool isInitialized(void) const
Has this buffer manager been initialized?
Definition: BufferManager.hpp:177
Definition: BufferManager.hpp:24
std::shared_ptr< BufferManager > Sptr
Definition: BufferManager.hpp:60
POTHOS_API void init(void)
size_t bufferSize
Definition: BufferManager.hpp:41
Definition: BufferChunk.hpp:30
const BufferChunk & front(void) const
Definition: BufferManager.hpp:161