helics  3.5.2
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
helics::CommsInterface Class Referenceabstract

#include <CommsInterface.hpp>

+ Inheritance diagram for helics::CommsInterface:

Public Types

enum class  thread_generation { single , dual }
 

Public Member Functions

 CommsInterface ()=default
 
 CommsInterface (thread_generation threads)
 
virtual ~CommsInterface ()
 
virtual void loadNetworkInfo (const NetworkBrokerData &netInfo)
 
void loadTargetInfo (std::string_view localTarget, std::string_view brokerTarget, gmlc::networking::InterfaceNetworks targetNetwork=gmlc::networking::InterfaceNetworks::LOCAL)
 
void transmit (route_id rid, const ActionMessage &cmd)
 
void transmit (route_id rid, ActionMessage &&cmd)
 
void addRoute (route_id rid, std::string_view routeInfo)
 
void removeRoute (route_id rid)
 
bool connect ()
 
void disconnect ()
 
bool reconnect ()
 
void setName (const std::string &commName)
 
void setRequireBrokerConnection (bool requireBrokerConnection)
 
void setCallback (std::function< void(ActionMessage &&)> callback)
 
void setLoggingCallback (std::function< void(int level, std::string_view name, std::string_view message)> callback)
 
void setMessageSize (int maxMsgSize, int maxCount)
 
bool isConnected () const
 
void setTimeout (std::chrono::milliseconds timeOut)
 
virtual void setFlag (std::string_view flag, bool val)
 
void setServerMode (bool serverActive)
 
void logWarning (std::string_view message) const
 
void logError (std::string_view message) const
 
void logMessage (std::string_view message) const
 

Protected Types

enum class  ConnectionStatus : int {
  STARTUP = -1 , CONNECTED = 0 , RECONNECTING = 1 , TERMINATED = 2 ,
  ERRORED = 4
}
 

Protected Member Functions

void setTxStatus (ConnectionStatus status)
 
void setRxStatus (ConnectionStatus status)
 
ConnectionStatus getRxStatus () const
 
ConnectionStatus getTxStatus () const
 
bool propertyLock ()
 
void propertyUnLock ()
 
void join_tx_rx_thread ()
 
const std::string & getRandomID () const
 

Protected Attributes

gmlc::concurrency::TriggerVariable rxTrigger
 
std::string name
 the name of the object
 
std::string localTargetAddress
 the base for the receive address
 
std::string brokerTargetAddress
 the base for the broker address
 
std::string brokerName
 
std::string brokerInitString
 the initialization string for any automatically generated broker
 
bool mRequireBrokerConnection
 specify that the comms should assume we have a broker More...
 
bool serverMode {true}
 some comms have a server mode and non-server mode
 
bool autoBroker {false}
 the broker should be automatically generated if needed
 
bool useJsonSerialization {false}
 true to make all connections use JSON serialization
 
bool observer {false}
 true for connections that are for observation only
 
std::chrono::milliseconds connectionTimeout {4000}
 
int maxMessageSize = 16 * 1024
 the maximum message size for the queues (if needed)
 
int maxMessageCount = 512
 the maximum number of message to buffer (if needed)
 
std::atomic< bool > requestDisconnect {false}
 flag gets set when disconnect is called
 
std::function< void(ActionMessage &&)> ActionCallback
 the callback for what to do with a received message
 
std::function< void(int level, std::string_view name, std::string_view message)> loggingCallback
 callback for logging
 
gmlc::containers::BlockingPriorityQueue< std::pair< route_id, ActionMessage > > txQueue
 set of messages waiting to be transmitted
 
std::atomic< bool > disconnecting
 flag indicating that the comm system is in the process of disconnecting More...
 
gmlc::networking::InterfaceNetworks interfaceNetwork
 

Detailed Description

implementation of a generic communications interface

Member Enumeration Documentation

◆ ConnectionStatus

enum helics::CommsInterface::ConnectionStatus : int
strongprotected

enumeration of the connection status flags for more immediate feedback from the processing threads

Enumerator
STARTUP 

the connection is in STARTUP mode

CONNECTED 

we are CONNECTED

RECONNECTING 

we are trying reconnect

TERMINATED 

the connection has been TERMINATED

ERRORED 

some ERRORED occurred on the connection

◆ thread_generation

enumeration of whether the threading system should generate a single thread or multiple threads

Enumerator
single 

indicate that a single thread is used for transmitting and receiving

dual 

indicate that separate threads are used, 1 for transmission and 1 for reception

Constructor & Destructor Documentation

◆ CommsInterface()

helics::CommsInterface::CommsInterface ( )
default

default constructor

◆ ~CommsInterface()

helics::CommsInterface::~CommsInterface ( )
virtual

destructor

Member Function Documentation

◆ addRoute()

void helics::CommsInterface::addRoute ( route_id  rid,
std::string_view  routeInfo 
)

◆ connect()

bool helics::CommsInterface::connect ( )

connect the commsInterface

Returns
true if the connection was successful false otherwise

◆ disconnect()

void helics::CommsInterface::disconnect ( )

◆ getRandomID()

const std::string& helics::CommsInterface::getRandomID ( ) const
inlineprotected

get the generated randomID for this comm interface

◆ isConnected()

bool helics::CommsInterface::isConnected ( ) const

check if the commInterface is connected

◆ join_tx_rx_thread()

void helics::CommsInterface::join_tx_rx_thread ( )
protected

function to join the processing threads

◆ loadNetworkInfo()

void helics::CommsInterface::loadNetworkInfo ( const NetworkBrokerData netInfo)
virtual

◆ logError()

void helics::CommsInterface::logError ( std::string_view  message) const

generate a log message as an error

References HELICS_LOG_LEVEL_ERROR.

◆ logMessage()

void helics::CommsInterface::logMessage ( std::string_view  message) const

generate a log message as a level above warning or error

References HELICS_LOG_LEVEL_INTERFACES.

Referenced by helics::mpi::MpiComms::MpiComms().

◆ logWarning()

void helics::CommsInterface::logWarning ( std::string_view  message) const

generate a log message as a warning

References HELICS_LOG_LEVEL_WARNING.

◆ propertyLock()

bool helics::CommsInterface::propertyLock ( )
protected

◆ reconnect()

bool helics::CommsInterface::reconnect ( )

try reconnected from a mismatched or disconnection

◆ removeRoute()

void helics::CommsInterface::removeRoute ( route_id  rid)

◆ setCallback()

void helics::CommsInterface::setCallback ( std::function< void(ActionMessage &&)>  callback)

set the callback for processing the messages

◆ setFlag()

void helics::CommsInterface::setFlag ( std::string_view  flag,
bool  val 
)
virtual

set a flag for the comms system

Reimplemented in helics::tcp::TcpCommsSS, helics::tcp::TcpComms, and helics::NetworkCommsInterface.

Referenced by helics::NetworkCommsInterface::setFlag().

◆ setLoggingCallback()

void helics::CommsInterface::setLoggingCallback ( std::function< void(int level, std::string_view name, std::string_view message)>  callback)

set the callback for processing the messages

◆ setMessageSize()

void helics::CommsInterface::setMessageSize ( int  maxMsgSize,
int  maxCount 
)

set the max message size and max Queue size

◆ setName()

void helics::CommsInterface::setName ( const std::string &  commName)

set the name of the communicator

◆ setRequireBrokerConnection()

void helics::CommsInterface::setRequireBrokerConnection ( bool  requireBrokerConnection)

set a flag indicating that a broker connection is required and all Connection fields are targeted at a broker

◆ setServerMode()

void helics::CommsInterface::setServerMode ( bool  serverActive)

enable or disable the server mode for the comms

◆ setTimeout()

void helics::CommsInterface::setTimeout ( std::chrono::milliseconds  timeOut)

set the timeout for the initial broker connection

Parameters
timeOutthe value is in milliseconds

◆ transmit() [1/2]

void helics::CommsInterface::transmit ( route_id  rid,
ActionMessage &&  cmd 
)

transmit a message along a particular route

References helics::isPriorityCommand().

◆ transmit() [2/2]

void helics::CommsInterface::transmit ( route_id  rid,
const ActionMessage cmd 
)

transmit a message along a particular route

References helics::isPriorityCommand().

Member Data Documentation

◆ brokerName

std::string helics::CommsInterface::brokerName
protected

the identifier for the broker

◆ connectionTimeout

std::chrono::milliseconds helics::CommsInterface::connectionTimeout {4000}
protected

timeout for the initial connection to a broker or to bind a broker port(in ms)

◆ disconnecting

std::atomic<bool> helics::CommsInterface::disconnecting
protected
Initial value:
{
false}

flag indicating that the comm system is in the process of disconnecting

Referenced by helics::zeromq::ZmqCommsSS::~ZmqCommsSS().

◆ interfaceNetwork

gmlc::networking::InterfaceNetworks helics::CommsInterface::interfaceNetwork
protected
Initial value:
{
gmlc::networking::InterfaceNetworks::LOCAL}

◆ mRequireBrokerConnection

bool helics::CommsInterface::mRequireBrokerConnection
protected
Initial value:
{
false}

specify that the comms should assume we have a broker

Referenced by helics::NetworkCommsInterface::loadNetworkInfo().


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