helics  2.8.1
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 helics_federate () const
 
helics_federate baseObject () const
 
void setFlagOption (int flag, bool flagValue=true)
 
void setProperty (int tProperty, helics_time timeValue)
 
void setProperty (int intProperty, int value)
 
bool getFlagOption (int flag) const
 
helics_time getTimeProperty (int tProperty) const
 
int getIntegerProperty (int intProperty) const
 
void setSeparator (char sep)
 
void registerInterfaces (const std::string &configString)
 
helics_federate_state getCurrentMode () const
 
void enterInitializingMode ()
 
void enterInitializingModeAsync ()
 
bool isAsyncOperationCompleted () const
 
void enterInitializingModeComplete ()
 
helics_iteration_result enterExecutingMode (helics_iteration_request iterate=helics_iteration_request_no_iteration)
 
void enterExecutingModeAsync (helics_iteration_request iterate=helics_iteration_request_no_iteration)
 
helics_iteration_result enterExecutingModeComplete ()
 
void finalize ()
 
void finalizeAsync ()
 
void finalizeComplete ()
 
helics_time getCurrentTime ()
 
helics_time requestTime (helics_time time)
 
helics_time requestNextStep ()
 
helics_time requestTimeAdvance (helics_time timeDelta)
 
helics_iteration_time requestTimeIterative (helics_time time, helics_iteration_request iterate)
 
void requestTimeAsync (helics_time time)
 
void requestTimeIterativeAsync (helics_time time, helics_iteration_request iterate)
 
helics_time requestTimeComplete ()
 
helics_iteration_time requestTimeIterativeComplete ()
 
const char * getName () const
 
std::string query (const std::string &target, const std::string &queryStr, helics_sequencing_mode mode=helics_sequencing_mode_fast) const
 
std::string query (const std::string &queryStr, helics_sequencing_mode mode=helics_sequencing_mode_fast) const
 
void setQueryCallback (void(*queryAnswer)(const char *query, int querySize, helics_query_buffer, void *userdata), void *userdata)
 
Filter registerFilter (helics_filter_type type, const std::string &filterName=std::string())
 
CloningFilter registerCloningFilter (const std::string &deliveryEndpoint)
 
Filter registerGlobalFilter (helics_filter_type type, const std::string &filterName=std::string())
 
CloningFilter registerGlobalCloningFilter (const std::string &deliveryEndpoint)
 
Filter getFilter (const std::string &filterName)
 
Filter getFilter (int index)
 
void setGlobal (const std::string &valueName, const std::string &value)
 
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)
 
helics_core getCore ()
 
helics_federate getObject () const
 

Protected Attributes

helics_federate fed
 underlying helics_federate 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

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

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

get the underlying helics_federate object

References fed.

◆ enterExecutingMode()

helics_iteration_result helicscpp::Federate::enterExecutingMode ( helics_iteration_request  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 ( helics_iteration_request  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()

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

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

◆ getCore()

helics_core helicscpp::Federate::getCore ( )
inline

get a Core Object

References fed, and helicsFederateGetCoreObject().

◆ getCurrentMode()

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

get the current state of the federate

References fed, and helicsFederateGetState().

◆ getCurrentTime()

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

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

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

get the C object for use in the C library

References fed.

◆ getTimeProperty()

helics_time 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

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

References fed, 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 helics_federate()

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

cast operator to get the underlying helics_federate object

References fed.

◆ query() [1/2]

std::string helicscpp::Federate::query ( const std::string &  queryStr,
helics_sequencing_mode  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,
helics_sequencing_mode  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 helics_filter object

References fed, and helicsFederateRegisterCloningFilter().

◆ registerFilter()

Filter helicscpp::Federate::registerFilter ( helics_filter_type  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 ( helics_filter_type  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()

helics_time helicscpp::Federate::requestNextStep ( )
inline

request a time advancement to the next allowed time

Returns
the granted time step

References fed, and helicsFederateRequestNextStep().

◆ requestTime()

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

request a time advancement

Parameters
timethe next requested time step
Returns
the granted time step

References fed, and helicsFederateRequestTime().

◆ requestTimeAdvance()

helics_time helicscpp::Federate::requestTimeAdvance ( helics_time  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 ( helics_time  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()

helics_time helicscpp::Federate::requestTimeComplete ( )
inline

request a time advancement

Returns
the granted time step

References fed, and helicsFederateRequestTimeComplete().

◆ requestTimeIterative()

helics_iteration_time helicscpp::Federate::requestTimeIterative ( helics_time  time,
helics_iteration_request  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 iteration_result

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

◆ requestTimeIterativeAsync()

void helicscpp::Federate::requestTimeIterativeAsync ( helics_time  time,
helics_iteration_request  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()

helics_iteration_time 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::helics_iteration_time::grantedTime, helicsFederateRequestTimeIterativeComplete(), and helicscpp::helics_iteration_time::status.

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


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