helics  2.8.1
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  thread_generation { single, dual }
 

Public Member Functions

 CommsInterface ()=default
 
 CommsInterface (thread_generation threads)
 
virtual ~CommsInterface ()
 
virtual void loadNetworkInfo (const NetworkBrokerData &netInfo)
 
void loadTargetInfo (const std::string &localTarget, const std::string &brokerTarget, interface_networks targetNetwork=interface_networks::local)
 
void transmit (route_id rid, const ActionMessage &cmd)
 
void transmit (route_id rid, ActionMessage &&cmd)
 
void addRoute (route_id rid, const std::string &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, const std::string &name, const std::string &message)> callback)
 
void setMessageSize (int maxMsgSize, int maxCount)
 
bool isConnected () const
 
void setTimeout (std::chrono::milliseconds timeOut)
 
virtual void setFlag (const std::string &flag, bool val)
 
void setServerMode (bool serverActive)
 
void logWarning (const std::string &message) const
 
void logError (const std::string &message) const
 
void logMessage (const std::string &message) const
 

Protected Types

enum  connection_status : int {
  connection_status::startup = -1, connection_status::connected = 0, connection_status::reconnecting = 1, connection_status::terminated = 2,
  connection_status::error = 4
}
 

Protected Member Functions

void setTxStatus (connection_status txStatus)
 
void setRxStatus (connection_status rxStatus)
 
connection_status getRxStatus () const
 
connection_status 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
 the identifier for the broker
 
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
 
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, const std::string &name, const std::string &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...
 
interface_networks interfaceNetwork = interface_networks::local
 

Detailed Description

implementation of a generic communications interface

Member Enumeration Documentation

◆ connection_status

enum helics::CommsInterface::connection_status : 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

error 

some error occurred on the connection

◆ thread_generation

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

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,
const std::string &  routeInfo 
)

◆ connect()

bool helics::CommsInterface::connect ( )

connect the commsInterface

Returns
true if the connection was successful false otherwise

References error.

◆ 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 ( const std::string &  message) const

generate a log message as an error

References helics_log_level_error.

◆ logMessage()

void helics::CommsInterface::logMessage ( const std::string &  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 ( const std::string &  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 ( const std::string &  flag,
bool  val 
)
virtual

set a flag for the comms system

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

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

◆ setLoggingCallback()

void helics::CommsInterface::setLoggingCallback ( std::function< void(int level, const std::string &name, const std::string &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

◆ 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().

◆ 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: