Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
GCFdConnectionClient Class Referenceabstract

Base class for FD-based GridConnect connection clients. More...

#include <ClientConnection.hxx>

Inheritance diagram for GCFdConnectionClient:
ConnectionClient DeviceConnectionClient UpstreamConnectionClient

Public Member Functions

 GCFdConnectionClient (const string &name, CanHubFlow *hub)
 Constructor.
 
 GCFdConnectionClient (const string &name, ByteDirectHubInterface *direct_hub)
 Constructor.
 
bool ping () OVERRIDE
 Tests if the device is alive or encountered an error.
 
int fd () override
 

Protected Member Functions

virtual void try_connect ()=0
 Abstrct base function to attempt to connect (or open device) to the destination.
 
void connection_complete (int fd)
 Callback from try_connect to donate the file descriptor.
 

Private Attributes

DeviceClosedNotify closedNotify_
 Will be called when the descriptor experiences an error (typivcally upon device closed or connection lost).
 
int fd_ {-1}
 File descriptor of the currently open device/socket.
 
CanHubFlowhub_ {nullptr}
 CAN hub to read-write data to.
 
ByteDirectHubInterfacedirectHub_ {nullptr}
 DirectHub to read/write data to.
 

Detailed Description

Base class for FD-based GridConnect connection clients.

Definition at line 94 of file ClientConnection.hxx.

Constructor & Destructor Documentation

◆ GCFdConnectionClient() [1/2]

GCFdConnectionClient::GCFdConnectionClient ( const string &  name,
CanHubFlow hub 
)
inline

Constructor.

Parameters
nameuser-readable name for this port.
hubCAN packet hub to connect this port to

Definition at line 101 of file ClientConnection.hxx.

◆ GCFdConnectionClient() [2/2]

GCFdConnectionClient::GCFdConnectionClient ( const string &  name,
ByteDirectHubInterface direct_hub 
)
inline

Constructor.

Parameters
nameuser-readable name for this port.
direct_hubgridconnect DirectHub to connect this device to.

Definition at line 111 of file ClientConnection.hxx.

◆ ~GCFdConnectionClient()

virtual GCFdConnectionClient::~GCFdConnectionClient ( )
inlinevirtual

Definition at line 117 of file ClientConnection.hxx.

Member Function Documentation

◆ connection_complete()

void GCFdConnectionClient::connection_complete ( int  fd)
protected

Callback from try_connect to donate the file descriptor.

Parameters
fdis the file destriptor of the connection freshly opened.
fdis the file destriptor of the connection freshly opened.

Definition at line 43 of file ClientConnection.cxx.

◆ fd()

int GCFdConnectionClient::fd ( )
inlineoverridevirtual
Returns
the file descriptor, if this connection has one, or -1 if the connection is down or doesn't have an fd.

Reimplemented from ConnectionClient.

Definition at line 132 of file ClientConnection.hxx.

◆ ping()

bool GCFdConnectionClient::ping ( )
inlinevirtual

Tests if the device is alive or encountered an error.

Retries connection if an error happens.

Returns
true if the connection is live.

Implements ConnectionClient.

Definition at line 123 of file ClientConnection.hxx.

◆ try_connect()

virtual void GCFdConnectionClient::try_connect ( )
protectedpure virtual

Abstrct base function to attempt to connect (or open device) to the destination.

Implemented in DeviceConnectionClient, and UpstreamConnectionClient.

Member Data Documentation

◆ closedNotify_

DeviceClosedNotify GCFdConnectionClient::closedNotify_
private

Will be called when the descriptor experiences an error (typivcally upon device closed or connection lost).

Definition at line 149 of file ClientConnection.hxx.

◆ directHub_

ByteDirectHubInterface* GCFdConnectionClient::directHub_ {nullptr}
private

DirectHub to read/write data to.

Definition at line 155 of file ClientConnection.hxx.

◆ fd_

int GCFdConnectionClient::fd_ {-1}
private

File descriptor of the currently open device/socket.

Definition at line 151 of file ClientConnection.hxx.

◆ hub_

CanHubFlow* GCFdConnectionClient::hub_ {nullptr}
private

CAN hub to read-write data to.

Definition at line 153 of file ClientConnection.hxx.


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