rogue
Loading...
Searching...
No Matches
Core.cpp
Go to the documentation of this file.
1
17#include "rogue/Directives.h"
18
20
21#include <memory>
22
23#include "rogue/GeneralError.h"
24#include "rogue/GilRelease.h"
28
31
32#ifndef NO_PYTHON
33 #include <boost/python.hpp>
34namespace bp = boost::python;
35#endif
36
38rpp::CorePtr rpp::Core::create(bool enSsi) {
39 rpp::CorePtr r = std::make_shared<rpp::Core>(enSsi);
40 return (r);
41}
42
43void rpp::Core::setup_python() {
44#ifndef NO_PYTHON
45
46 bp::class_<rpp::Core, rpp::CorePtr, boost::noncopyable>("Core", bp::init<bool>())
47 .def("transport", &rpp::Core::transport)
48 .def("application", &rpp::Core::application)
49 .def("getDropCount", &rpp::Core::getDropCount);
50#endif
51}
52
54rpp::Core::Core(bool enSsi) {
55 tran_ = rpp::Transport::create();
56 cntl_ = rpp::ControllerV1::create(enSsi, tran_);
57
58 tran_->setController(cntl_);
59}
60
62rpp::Core::~Core() {
63 uint32_t x;
64
65 // Join the TX thread first: upstream masters may keep tran_ alive past this Core.
66 tran_->stop();
67
68 tran_.reset();
69 cntl_.reset();
70
71 for (x = 0; x < 256; x++) app_[x].reset();
72}
73
75rpp::TransportPtr rpp::Core::transport() {
76 return (tran_);
77}
78
80rpp::ApplicationPtr rpp::Core::application(uint8_t dest) {
81 if (!app_[dest]) {
82 app_[dest] = rpp::Application::create(dest);
83 app_[dest]->setController(cntl_);
84 cntl_->setApplication(dest, app_[dest]);
85 }
86 return (app_[dest]);
87}
88
90uint32_t rpp::Core::getDropCount() {
91 return (cntl_->getDropCount());
92}
93
94void rpp::Core::setTimeout(uint32_t timeout) {
95 cntl_->setTimeout(timeout);
96}
std::shared_ptr< rogue::protocols::packetizer::Transport > TransportPtr
Definition Transport.h:120
std::shared_ptr< rogue::protocols::packetizer::Core > CorePtr
Definition Core.h:111
std::shared_ptr< rogue::protocols::packetizer::Application > ApplicationPtr