rogue
Loading...
Searching...
No Matches
Master.h
Go to the documentation of this file.
1
17#ifndef __ROGUE_INTERFACES_STREAM_MASTER_H__
18#define __ROGUE_INTERFACES_STREAM_MASTER_H__
19#include "rogue/Directives.h"
20
21#include <stdint.h>
22
23#include <cstdio>
24#include <memory>
25#include <mutex>
26#include <string>
27#include <thread>
28#include <vector>
29
31
32#ifndef NO_PYTHON
33 #include <boost/python.hpp>
34#endif
35
36namespace rogue {
37namespace interfaces {
38namespace stream {
39
40class Slave;
41class Frame;
42
65class Master : public rogue::EnableSharedFromThis<rogue::interfaces::stream::Master> {
66 // Vector of slaves
67 std::vector<std::shared_ptr<rogue::interfaces::stream::Slave> > slaves_;
68
69 // Slave mutex
70 std::mutex slaveMtx_;
71
72 // Default slave if not connected
73 std::shared_ptr<rogue::interfaces::stream::Slave> defSlave_;
74
75 public:
87 static std::shared_ptr<rogue::interfaces::stream::Master> create();
88
90 static void setup_python();
91
99 Master();
100
102 virtual ~Master();
103
111 uint32_t slaveCount();
112
123 void addSlave(std::shared_ptr<rogue::interfaces::stream::Slave> slave);
124
141 std::shared_ptr<rogue::interfaces::stream::Frame> reqFrame(uint32_t size, bool zeroCopyEn);
142
156 void sendFrame(std::shared_ptr<rogue::interfaces::stream::Frame> frame);
157
174 bool ensureSingleBuffer(std::shared_ptr<rogue::interfaces::stream::Frame>& frame, bool reqEn);
175
186 virtual void stop();
187
188#ifndef NO_PYTHON
189
194 void equalsPy(boost::python::object p);
195
201 boost::python::object rshiftPy(boost::python::object p);
202
203#endif
204
209 void operator==(std::shared_ptr<rogue::interfaces::stream::Slave>& other);
210
216 std::shared_ptr<rogue::interfaces::stream::Slave>& operator>>(
217 std::shared_ptr<rogue::interfaces::stream::Slave>& other);
218};
219
221typedef std::shared_ptr<rogue::interfaces::stream::Master> MasterPtr;
222} // namespace stream
223} // namespace interfaces
224} // namespace rogue
225#endif
Typed shared-from-this helper for Rogue classes.
Stream master endpoint.
Definition Master.h:65
virtual void stop()
Stops frame generation and shuts down associated threads.
Definition Master.cpp:119
std::shared_ptr< rogue::interfaces::stream::Frame > reqFrame(uint32_t size, bool zeroCopyEn)
Requests allocation of a new frame from the primary slave.
Definition Master.cpp:66
virtual ~Master()
Destroys the stream master.
Definition Master.cpp:51
void addSlave(std::shared_ptr< rogue::interfaces::stream::Slave > slave)
Attaches a downstream slave.
Definition Master.cpp:59
uint32_t slaveCount()
Returns the number of attached slaves.
Definition Master.cpp:54
void operator==(std::shared_ptr< rogue::interfaces::stream::Slave > &other)
Supports == operator usage in C++.
Definition Master.cpp:224
bool ensureSingleBuffer(std::shared_ptr< rogue::interfaces::stream::Frame > &frame, bool reqEn)
Ensures a frame is represented by a single buffer.
Definition Master.cpp:91
void equalsPy(boost::python::object p)
Supports == operator usage from Python.
Definition Master.cpp:138
std::shared_ptr< rogue::interfaces::stream::Slave > & operator>>(std::shared_ptr< rogue::interfaces::stream::Slave > &other)
Connects this master to a slave via stream chaining operator.
Definition Master.cpp:243
boost::python::object rshiftPy(boost::python::object p)
Supports >> operator usage from Python.
Definition Master.cpp:191
static void setup_python()
Registers this type with Python bindings.
Definition Master.cpp:121
void sendFrame(std::shared_ptr< rogue::interfaces::stream::Frame > frame)
Sends a frame to all attached slaves.
Definition Master.cpp:77
Master()
Constructs a stream master.
Definition Master.cpp:46
static std::shared_ptr< rogue::interfaces::stream::Master > create()
Creates a stream master.
Definition Master.cpp:40
std::shared_ptr< rogue::interfaces::stream::Master > MasterPtr
Shared pointer alias for Master.
Definition Master.h:221