helics  3.5.2
Public Member Functions | Protected Attributes | List of all members
helicscpp::Federate Class Reference

#include <Federate.hpp>

+ Inheritance diagram for helicscpp::Federate:

Public Member Functions

 Federate () HELICS_NOTHROW
 Default constructor.
 
 Federate (const Federate &fedObj)
 Copy constructor.
 
Federateoperator= (const Federate &fedObj)
 Copy assignment operator.
 
virtual ~Federate ()
 
 operator HelicsFederate () const
 
HelicsFederate baseObject () const
 
void setFlagOption (int flag, bool flagValue=true)
 
void setProperty (int tProperty, HelicsTime timeValue)
 
void setProperty (int intProperty, int value)
 
bool getFlagOption (int flag) const
 
HelicsTime getTimeProperty (int tProperty) const
 
int getIntegerProperty (int intProperty) const
 
void setSeparator (char sep)
 
void registerInterfaces (const std::string &configString)
 
HelicsFederateState getCurrentMode () const
 
bool isAsyncOperationCompleted () const
 
void enterInitializingMode ()
 
void enterInitializingModeAsync ()
 
void enterInitializingModeComplete ()
 
void enterInitializingModeIterative ()
 
void enterInitializingModeIterativeAsync ()
 
void enterInitializingModeIterativeComplete ()
 
HelicsIterationResult enterExecutingMode (HelicsIterationRequest iterate=HELICS_ITERATION_REQUEST_NO_ITERATION)
 
void enterExecutingModeAsync (HelicsIterationRequest iterate=HELICS_ITERATION_REQUEST_NO_ITERATION)
 
HelicsIterationResult enterExecutingModeComplete ()
 
void finalize ()
 
void finalizeAsync ()
 
void finalizeComplete ()
 
HelicsTime getCurrentTime ()
 
HelicsTime requestTime (HelicsTime time)
 
HelicsTime requestNextStep ()
 
HelicsTime requestTimeAdvance (HelicsTime timeDelta)
 
HelicsIterationTime requestTimeIterative (HelicsTime time, HelicsIterationRequest iterate)
 
void requestTimeAsync (HelicsTime time)
 
void requestTimeIterativeAsync (HelicsTime time, HelicsIterationRequest iterate)
 
HelicsTime requestTimeComplete ()
 
HelicsIterationTime requestTimeIterativeComplete ()
 
void processCommunication (HelicsTime period)
 
const char * getName () const
 
void protect ()
 
void unProtect ()
 
std::string query (const std::string &target, const std::string &queryStr, HelicsSequencingModes mode=HELICS_SEQUENCING_MODE_FAST) const
 
std::string query (const std::string &queryStr, HelicsSequencingModes mode=HELICS_SEQUENCING_MODE_FAST) const
 
void sendCommand (const std::string &target, const std::string &cmd)
 
const char * getCommand ()
 
const char * waitCommand ()
 
const char * getCommandSource ()
 
void setQueryCallback (void(*queryAnswer)(const char *query, int querySize, HelicsQueryBuffer, void *userdata), void *userdata)
 
void setTimeRequestEntryCallback (void(*timeRequestEntry)(HelicsTime currentTime, HelicsTime requestTime, HelicsBool iterating, void *userdata), void *userdata)
 
void setTimeUpdateCallback (void(*timeUpdate)(HelicsTime time, HelicsBool iterating, void *userdata), void *userdata)
 
void setStateChangeCallback (void(*stateChange)(HelicsFederateState newState, HelicsFederateState oldState, void *userdata), void *userdata)
 
void setTimeRequestReturnCallback (void(*timeRequestReturn)(HelicsTime newTime, HelicsBool iterating, void *userdata), void *userdata)
 
Filter registerFilter (HelicsFilterTypes type, const std::string &filterName=std::string())
 
CloningFilter registerCloningFilter (const std::string &deliveryEndpoint)
 
Filter registerGlobalFilter (HelicsFilterTypes type, const std::string &filterName=std::string())
 
CloningFilter registerGlobalCloningFilter (const std::string &deliveryEndpoint)
 
int getFilterCount () const
 
Filter getFilter (const std::string &filterName)
 
Filter getFilter (int index)
 
void setGlobal (const std::string &valueName, const std::string &value)
 
void addAlias (const std::string &interfaceName, const std::string &alias)
 
void setTag (const std::string &tag, const std::string &value)
 
const char * getTag (const std::string &tag) const
 
void addDependency (const std::string &fedName)
 
void localError (int errorCode, const std::string &errorString)
 
void globalError (int errorCode, const std::string &errorString)
 
void logErrorMessage (const std::string &message)
 
void logWarningMessage (const std::string &message)
 
void logInfoMessage (const std::string &message)
 
void logDebugMessage (const std::string &message)
 
void logMessage (int level, const std::string &message)
 
HelicsCore getCore ()
 
HelicsFederate getObject () const
 

Protected Attributes

HelicsFederate fed
 underlying HelicsFederate object
 
bool exec_async_iterate
 indicator that the federate is in an async operation
 

Detailed Description

Federate object managing a C++98 Federate object

Constructor & Destructor Documentation

◆ ~Federate()

virtual helicscpp::Federate::~Federate ( )
inlinevirtual

destructor

References fed, and helicsFederateFree().

Member Function Documentation

◆ addAlias()

void helicscpp::Federate::addAlias ( const std::string &  interfaceName,
const std::string &  alias 
)
inline

add a global alias for an interface

Parameters
interfaceNamethe given name of the interface
aliasthe new name by which the interface can be referenced

References fed, and helicsFederateAddAlias().

◆ addDependency()

void helicscpp::Federate::addDependency ( const std::string &  fedName)
inline

add a dependency for this federate

adds an additional internal time dependency for the federate

Parameters
fedNamethe name of the federate to add a dependency on

References fed, and helicsFederateAddDependency().

◆ baseObject()

HelicsFederate helicscpp::Federate::baseObject ( ) const
inline

get the underlying HelicsFederate object

References fed.

◆ enterExecutingMode()

HelicsIterationResult helicscpp::Federate::enterExecutingMode ( HelicsIterationRequest  iterate = HELICS_ITERATION_REQUEST_NO_ITERATION)
inline

enter the normal execution mode

call will block until all federates have entered this mode

Parameters
iteratean optional flag indicating the desired iteration mode

References fed, HELICS_ITERATION_REQUEST_NO_ITERATION, HELICS_ITERATION_RESULT_NEXT_STEP, helicsFederateEnterExecutingMode(), and helicsFederateEnterExecutingModeIterative().

◆ enterExecutingModeAsync()

void helicscpp::Federate::enterExecutingModeAsync ( HelicsIterationRequest  iterate = HELICS_ITERATION_REQUEST_NO_ITERATION)
inline

enter the normal execution mode

call will return immediately but enterExecutingModeComplete should be called to complete the operation

Parameters
iteratean optional flag indicating the desired iteration mode

References exec_async_iterate, fed, HELICS_ITERATION_REQUEST_NO_ITERATION, helicsFederateEnterExecutingModeAsync(), and helicsFederateEnterExecutingModeIterativeAsync().

◆ enterExecutingModeComplete()

HelicsIterationResult helicscpp::Federate::enterExecutingModeComplete ( )
inline

complete the async call for entering Execution state

call will not block but will return quickly. The enterInitializingModeComplete must be called before doing other operations

References exec_async_iterate, fed, HELICS_ITERATION_RESULT_NEXT_STEP, helicsFederateEnterExecutingModeComplete(), and helicsFederateEnterExecutingModeIterativeComplete().

◆ enterInitializingMode()

void helicscpp::Federate::enterInitializingMode ( )
inline

enter the initialization mode after all interfaces have been defined

the call will block until all federates have entered initialization mode

References fed, and helicsFederateEnterInitializingMode().

◆ enterInitializingModeAsync()

void helicscpp::Federate::enterInitializingModeAsync ( )
inline

enter the initialization mode after all interfaces have been defined

the call will not block but a call to enterInitializingModeComplete should be made to complete the call sequence

References fed, and helicsFederateEnterInitializingModeAsync().

◆ enterInitializingModeComplete()

void helicscpp::Federate::enterInitializingModeComplete ( )
inline

second part of the async process for entering initializationState call after a call to enterInitializingModeAsync if call any other time it will throw an InvalidFunctionCall exception

References fed, and helicsFederateEnterInitializingModeComplete().

◆ enterInitializingModeIterative()

void helicscpp::Federate::enterInitializingModeIterative ( )
inline

iterate in the created mode.

the call will block until all federates have flagged they are ready for the next stage of initialization all federates requesting iterations on the created mode will be notified they can continue with setup.

References fed, and helicsFederateEnterInitializingModeIterative().

◆ enterInitializingModeIterativeAsync()

void helicscpp::Federate::enterInitializingModeIterativeAsync ( )
inline

iterate in the created mode.

the call will not block but a call to enterInitializingModeIterativeComplete should be made to complete the call sequence

References fed, and helicsFederateEnterInitializingModeIterativeAsync().

◆ enterInitializingModeIterativeComplete()

void helicscpp::Federate::enterInitializingModeIterativeComplete ( )
inline

second part of the async process for entering initializationModeIterative call after a call to enterInitializingModeIterativeAsync; if called any other time it will throw an InvalidFunctionCall exception

References fed, and helicsFederateEnterInitializingModeIterativeComplete().

◆ finalize()

void helicscpp::Federate::finalize ( )
inline

terminate the simulation

call is will block until the finalize has been acknowledged, no commands that interact with the core may be called after this function function

References fed, and helicsFederateFinalize().

◆ finalizeAsync()

void helicscpp::Federate::finalizeAsync ( )
inline

terminate the simulation in a non-blocking call

finalizeComplete must be called after this call to complete the finalize procedure

References fed, and helicsFederateFinalizeAsync().

◆ finalizeComplete()

void helicscpp::Federate::finalizeComplete ( )
inline

complete the asynchronous terminate pair

References fed, and helicsFederateFinalizeComplete().

◆ getCommand()

const char* helicscpp::Federate::getCommand ( )
inline

Get a command sent to the federate.

Returns
A string with the command for the federate, if the string is empty no command is available.

References fed, and helicsFederateGetCommand().

◆ getCommandSource()

const char* helicscpp::Federate::getCommandSource ( )
inline

Get the source of the most recently retrieved command sent to the federate.

Returns
A string with the command for the federate, if the string is empty no command is available.

References fed, and helicsFederateGetCommandSource().

◆ getCore()

HelicsCore helicscpp::Federate::getCore ( )
inline

get a Core Object

References fed, and helicsFederateGetCore().

◆ getCurrentMode()

HelicsFederateState helicscpp::Federate::getCurrentMode ( ) const
inline

get the current state of the federate

References fed, and helicsFederateGetState().

◆ getCurrentTime()

HelicsTime helicscpp::Federate::getCurrentTime ( )
inline

get the current time from a federate

References fed, and helicsFederateGetCurrentTime().

◆ getFilter() [1/2]

Filter helicscpp::Federate::getFilter ( const std::string &  filterName)
inline

get the id of a source filter from the name of the endpoint

Parameters
filterNamethe name of the filter
Returns
a reference to a filter object which could be invalid if filterName is not valid

References fed, and helicsFederateGetFilter().

◆ getFilter() [2/2]

Filter helicscpp::Federate::getFilter ( int  index)
inline

get a filter from its index

Parameters
indexthe index of a filter
Returns
a reference to a filter object which could be invalid if filterName is not valid

References fed, and helicsFederateGetFilterByIndex().

◆ getFilterCount()

int helicscpp::Federate::getFilterCount ( ) const
inline

get a count of the number of filters registered in a federate

References fed, and helicsFederateGetFilterCount().

◆ getFlagOption()

bool helicscpp::Federate::getFlagOption ( int  flag) const
inline

get the value of a flag option

Parameters
flagan index into the flag /ref flag-definitions.h

References fed, HELICS_FALSE, and helicsFederateGetFlagOption().

◆ getIntegerProperty()

int helicscpp::Federate::getIntegerProperty ( int  intProperty) const
inline

get an integer option for the federate

Parameters
intPropertythe option to inquire

References fed, and helicsFederateGetIntegerProperty().

◆ getName()

const char* helicscpp::Federate::getName ( ) const
inline

get the federate name

References fed, and helicsFederateGetName().

◆ getObject()

HelicsFederate helicscpp::Federate::getObject ( ) const
inline

get the C object for use in the C library

References fed.

Referenced by helicscpp::Message::newMessageObject().

◆ getTag()

const char* helicscpp::Federate::getTag ( const std::string &  tag) const
inline

get the value of a specific tag (key-value pair) for a federate

the tag is an arbitrary user defined string and value; the tags for a federate are queryable

Parameters
tagthe name of the tag to get the value for
Returns
a const char * containing the text value of the tag, if the tag is not defined the value is a length 0 string

References fed, and helicsFederateGetTag().

◆ getTimeProperty()

HelicsTime helicscpp::Federate::getTimeProperty ( int  tProperty) const
inline

get the value of a time option for the federate

Parameters
tPropertythe option to get

References fed, and helicsFederateGetTimeProperty().

◆ globalError()

void helicscpp::Federate::globalError ( int  errorCode,
const std::string &  errorString 
)
inline

generate a global error to terminate the federation

Parameters
errorCodean error code to give to the error
errorStringa string message associated with the error

References fed, and helicsFederateGlobalError().

◆ isAsyncOperationCompleted()

bool helicscpp::Federate::isAsyncOperationCompleted ( ) const
inline

called after one of the async calls and will indicate true if an async operation has completed

this should only be called from the same thread as the one that called the initial async call and will return false if called when no async operation is in flight

References fed, HELICS_FALSE, and helicsFederateIsAsyncOperationCompleted().

◆ localError()

void helicscpp::Federate::localError ( int  errorCode,
const std::string &  errorString 
)
inline

generate a local federate error

Parameters
errorCodean error code to give to the error
errorStringa string message associated with the error

References fed, and helicsFederateLocalError().

◆ logDebugMessage()

void helicscpp::Federate::logDebugMessage ( const std::string &  message)
inline

log a debug message

References fed, and helicsFederateLogDebugMessage().

◆ logErrorMessage()

void helicscpp::Federate::logErrorMessage ( const std::string &  message)
inline

log an error message

References fed, and helicsFederateLogErrorMessage().

◆ logInfoMessage()

void helicscpp::Federate::logInfoMessage ( const std::string &  message)
inline

log an info message

References fed, and helicsFederateLogInfoMessage().

◆ logMessage()

void helicscpp::Federate::logMessage ( int  level,
const std::string &  message 
)
inline

log a message with a specified log level

References fed, and helicsFederateLogLevelMessage().

◆ logWarningMessage()

void helicscpp::Federate::logWarningMessage ( const std::string &  message)
inline

log a warning message

References fed, and helicsFederateLogWarningMessage().

◆ operator HelicsFederate()

helicscpp::Federate::operator HelicsFederate ( ) const
inline

cast operator to get the underlying HelicsFederate object

References fed.

◆ protect()

void helicscpp::Federate::protect ( )
inline

protect the federate and make it retrievable even if not library objects exist

References fed, helicsFederateGetName(), and helicsFederateProtect().

◆ query() [1/2]

std::string helicscpp::Federate::query ( const std::string &  queryStr,
HelicsSequencingModes  mode = HELICS_SEQUENCING_MODE_FAST 
) const
inline

make a query of the federate

this call is blocking until the value is returned which may take some time depending on the size of the federation and the specific string being queried, query without a target assumes the target is the federate

Parameters
queryStra string with the query, see other documentation for specific properties to query, can be defined by the federate
modethe ordering mode to use for the query (fast for priority channels, ordered for normal channels ordered with all other messages)
Returns
a string with the value requested. this is either going to be a vector of strings value or a JSON string stored in the first element of the vector. The string "#invalid" is returned if the query was not valid

References fed, HELICS_SEQUENCING_MODE_FAST, helicsCreateQuery(), helicsQueryExecute(), helicsQueryFree(), and helicsQuerySetOrdering().

◆ query() [2/2]

std::string helicscpp::Federate::query ( const std::string &  target,
const std::string &  queryStr,
HelicsSequencingModes  mode = HELICS_SEQUENCING_MODE_FAST 
) const
inline

make a query of the federate

this call is blocking until the value is returned which make take some time depending on the size of the federation and the specific string being queried

Parameters
targetthe target of the query can be "federation", "federate", "broker", "core", or a specific name of a federate, core, or broker
queryStra string with the query see other documentation for specific properties to query, can be defined by the federate
modethe ordering mode to use for the query (fast for priority channels, ordered for normal channels ordered with all other messages)
Returns
a string with the value requested. this is either going to be a vector of strings value or a JSON string stored in the first element of the vector. The string "#invalid" is returned if the query was not valid

References fed, HELICS_SEQUENCING_MODE_FAST, helicsCreateQuery(), helicsQueryExecute(), helicsQueryFree(), and helicsQuerySetOrdering().

◆ registerCloningFilter()

CloningFilter helicscpp::Federate::registerCloningFilter ( const std::string &  deliveryEndpoint)
inline

create a cloning Filter on the specified federate

cloning filters copy a message and send it to multiple locations source and destination can be added through other functions

Parameters
deliveryEndpointthe specified endpoint to deliver the message
Returns
a HelicsFilter object

References fed, and helicsFederateRegisterCloningFilter().

◆ registerFilter()

Filter helicscpp::Federate::registerFilter ( HelicsFilterTypes  type,
const std::string &  filterName = std::string() 
)
inline

define a filter interface

a filter will modify messages coming from or going to target endpoints

Parameters
typethe type of the filter to register
filterNamethe name of the filter

References fed, and helicsFederateRegisterFilter().

◆ registerGlobalCloningFilter()

CloningFilter helicscpp::Federate::registerGlobalCloningFilter ( const std::string &  deliveryEndpoint)
inline

create a cloning Filter on the specified federate

cloning filters copy a message and send it to multiple locations source and destination can be added through other functions

Parameters
deliveryEndpointthe specified endpoint to deliver the message
Returns
a CloningFilter object

References fed, and helicsFederateRegisterGlobalCloningFilter().

◆ registerGlobalFilter()

Filter helicscpp::Federate::registerGlobalFilter ( HelicsFilterTypes  type,
const std::string &  filterName = std::string() 
)
inline

define a filter interface

a filter will modify messages coming from or going to target endpoints

Parameters
typethe type of the filter to register
filterNamethe name of the filter

References fed, and helicsFederateRegisterGlobalFilter().

◆ registerInterfaces()

void helicscpp::Federate::registerInterfaces ( const std::string &  configString)
inline

register a set of interfaces defined in a file

call is only valid in startup mode

Parameters
configStringthe location of the file or config String to load to generate the interfaces

References fed, and helicsFederateRegisterInterfaces().

◆ requestNextStep()

HelicsTime helicscpp::Federate::requestNextStep ( )
inline

request a time advancement to the next allowed time

Returns
the granted time step

References fed, and helicsFederateRequestNextStep().

◆ requestTime()

HelicsTime helicscpp::Federate::requestTime ( HelicsTime  time)
inline

request a time advancement

Parameters
timethe next requested time step
Returns
the granted time step

References fed, and helicsFederateRequestTime().

◆ requestTimeAdvance()

HelicsTime helicscpp::Federate::requestTimeAdvance ( HelicsTime  timeDelta)
inline

request a time advancement to the next allowed time

Parameters
timeDeltathe amount of time requested to advance
Returns
the granted time step

References fed, and helicsFederateRequestTimeAdvance().

◆ requestTimeAsync()

void helicscpp::Federate::requestTimeAsync ( HelicsTime  time)
inline

request a time advancement and return immediately for asynchronous function.

/ref requestTimeComplete should be called to finish the operation and get the result

Parameters
timethe next requested time step

References fed, and helicsFederateRequestTimeAsync().

◆ requestTimeComplete()

HelicsTime helicscpp::Federate::requestTimeComplete ( )
inline

request a time advancement

Returns
the granted time step

References fed, and helicsFederateRequestTimeComplete().

◆ requestTimeIterative()

HelicsIterationTime helicscpp::Federate::requestTimeIterative ( HelicsTime  time,
HelicsIterationRequest  iterate 
)
inline

request a time advancement

Parameters
timethe next requested time step
iteratea requested iteration mode
Returns
the granted time step in a structure containing a return time and an IterationResult

References fed, helicscpp::HelicsIterationTime::grantedTime, helicsFederateRequestTimeIterative(), and helicscpp::HelicsIterationTime::status.

◆ requestTimeIterativeAsync()

void helicscpp::Federate::requestTimeIterativeAsync ( HelicsTime  time,
HelicsIterationRequest  iterate 
)
inline

request a time advancement with iterative call and return for asynchronous function.

/ref requestTimeIterativeComplete should be called to finish the operation and get the result

Parameters
timethe next requested time step
iteratea requested iteration level (none, require, optional)

References fed, and helicsFederateRequestTimeIterativeAsync().

◆ requestTimeIterativeComplete()

HelicsIterationTime helicscpp::Federate::requestTimeIterativeComplete ( )
inline

finalize the time advancement request

Returns
the granted time step in an iteration_time structure which contains a time and iteration result

References fed, helicscpp::HelicsIterationTime::grantedTime, helicsFederateRequestTimeIterativeComplete(), and helicscpp::HelicsIterationTime::status.

◆ sendCommand()

void helicscpp::Federate::sendCommand ( const std::string &  target,
const std::string &  cmd 
)
inline

Send a command to another HELICS object through a federate.

Parameters
targetThe name of the object to send the command to.
cmdThe command to send.

References fed, and helicsFederateSendCommand().

◆ setFlagOption()

void helicscpp::Federate::setFlagOption ( int  flag,
bool  flagValue = true 
)
inline

set a flag for the federate

Parameters
flagan index into the flag /ref flag-definitions.h
flagValuethe value of the flag defaults to true

References fed, HELICS_FALSE, HELICS_TRUE, and helicsFederateSetFlagOption().

◆ setGlobal()

void helicscpp::Federate::setGlobal ( const std::string &  valueName,
const std::string &  value 
)
inline

set a federation global value

this overwrites any previous value for this name

Parameters
valueNamethe name of the global to set
valuethe value of the global

References fed, and helicsFederateSetGlobal().

◆ setProperty() [1/2]

void helicscpp::Federate::setProperty ( int  intProperty,
int  value 
)
inline

set an integer option for the federate

Parameters
intPropertyan index of the option to set
valuean integer option value for an integer based property

References fed, and helicsFederateSetIntegerProperty().

◆ setProperty() [2/2]

void helicscpp::Federate::setProperty ( int  tProperty,
HelicsTime  timeValue 
)
inline

set a time property option for the federate

Parameters
tPropertyan index of the option to set
timeValueand integer option value for an integer based property

References fed, and helicsFederateSetTimeProperty().

◆ setSeparator()

void helicscpp::Federate::setSeparator ( char  sep)
inline

specify a separator to use for naming separation between the federate name and the interface name setSeparator('.') will result in future registrations of local endpoints such as fedName.endpoint setSeparator('/') will result in fedName/endpoint the default is '/' any character can be used though many will not make that much sense. This call is not thread safe and should be called before any local interfaces are created otherwise it may not be possible to retrieve them without using the full name. recommended possibilities are ('.','/', ':','-','_')

References fed, and helicsFederateSetSeparator().

◆ setTag()

void helicscpp::Federate::setTag ( const std::string &  tag,
const std::string &  value 
)
inline

set a tag (key-value pair) for a federate

the tag is an arbitrary user defined string and value; the tags for a federate are queryable through a "tags" query or "tag/<tagname>"

Parameters
tagthe name of the tag to set the value for
valuethe value for the given tag

References fed, and helicsFederateSetTag().

◆ unProtect()

void helicscpp::Federate::unProtect ( )
inline

unprotect the federate and make it retrievable even if not library objects exist

References fed, helicsFederateGetName(), and helicsFederateUnProtect().

◆ waitCommand()

const char* helicscpp::Federate::waitCommand ( )
inline

Get a command sent to the federate. Blocks until a command is received.

Returns
A string with the command for the federate, if the string is empty no command is available.

References fed, and helicsFederateWaitCommand().


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