rogue
Loading...
Searching...
No Matches
Slave.h
Go to the documentation of this file.
1
17#ifndef __ROGUE_INTERFACES_STREAM_SLAVE_H__
18#define __ROGUE_INTERFACES_STREAM_SLAVE_H__
19#include "rogue/Directives.h"
20
21#include <stdint.h>
22
23#include <memory>
24#include <string>
25#include <thread>
26
28#include "rogue/Logging.h"
30
31#ifndef NO_PYTHON
32 #include <boost/python.hpp>
33#endif
34
35namespace rogue {
36namespace interfaces {
37namespace stream {
38
39class Frame;
40class Buffer;
41class Master;
42
72 public rogue::EnableSharedFromThis<rogue::interfaces::stream::Slave> {
73 // Mutex
74 std::mutex mtx_;
75
76 // Debug control
77 uint32_t debug_;
78 std::shared_ptr<rogue::Logging> log_;
79
80 // Counters
81 uint64_t frameCount_;
82 uint64_t frameBytes_;
83
84 public:
96 static std::shared_ptr<rogue::interfaces::stream::Slave> create();
97
99 static void setup_python();
100
108 Slave();
109
111 virtual ~Slave();
112
122 virtual void stop();
123
137 void setDebug(uint32_t debug, std::string name);
138
156 virtual void acceptFrame(std::shared_ptr<rogue::interfaces::stream::Frame> frame);
157
169 uint64_t getFrameCount();
170
182 uint64_t getByteCount();
183
199 bool ensureSingleBuffer(std::shared_ptr<rogue::interfaces::stream::Frame>& frame, bool reqEn);
200
211 std::shared_ptr<rogue::interfaces::stream::Frame> reqLocalFrame(uint32_t size, bool zeroCopyEn);
212
213#ifndef NO_PYTHON
214
220 boost::python::object lshiftPy(boost::python::object p);
221
222#endif
223
229 std::shared_ptr<rogue::interfaces::stream::Master>& operator<<(
230 std::shared_ptr<rogue::interfaces::stream::Master>& other);
231};
232
234typedef std::shared_ptr<rogue::interfaces::stream::Slave> SlavePtr;
235
236#ifndef NO_PYTHON
237
246 public boost::python::wrapper<rogue::interfaces::stream::Slave> {
247 public:
256 void acceptFrame(std::shared_ptr<rogue::interfaces::stream::Frame> frame);
257
266 void defAcceptFrame(std::shared_ptr<rogue::interfaces::stream::Frame> frame);
267};
268
269typedef std::shared_ptr<rogue::interfaces::stream::SlaveWrap> SlaveWrapPtr;
270#endif
271
272} // namespace stream
273} // namespace interfaces
274} // namespace rogue
275#endif
Typed shared-from-this helper for Rogue classes.
Frame and buffer allocator for stream endpoints.
Definition Pool.h:71
Internal Boost.Python wrapper for rogue::interfaces::stream::Slave. Enables Python subclasses to over...
Definition Slave.h:246
void defAcceptFrame(std::shared_ptr< rogue::interfaces::stream::Frame > frame)
Calls the base-class acceptFrame() implementation.
Definition Slave.cpp:127
void acceptFrame(std::shared_ptr< rogue::interfaces::stream::Frame > frame)
Accepts a frame from an upstream master.
Definition Slave.cpp:110
Stream slave endpoint and default frame pool.
Definition Slave.h:72
void setDebug(uint32_t debug, std::string name)
Sets debug message verbosity and logger name.
Definition Slave.cpp:67
Slave()
Constructs a stream slave.
Definition Slave.cpp:55
uint64_t getFrameCount()
Returns frame counter.
Definition Slave.cpp:134
static std::shared_ptr< rogue::interfaces::stream::Slave > create()
Creates a new stream slave.
Definition Slave.cpp:49
virtual ~Slave()
Destroys the stream slave.
Definition Slave.cpp:62
static void setup_python()
Registers this type with Python bindings.
Definition Slave.cpp:177
uint64_t getByteCount()
Returns byte counter.
Definition Slave.cpp:139
boost::python::object lshiftPy(boost::python::object p)
Supports << operator usage from Python.
Definition Slave.cpp:201
std::shared_ptr< rogue::interfaces::stream::Frame > reqLocalFrame(uint32_t size, bool zeroCopyEn)
Services a local frame allocation request through this object's pool interface.
Definition Slave.cpp:173
std::shared_ptr< rogue::interfaces::stream::Master > & operator<<(std::shared_ptr< rogue::interfaces::stream::Master > &other)
Connects this slave to a master via stream chaining operator.
virtual void stop()
Shuts down threads associated with this object.
Definition Slave.cpp:64
bool ensureSingleBuffer(std::shared_ptr< rogue::interfaces::stream::Frame > &frame, bool reqEn)
Ensures frame is backed by a single buffer.
Definition Slave.cpp:144
virtual void acceptFrame(std::shared_ptr< rogue::interfaces::stream::Frame > frame)
Accepts a frame from a master.
Definition Slave.cpp:73
std::shared_ptr< rogue::interfaces::stream::SlaveWrap > SlaveWrapPtr
Definition Slave.h:269
std::shared_ptr< rogue::interfaces::stream::Slave > SlavePtr
Shared pointer alias for Slave.
Definition Slave.h:234