rogue
Loading...
Searching...
No Matches
Filter.cpp
Go to the documentation of this file.
1
17#include "rogue/Directives.h"
18
20
21#include <inttypes.h>
22#include <stdint.h>
23
24#include <memory>
25
26#include "rogue/Logging.h"
30
32
33#ifndef NO_PYTHON
34 #include <boost/python.hpp>
35namespace bp = boost::python;
36#endif
37
39ris::FilterPtr ris::Filter::create(bool dropErrors, uint8_t channel) {
40 ris::FilterPtr p = std::make_shared<ris::Filter>(dropErrors, channel);
41 return (p);
42}
43
45void ris::Filter::setup_python() {
46#ifndef NO_PYTHON
47 bp::class_<ris::Filter, ris::FilterPtr, bp::bases<ris::Master, ris::Slave>, boost::noncopyable>(
48 "Filter",
49 bp::init<bool, uint8_t>());
50#endif
51}
52
54ris::Filter::Filter(bool dropErrors, uint8_t channel) : ris::Master(), ris::Slave() {
55 dropErrors_ = dropErrors;
56 channel_ = channel;
57
58 log_ = rogue::Logging::create("stream.Filter");
59}
60
62ris::Filter::~Filter() {}
63
65void ris::Filter::acceptFrame(ris::FramePtr frame) {
66 // Drop channel mismatches
67 if (frame->getChannel() != channel_) return;
68
69 // Drop errored frames
70 if (dropErrors_ && (frame->getError() != 0)) {
71 log_->debug("Dropping errored frame: Channel=%" PRIu8 ", Error=0x%" PRIx8, channel_, frame->getError());
72 return;
73 }
74
75 sendFrame(frame);
76}
static std::shared_ptr< rogue::Logging > create(const std::string &name, bool quiet=false)
Creates a logger instance.
Definition Logging.cpp:60
Stream master endpoint.
Definition Master.h:65
Stream slave endpoint and default frame pool.
Definition Slave.h:72
std::shared_ptr< rogue::interfaces::stream::Frame > FramePtr
Shared pointer alias for Frame.
Definition Frame.h:549
std::shared_ptr< rogue::interfaces::stream::Filter > FilterPtr
Shared pointer alias for Filter.
Definition Filter.h:93