Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
DirectHub.hxx File Reference

Go to the source code of this file.

Classes

class  HubSource
 Empty class that can be used as a pointer for identifying where a piece of data came from. More...
 
struct  MessageMetadata
 Metadata that is the same about every message (independent of data type). More...
 
struct  MessageAccessor< T >
 Typed message class. More...
 
struct  MessageAccessor< uint8_t[]>
 Type specializer for message interface when we are sending untyped data (i.e., byte streams). More...
 
class  MessageSegmenter
 Abstract base class for segmenting a byte stream typed input into meaningful packet sized chunks. More...
 
class  DirectHubPort< T >
 Interface for a downstream port of a hub (aka a target to send data to). More...
 
class  DirectHubInterface< T >
 Interface for a the central part of a hub. More...
 

Typedefs

typedef DirectHubInterface< uint8_t[]> ByteDirectHubInterface
 
typedef HubContainer< CanFrameContainerCanHubData
 
typedef GenericHubFlow< CanHubDataCanHubFlow
 

Functions

ByteDirectHubInterfacecreate_hub (ExecutorBase *e)
 Creates a new byte stream typed hub.
 
void create_port_for_fd (ByteDirectHubInterface *hub, int fd, std::unique_ptr< MessageSegmenter > segmenter, Notifiable *on_error=nullptr)
 Creates a hub port of byte stream type reading/writing a given fd.
 
void create_direct_gc_tcp_hub (ByteDirectHubInterface *hub, int port)
 Creates a new GridConnect listener on a given TCP port.
 
MessageSegmentercreate_gc_message_segmenter ()
 Creates a message segmenter for gridconnect data.
 
MessageSegmentercreate_trivial_message_segmenter ()
 Creates a message segmenter for arbitrary data.
 
Destructablecreate_gc_to_legacy_can_bridge (DirectHubInterface< uint8_t[]> *gc_hub, CanHubFlow *can_hub)
 Creates a bridge between a gridconnect-based DirectHub and an old style CAN hub flow.
 

Detailed Description

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Optimized class for ingress and egress of write-once objects, aimed to support multi-recipient messages with fast internal fan-out but low compute overhead.

Author
Balazs Racz
Date
9 Feb 2020

Definition in file DirectHub.hxx.

Typedef Documentation

◆ ByteDirectHubInterface

Definition at line 203 of file DirectHub.hxx.

◆ CanHubData

Definition at line 241 of file DirectHub.hxx.

◆ CanHubFlow

Definition at line 242 of file DirectHub.hxx.

Function Documentation

◆ create_direct_gc_tcp_hub()

void create_direct_gc_tcp_hub ( ByteDirectHubInterface hub,
int  port 
)

Creates a new GridConnect listener on a given TCP port.

The object is leaked (never destroyed).

Parameters
hubincoming and outgoing data will be multiplexed through this hub instance.
portthe TCP port to listen on.

Definition at line 945 of file DirectHub.cxx.

◆ create_gc_message_segmenter()

MessageSegmenter * create_gc_message_segmenter ( )

Creates a message segmenter for gridconnect data.

Returns
a newly allocated message segmenter that chops gridconnect packets off of a data stream.

Definition at line 122 of file DirectHubGc.cxx.

◆ create_gc_to_legacy_can_bridge()

Destructable * create_gc_to_legacy_can_bridge ( DirectHubInterface< uint8_t[]> *  gc_hub,
CanHubFlow can_hub 
)

Creates a bridge between a gridconnect-based DirectHub and an old style CAN hub flow.

Parameters
gc_hubthe gridconnect hub.
can_hubthe CAN hub.
Returns
an object that can be deleted (only outside the main executor).

Definition at line 182 of file DirectHubLegacy.cxx.

◆ create_hub()

ByteDirectHubInterface * create_hub ( ExecutorBase e)

Creates a new byte stream typed hub.

Creates a new byte stream typed hub.

Definition at line 251 of file DirectHub.cxx.

◆ create_port_for_fd()

void create_port_for_fd ( ByteDirectHubInterface hub,
int  fd,
std::unique_ptr< MessageSegmenter segmenter,
Notifiable on_error = nullptr 
)

Creates a hub port of byte stream type reading/writing a given fd.

This port will be automaticelly deleted upon any error reading/writing the fd (unregistered and memory released).

Parameters
hubhub instance on which to register the new port. Onwership retained by caller.
fdwhere to read and write data.
segmenteris an newly allocated object for the given protocol to segment incoming data into messages. Transfers ownership to the function.
on_errorthis will be notified if the port closes due to an error.

Definition at line 880 of file DirectHub.cxx.

◆ create_trivial_message_segmenter()

MessageSegmenter * create_trivial_message_segmenter ( )

Creates a message segmenter for arbitrary data.

Each buffer is left alone.

Returns
a newly allocated message segmenter.

Definition at line 145 of file DirectHubGc.cxx.