rogue
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rogue::interfaces::stream::TcpCore Class Reference

Stream TCP bridge core implementation. More...

#include <TcpCore.h>

Inheritance diagram for rogue::interfaces::stream::TcpCore:
rogue::interfaces::stream::Master rogue::interfaces::stream::Slave rogue::EnableSharedFromThis< rogue::interfaces::stream::Master > rogue::interfaces::stream::Pool rogue::EnableSharedFromThis< rogue::interfaces::stream::Slave > rogue::EnableSharedFromThisBase rogue::EnableSharedFromThis< rogue::interfaces::stream::Pool > rogue::EnableSharedFromThisBase rogue::EnableSharedFromThisBase rogue::interfaces::stream::TcpClient rogue::interfaces::stream::TcpServer

Public Member Functions

 TcpCore (const std::string &addr, uint16_t port, bool server)
 Constructs a TCP stream bridge core.
 
 ~TcpCore ()
 Destroys the bridge core and releases resources.
 
void close ()
 Closes active bridge connections.
 
void stop ()
 Stops the interface and worker thread.
 
void acceptFrame (std::shared_ptr< rogue::interfaces::stream::Frame > frame)
 Receives a frame from upstream and forwards over the TCP bridge.
 
- Public Member Functions inherited from rogue::interfaces::stream::Master
 Master ()
 Constructs a stream master.
 
virtual ~Master ()
 Destroys the stream master.
 
uint32_t slaveCount ()
 Returns the number of attached slaves.
 
void addSlave (std::shared_ptr< rogue::interfaces::stream::Slave > slave)
 Attaches a downstream slave.
 
std::shared_ptr< rogue::interfaces::stream::FramereqFrame (uint32_t size, bool zeroCopyEn)
 Requests allocation of a new frame from the primary slave.
 
void sendFrame (std::shared_ptr< rogue::interfaces::stream::Frame > frame)
 Sends a frame to all attached slaves.
 
bool ensureSingleBuffer (std::shared_ptr< rogue::interfaces::stream::Frame > &frame, bool reqEn)
 Ensures a frame is represented by a single buffer.
 
void equalsPy (boost::python::object p)
 Supports == operator usage from Python.
 
boost::python::object rshiftPy (boost::python::object p)
 Supports >> operator usage from Python.
 
void operator== (std::shared_ptr< rogue::interfaces::stream::Slave > &other)
 Supports == operator usage in C++.
 
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.
 
- Public Member Functions inherited from rogue::EnableSharedFromThis< rogue::interfaces::stream::Master >
std::shared_ptr< rogue::interfaces::stream::Mastershared_from_this ()
 Returns a shared_ptr<T> for this instance.
 
- Public Member Functions inherited from rogue::EnableSharedFromThisBase
virtual ~EnableSharedFromThisBase ()
 Virtual destructor for polymorphic base usage.
 
- Public Member Functions inherited from rogue::interfaces::stream::Slave
 Slave ()
 Constructs a stream slave.
 
virtual ~Slave ()
 Destroys the stream slave.
 
void setDebug (uint32_t debug, std::string name)
 Sets debug message verbosity and logger name.
 
uint64_t getFrameCount ()
 Returns frame counter.
 
uint64_t getByteCount ()
 Returns byte counter.
 
bool ensureSingleBuffer (std::shared_ptr< rogue::interfaces::stream::Frame > &frame, bool reqEn)
 Ensures frame is backed by a single buffer.
 
std::shared_ptr< rogue::interfaces::stream::FramereqLocalFrame (uint32_t size, bool zeroCopyEn)
 Services a local frame allocation request through this object's pool interface.
 
boost::python::object lshiftPy (boost::python::object p)
 Supports << operator usage from Python.
 
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.
 
- Public Member Functions inherited from rogue::interfaces::stream::Pool
 Pool ()
 Constructs a pool with default allocation behavior enabled.
 
virtual ~Pool ()
 Destroys the pool and releases any cached buffer storage.
 
uint32_t getAllocBytes ()
 Returns total currently allocated bytes.
 
uint32_t getAllocCount ()
 Returns total currently allocated buffer count.
 
virtual std::shared_ptr< rogue::interfaces::stream::FrameacceptReq (uint32_t size, bool zeroCopyEn)
 Services a frame allocation request from a master.
 
virtual void retBuffer (uint8_t *data, uint32_t meta, uint32_t size)
 Returns buffer data to the allocator.
 
void setFixedSize (uint32_t size)
 Sets fixed-size mode.
 
uint32_t getFixedSize ()
 Returns fixed-size allocation setting.
 
void setPoolSize (uint32_t size)
 Sets buffer pool size.
 
uint32_t getPoolSize ()
 Returns configured maximum number of cached pool entries.
 
- Public Member Functions inherited from rogue::EnableSharedFromThis< rogue::interfaces::stream::Pool >
std::shared_ptr< rogue::interfaces::stream::Poolshared_from_this ()
 Returns a shared_ptr<T> for this instance.
 
- Public Member Functions inherited from rogue::EnableSharedFromThis< rogue::interfaces::stream::Slave >
std::shared_ptr< rogue::interfaces::stream::Slaveshared_from_this ()
 Returns a shared_ptr<T> for this instance.
 

Static Public Member Functions

static std::shared_ptr< rogue::interfaces::stream::TcpCorecreate (const std::string &addr, uint16_t port, bool server)
 Creates a TCP stream bridge core instance and returns it as TcpCorePtr.
 
static void setup_python ()
 Registers this type with Python bindings.
 
- Static Public Member Functions inherited from rogue::interfaces::stream::Master
static std::shared_ptr< rogue::interfaces::stream::Mastercreate ()
 Creates a stream master.
 
static void setup_python ()
 Registers this type with Python bindings.
 
- Static Public Member Functions inherited from rogue::interfaces::stream::Slave
static std::shared_ptr< rogue::interfaces::stream::Slavecreate ()
 Creates a new stream slave.
 
static void setup_python ()
 Registers this type with Python bindings.
 
- Static Public Member Functions inherited from rogue::interfaces::stream::Pool
static void setup_python ()
 Registers this type with Python bindings.
 

Protected Member Functions

void runThread ()
 Run thread.
 
- Protected Member Functions inherited from rogue::interfaces::stream::Pool
std::shared_ptr< rogue::interfaces::stream::BufferallocBuffer (uint32_t size, uint32_t *total)
 Allocate a buffer passed size.
 
std::shared_ptr< rogue::interfaces::stream::BuffercreateBuffer (void *data, uint32_t meta, uint32_t size, uint32_t alloc)
 Creates a Buffer with a pre-allocated data block.
 
void decCounter (uint32_t alloc)
 Decrements allocation counter.
 

Protected Attributes

std::string pullAddr_
 
std::string pushAddr_
 
void * zmqCtx_
 
void * zmqPull_
 
void * zmqPush_
 
std::shared_ptr< rogue::LoggingbridgeLog_
 
std::thread * thread_
 
bool threadEn_
 
std::mutex bridgeMtx_
 

Detailed Description

Stream TCP bridge core implementation.

This class implements the core functionality of the TcpClient and TcpServer classes which implement a Rogue stream bridge over a TCP network. This core can operate in either client or server mode. The TcpClient and TcpServer classes are thin wrappers that define which mode flag to pass to this base class.

The TcpServer and TcpClient interfaces are blocking and will stall frame transmissions when the remote side is either not present or is back-pressuring. When the remote server is not present a local buffer is not utilized, where it is utilized when a connection has been established.

Definition at line 51 of file TcpCore.h.

Constructor & Destructor Documentation

◆ TcpCore()

rogue::interfaces::stream::TcpCore::TcpCore ( const std::string &  addr,
uint16_t  port,
bool  server 
)

Constructs a TCP stream bridge core.

Creator.

This constructor is a low-level C++ allocation path. Prefer create() when shared ownership or Python exposure is required.

The constructor takes an address, port, and server mode flag. The address can be an IP address or hostname. In server mode, the address selects the local interface to bind. A value of "*" binds all local interfaces.

The stream bridge uses two consecutive TCP ports; port is the base. For example, port=8000 uses ports 8000 and 8001.

Parameters
addrInterface address for server, remote server address for client.
portBase TCP port number.
serverSet to true to run in server mode.

Definition at line 50 of file TcpCore.cpp.

◆ ~TcpCore()

rogue::interfaces::stream::TcpCore::~TcpCore ( )

Destroys the bridge core and releases resources.

Destructor.

Definition at line 147 of file TcpCore.cpp.

Member Function Documentation

◆ acceptFrame()

void rogue::interfaces::stream::TcpCore::acceptFrame ( std::shared_ptr< rogue::interfaces::stream::Frame frame)
virtual

Receives a frame from upstream and forwards over the TCP bridge.

Accept a frame from master.

Parameters
frameIncoming stream frame.

Reimplemented from rogue::interfaces::stream::Slave.

Definition at line 168 of file TcpCore.cpp.

◆ close()

void rogue::interfaces::stream::TcpCore::close ( )

Closes active bridge connections.

Definition at line 152 of file TcpCore.cpp.

◆ create()

rogue::interfaces::stream::TcpCorePtr rogue::interfaces::stream::TcpCore::create ( const std::string &  addr,
uint16_t  port,
bool  server 
)
static

Creates a TCP stream bridge core instance and returns it as TcpCorePtr.

Class creation.

Parameter semantics are identical to the constructor; see TcpCore() for address and port behavior details. This static factory is the preferred construction path when the object is shared across Rogue graph connections or exposed to Python. It returns std::shared_ptr ownership compatible with Rogue pointer typedefs. Not exposed to Python.

Parameters
addrInterface address for server, remote server address for client.
portBase TCP port number.
serverSet to true to run in server mode.
Returns
Shared pointer to the created bridge core.

Company : SLAC National Accelerator Laboratory

Description:

Stream Network Core

This file is part of the rogue software platform. It is subject to the license terms in the LICENSE.txt file found in the top-level directory of this distribution and at: https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. No part of the rogue software platform, including this file, may be copied, modified, propagated, or distributed except according to the terms

contained in the LICENSE.txt file.

Definition at line 44 of file TcpCore.cpp.

◆ runThread()

void rogue::interfaces::stream::TcpCore::runThread ( )
protected

Run thread.

Definition at line 217 of file TcpCore.cpp.

◆ setup_python()

void rogue::interfaces::stream::TcpCore::setup_python ( )
static

Registers this type with Python bindings.

Definition at line 292 of file TcpCore.cpp.

◆ stop()

void rogue::interfaces::stream::TcpCore::stop ( )
virtual

Stops the interface and worker thread.

Reimplemented from rogue::interfaces::stream::Master.

Definition at line 156 of file TcpCore.cpp.

Member Data Documentation

◆ bridgeLog_

std::shared_ptr<rogue::Logging> rogue::interfaces::stream::TcpCore::bridgeLog_
protected

Definition at line 72 of file TcpCore.h.

◆ bridgeMtx_

std::mutex rogue::interfaces::stream::TcpCore::bridgeMtx_
protected

Definition at line 79 of file TcpCore.h.

◆ pullAddr_

std::string rogue::interfaces::stream::TcpCore::pullAddr_
protected

Definition at line 54 of file TcpCore.h.

◆ pushAddr_

std::string rogue::interfaces::stream::TcpCore::pushAddr_
protected

Definition at line 57 of file TcpCore.h.

◆ thread_

std::thread* rogue::interfaces::stream::TcpCore::thread_
protected

Definition at line 75 of file TcpCore.h.

◆ threadEn_

bool rogue::interfaces::stream::TcpCore::threadEn_
protected

Definition at line 76 of file TcpCore.h.

◆ zmqCtx_

void* rogue::interfaces::stream::TcpCore::zmqCtx_
protected

Definition at line 60 of file TcpCore.h.

◆ zmqPull_

void* rogue::interfaces::stream::TcpCore::zmqPull_
protected

Definition at line 63 of file TcpCore.h.

◆ zmqPush_

void* rogue::interfaces::stream::TcpCore::zmqPush_
protected

Definition at line 66 of file TcpCore.h.


The documentation for this class was generated from the following files: