| helics 3.6.1

Public Member Functions | Protected Member Functions | List of all members
helics::ValueFederate Class Reference

`#include <ValueFederate.hpp>`

Inheritance diagram for helics::ValueFederate:

## Public Member Functions
| ValueFederate (std::string_view fedName, const FederateInfo &fedInfo)
| ValueFederate (std::string_view fedName, const std::shared_ptr< Core > &core, const FederateInfo &fedInfo=FederateInfo{})
| ValueFederate (std::string_view fedName, CoreApp &core, const FederateInfo &fedInfo=FederateInfo{})
| ValueFederate (const std::string &configString)
| ValueFederate (std::string_view fedName, const std::string &configString)
| ValueFederate ()
| ValueFederate (bool res)
| ValueFederate (const char *configString)
| ValueFederate (const ValueFederate &fed)=delete
| ValueFederate (ValueFederate &&fed) noexcept
virtual | ~ValueFederate ()
ValueFederate & | operator= (ValueFederate &&fed) noexcept
ValueFederate & | operator= (const ValueFederate &fed)=delete
Publication & | registerPublication (std::string_view name, std::string_view type, std::string_view units=std::string_view{})
template<typename X >
Publication & | registerPublication (std::string_view name, std::string_view units=std::string_view{})
Publication & | registerGlobalPublication (std::string_view name, std::string_view type, std::string_view units=std::string_view{})
template<typename X >
Publication & | registerGlobalPublication (std::string_view name, std::string_view units=std::string_view{})
template<typename X >
Publication & | registerIndexedPublication (std::string_view name, int index1, std::string_view units=std::string_view{})
template<typename X >
Publication & | registerIndexedPublication (std::string_view name, int index1, int index2, std::string_view units=std::string_view{})
Input & | registerInput (std::string_view name, std::string_view type, std::string_view units=std::string_view{})
Input & | registerGlobalInput (std::string_view name, std::string_view type, std::string_view units=std::string_view{})
template<typename X >
Input & | registerInput (std::string_view name, std::string_view units=std::string_view{})
template<typename X >
Input & | registerGlobalInput (std::string_view name, std::string_view units=std::string_view{})
template<typename X >
Input & | registerIndexedInput (std::string_view name, int index1, std::string_view units=std::string_view())
template<typename X >
Input & | registerIndexedInput (std::string_view name, int index1, int index2, std::string_view units=std::string_view())
Input & | registerSubscription (std::string_view target, std::string_view units=std::string_view{})
Input & | registerIndexedSubscription (std::string_view target, int index1, std::string_view units=std::string_view{})
Input & | registerIndexedSubscription (std::string_view target, int index1, int index2, std::string_view units=std::string_view{})
void | addAlias (const Input &inp, std::string_view shortcutName)
void | addAlias (const Publication &pub, std::string_view shortcutName)
virtual void | setFlagOption (int flag, bool flagValue=true) override
void | setDefaultValue (const Input &inp, data_view block)
virtual void | registerInterfaces (const std::string &configString) override
void | registerValueInterfaces (const std::string &configString)
data_view | getBytes (const Input &inp)
bool | forceCoreUpdate (Input &inp)
void | publishBytes (const Publication &pub, data_view block)
void | publishBytes (const Publication &pub, const char *data, size_t data_size)
void | registerFromPublicationJSON (const std::string &jsonString)
void | publishJSON (const std::string &jsonString)
void | addTarget (const Publication &pub, std::string_view target)
void | addTarget (const Input &inp, std::string_view target)
void | removeTarget (const Publication &pub, std::string_view target)
void | removeTarget (const Input &inp, std::string_view target)
template<class iType >
void | addIndexedTarget (const iType &iObject, std::string_view target, int index1)
template<class iType >
void | addIndexedTarget (const iType &iObject, std::string_view target, int index1, int index2)
bool | isUpdated (const Input &inp) const
Time | getLastUpdateTime (const Input &inp) const
virtual void | disconnect () override
void | clearUpdates ()
void | clearUpdate (const Input &inp)
std::vector< int > | queryUpdates ()
const std::string & | getTarget (const Input &inp) const
const Input & | getInput (std::string_view name) const
Input & | getInput (std::string_view name)
const Input & | getInput (int index) const
Input & | getInput (int index)
const Input & | getInput (std::string_view name, int index1) const
const Input & | getInput (std::string_view name, int index1, int index2) const
const Input & | getSubscription (std::string_view target) const
Input & | getSubscription (std::string_view target)
const Input & | getInputByTarget (std::string_view target) const
Input & | getInputByTarget (std::string_view target)
Publication & | getPublication (std::string_view name)
const Publication & | getPublication (std::string_view name) const
Publication & | getPublication (int index)
const Publication & | getPublication (int index) const
const Publication & | getPublication (std::string_view name, int index1) const
const Publication & | getPublication (std::string_view name, int index1, int index2) const
void | setInputNotificationCallback (std::function< void(Input &, Time)> callback)
void | setInputNotificationCallback (Input &inp, std::function< void(Input &, Time)> callback)
int | getPublicationCount () const
int | getInputCount () const
void | addAlias (std::string_view interfaceName, std::string_view alias)
Public Member Functions inherited from helics::Federate
| Federate (std::string_view fedname, const FederateInfo &fedInfo)
| Federate (std::string_view fedname, const std::shared_ptr< Core > &core, const FederateInfo &fedInfo=FederateInfo{})
| Federate (std::string_view fedname, CoreApp &core, const FederateInfo &fedInfo=FederateInfo{})
| Federate (const std::string &configString)
| Federate (std::string_view fedname, const std::string &configString)
| Federate () noexcept
| Federate (Federate &&fed) noexcept
| Federate (const Federate &fed)=delete
virtual | ~Federate ()
Federate & | operator= (Federate &&fed) noexcept
Federate & | operator= (const Federate &fed)=delete
void | enterInitializingMode ()
void | enterInitializingModeAsync ()
bool | isAsyncOperationCompleted () const
void | enterInitializingModeComplete ()
void | enterInitializingModeIterative ()
void | enterInitializingModeIterativeAsync ()
void | enterInitializingModeIterativeComplete ()
IterationResult | enterExecutingMode (IterationRequest iterate=IterationRequest::NO_ITERATIONS)
void | enterExecutingModeAsync (IterationRequest iterate=IterationRequest::NO_ITERATIONS)
IterationResult | enterExecutingModeComplete ()
void | finalize ()
void | finalizeAsync ()
void | finalizeComplete ()
void | processCommunication (std::chrono::milliseconds period=std::chrono::milliseconds(0))
void | localError (int errorcode, std::string_view message)
void | globalError (int errorcode, std::string_view message)
void | localError (int errorcode)
void | globalError (int errorcode)
void | setSeparator (char separator)
Time | requestTime (Time nextInternalTimeStep)
Time | requestNextStep ()
Time | requestTimeAdvance (Time timeDelta)
iteration_time | requestTimeIterative (Time nextInternalTimeStep, IterationRequest iterate)
void | requestTimeAsync (Time nextInternalTimeStep)
void | requestTimeIterativeAsync (Time nextInternalTimeStep, IterationRequest iterate)
Time | requestTimeComplete ()
iteration_time | requestTimeIterativeComplete ()
void | setTag (std::string_view tag, std::string_view value)
const std::string & | getTag (std::string_view tag) const
virtual void | setProperty (int32_t option, double timeValue)
virtual void | setProperty (int32_t option, Time timeValue)
virtual void | setProperty (int32_t option, int32_t optionValue)
virtual Time | getTimeProperty (int32_t option) const
virtual bool | getFlagOption (int flag) const
virtual int | getIntegerProperty (int32_t option) const
void | setLoggingCallback (const std::function< void(int, std::string_view, std::string_view)> &logFunction)
void | setInitializingEntryCallback (std::function< void(bool)> callback)
void | setExecutingEntryCallback (std::function< void()> callback)
void | setTimeRequestEntryCallback (std::function< void(Time, Time, bool)> callback)
void | setTimeUpdateCallback (std::function< void(Time, bool)> callback)
void | setModeUpdateCallback (std::function< void(Modes, Modes)> callback)
void | setTimeRequestReturnCallback (std::function< void(Time, bool)> callback)
void | setCosimulationTerminatedCallback (std::function< void()> callback)
void | setErrorHandlerCallback (std::function< void(int, std::string_view)> errorHandlerCallback)
std::string | query (std::string_view target, std::string_view queryStr, HelicsSequencingModes mode=HELICS_SEQUENCING_MODE_FAST)
std::string | query (std::string_view queryStr, HelicsSequencingModes mode=HELICS_SEQUENCING_MODE_FAST)
QueryId | queryAsync (std::string_view target, std::string_view queryStr, HelicsSequencingModes mode=HELICS_SEQUENCING_MODE_FAST)
QueryId | queryAsync (std::string_view queryStr, HelicsSequencingModes mode=HELICS_SEQUENCING_MODE_FAST)
std::string | queryComplete (QueryId queryIndex)
bool | isQueryCompleted (QueryId queryIndex) const
void | setQueryCallback (const std::function< std::string(std::string_view)> &queryFunction)
void | setGlobal (std::string_view valueName, std::string_view value)
void | addAlias (std::string_view interfaceName, std::string_view alias)
void | sendCommand (std::string_view target, std::string_view commandStr, HelicsSequencingModes mode=HelicsSequencingModes::HELICS_SEQUENCING_MODE_FAST)
std::pair< std::string, std::string > | getCommand ()
std::pair< std::string, std::string > | waitCommand ()
void | addDependency (std::string_view fedName)
Filter & | registerGlobalFilter (std::string_view filterName, std::string_view inputType=std::string_view{}, std::string_view outputType=std::string_view{})
CloningFilter & | registerGlobalCloningFilter (std::string_view filterName, std::string_view inputType=std::string_view{}, std::string_view outputType=std::string_view{})
Filter & | registerFilter (std::string_view filterName, std::string_view inputType=std::string_view{}, std::string_view outputType=std::string_view{})
CloningFilter & | registerCloningFilter (std::string_view filterName, std::string_view inputType=std::string_view{}, std::string_view outputType=std::string_view{})
Filter & | registerFilter ()
Translator & | registerGlobalTranslator (std::int32_t translatorType, std::string_view translatorName, std::string_view endpointType=std::string_view{}, std::string_view units=std::string_view{})
Translator & | registerTranslator (std::int32_t translatorType, std::string_view translatorName, std::string_view endpointType=std::string_view{}, std::string_view units=std::string_view{})
Translator & | registerGlobalTranslator (std::string_view translatorName, std::string_view endpointType=std::string_view{}, std::string_view units=std::string_view{})
Translator & | registerTranslator (std::string_view translatorName, std::string_view endpointType=std::string_view{}, std::string_view units=std::string_view{})
Translator & | registerTranslator ()
CloningFilter & | registerCloningFilter ()
const Filter & | getFilter (std::string_view filterName) const
const Filter & | getFilter (int index) const
Filter & | getFilter (std::string_view filterName)
Filter & | getFilter (int index)
int | getFilterCount () const
const Translator & | getTranslator (std::string_view translatorName) const
const Translator & | getTranslator (int index) const
Translator & | getTranslator (std::string_view translatorName)
Translator & | getTranslator (int index)
int | getTranslatorCount () const
const std::string & | getConfigFile () const
void | registerConnectorInterfaces (const std::string &configString)
void | registerFilterInterfaces (const std::string &configString)
auto | getID () const noexcept
Modes | getCurrentMode () const noexcept
Time | getCurrentTime () const noexcept
const std::string & | getName () const
const std::shared_ptr< Core > & | getCorePointer ()
void | logMessage (int level, std::string_view message) const
void | logErrorMessage (std::string_view message) const
void | logWarningMessage (std::string_view message) const
void | logInfoMessage (std::string_view message) const
void | logDebugMessage (std::string_view message) const
void | completeOperation ()

## Protected Member Functions
virtual void | updateTime (Time newTime, Time oldTime) override
virtual void | startupToInitializeStateTransition () override
virtual void | initializeToExecuteStateTransition (iteration_time result) override
virtual std::string | localQuery (std::string_view queryStr) const override
Protected Member Functions inherited from helics::Federate
void | enteringInitializingMode (IterationResult iterating)
void | enteringExecutingMode (iteration_time res)
void | finalizeOperations ()
void | preTimeRequestOperations (Time nextStep, bool iterating)
void | postTimeRequestOperations (Time newTime, bool iterating)
virtual void | disconnectTransition ()
std::string | localNameGenerator (std::string_view addition) const
void | handleError (int errorCode, std::string_view errorString, bool noThrow)
void | setAsyncCheck (std::function< bool()> asyncCheck)

## Additional Inherited Members
Public Types inherited from helics::Federate
enum class | Modes : char { STARTUP = 0 , INITIALIZING = 1 , EXECUTING = 2 , FINALIZE = 3 , ERROR_STATE = 4 , PENDING_INIT = 5 , PENDING_EXEC = 6 , PENDING_TIME = 7 , PENDING_ITERATIVE_TIME = 8 , PENDING_FINALIZE = 9 , FINISHED = 10 , PENDING_ITERATIVE_INIT = 12 }
Static Public Member Functions inherited from helics::Federate
static void | setFilterOperator (Filter &filt, std::shared_ptr< FilterOperator > filtOp)
| register a operator for the specified filter More...
static void | setTranslatorOperator (Translator &trans, std::shared_ptr< TranslatorOperator > transOp)
| register an operator for the specified translator More...
Protected Attributes inherited from helics::Federate
std::atomic< Modes > | currentMode {Modes::STARTUP}
| the current state of the simulation
char | nameSegmentSeparator = '/'
| the separator between automatically prependend names
bool | strictConfigChecking {true}
bool | useJsonSerialization {false}
bool | observerMode {false}
bool | retriggerTimeRequest {false}
bool | singleThreadFederate {false}
bool | hasPotentialInterfaces {false}
std::shared_ptr< Core > | coreObject
| reference to the core simulation API
Time | mCurrentTime = Time::minVal()
| the current simulation time
Time | mStopTime = Time::maxVal()
| the stopping time for the federate
std::string | configFile
| any config file used

## Detailed Description

class defining the value based interface

## Constructor & Destructor Documentation

## ◆ ValueFederate() [1/10]

helics::ValueFederate::ValueFederate | ( | std::string_view | fedName,
|  | const FederateInfo & | fedInfo
| ) |  |

constructor taking a federate information structure and using the default core

Parameters

  fedName | the name of the federate, can be empty to use the name from fedInfo or an auto generated one
  fedInfo | a federate information structure

constructor taking a core engine and federate info structure

## ◆ ValueFederate() [2/10]

helics::ValueFederate::ValueFederate | ( | std::string_view | fedName,
|  | const std::shared_ptr< Core > & | core,
|  | const FederateInfo & | fedInfo = `FederateInfo{}`
| ) |  |

constructor taking a core and a federate information structure, core information in fedInfo is ignored

Parameters

  fedName | the name of the federate, can be empty to use the name from fedInfo or an auto generated one
  core | a shared ptr to a core to join
  fedInfo | a federate information structure

## ◆ ValueFederate() [3/10]

helics::ValueFederate::ValueFederate | ( | std::string_view | fedName,
|  | CoreApp & | core,
|  | const FederateInfo & | fedInfo = `FederateInfo{}`
| ) |  |

constructor taking a CoreApp and a federate information structure

Parameters

  fedName | the name of the federate can be empty to use a name from the federateInfo
  core | a CoreApp with the core to connect to.
  fedInfo | a federate information structure

## ◆ ValueFederate() [4/10]

helics::ValueFederate::ValueFederate | ( | const std::string & | configString | ) |
| explicit

constructor taking a string with the required information

Parameters

  configString | can be either a JSON file a TOML file (with extension TOML) or a string containing JSON code

## ◆ ValueFederate() [5/10]

helics::ValueFederate::ValueFederate | ( | std::string_view | fedName,
|  | const std::string & | configString
| ) |  |

constructor taking a name and a string with the required information

Parameters

  fedName | the name of the federate, can be empty to use the name from the configString
  configString | can be either a JSON file a TOML file (with extension TOML) or a string containing JSON code or a string with command line arguments

## ◆ ValueFederate() [6/10]

helics::ValueFederate::ValueFederate | ( |  | ) |
| explicit default

default constructor

## ◆ ValueFederate() [7/10]

helics::ValueFederate::ValueFederate | ( | bool | res | ) |
| explicit

special constructor called by child class to initialize the class vs the default constructor

## ◆ ValueFederate() [8/10]

helics::ValueFederate::ValueFederate | ( | const char * | configString | ) |
| explicit

this is an overload for the string operation to deconflict with the bool version

## ◆ ValueFederate() [9/10]

helics::ValueFederate::ValueFederate | ( | const ValueFederate & | fed | ) |
| delete

federate is not copyable

## ◆ ValueFederate() [10/10]

helics::ValueFederate::ValueFederate | ( | ValueFederate && | fed | ) |
| default noexcept

default move constructor

## ◆ ~ValueFederate()

helics::ValueFederate::~ValueFederate | ( |  | ) |
| virtual default

destructor

## Member Function Documentation

## ◆ addAlias() [1/3]

void helics::ValueFederate::addAlias | ( | const Input & | inp,
|  | std::string_view | shortcutName
| ) |  |

add a shortcut for locating an input

primarily for use in looking up an id from a different location creates a local shortcut for referring to a input which may not have another name

Parameters

  inp | the input object
  shortcutName | the name of the shortcut

## ◆ addAlias() [2/3]

void helics::ValueFederate::addAlias | ( | const Publication & | pub,
|  | std::string_view | shortcutName
| ) |  |

add a shortcut for locating a publication

primarily for use in looking up an id from a different location creates a local shortcut for referring to a publication which may not have another name

Parameters

  pub | the publication object
  shortcutName | the name of the shortcut

## ◆ addAlias() [3/3]

void helics::Federate::addAlias

add a global alias for an interface

Parameters

  interfaceName | the given name of the interface
  alias | the new name by which the interface can be referenced

## ◆ addIndexedTarget() [1/2]

template<class iType >

void helics::ValueFederate::addIndexedTarget | ( | const iType & | iObject,
|  | std::string_view | target,
|  | int | index1
| ) |  |
| inline

add a 1-d Indexed target to an interface

call is only valid in startup mode, register an optional subscription for a 1D array of values

Parameters

  iObject | an interface object to add the target to
  target | the name of the target
  index1 | the index into a 1 dimensional array of values

## ◆ addIndexedTarget() [2/2]

template<class iType >

void helics::ValueFederate::addIndexedTarget | ( | const iType & | iObject,
|  | std::string_view | target,
|  | int | index1,
|  | int | index2
| ) |  |
| inline

add an indexed target to an interface

call is only valid in startup mode

Parameters

  iObject | an interface object such as a publication, filter or input
  target | the name of the target
  index1 | the first index of a 2-D value structure
  index2 | the 2nd index of a 2-D value structure

## ◆ addTarget() [1/2]

void helics::ValueFederate::addTarget | ( | const Input & | inp,
|  | std::string_view | target
| ) |  |

add a source target to an input/subscription

Parameters

  inp | the input object to add a named publication
  target | the name of the publication to get data from

## ◆ addTarget() [2/2]

void helics::ValueFederate::addTarget | ( | const Publication & | pub,
|  | std::string_view | target
| ) |  |

add a destination target to a publication

Parameters

  pub | the publication object to add a target to
  target | the name of the input to send the data to

Referenced by helics::Input::addPublication().

## ◆ clearUpdate()

void helics::ValueFederate::clearUpdate | ( | const Input & | inp | ) |

clear all the update for a specific federate

after this call isUpdated on the input will return false

Referenced by helics::Input::clearUpdate().

## ◆ clearUpdates()

void helics::ValueFederate::clearUpdates | ( |  | ) |

clear all the updates

after this call isUpdated on all the internal objects will return false

## ◆ disconnect()

void helics::ValueFederate::disconnect | ( |  | ) |
| override virtual

disconnect a simulation from the core (will also call finalize before disconnecting if necessary)

Reimplemented from helics::Federate.

Reimplemented in helics::CombinationFederate.

References helics::Federate::disconnect().

Referenced by helics::CombinationFederate::disconnect().

## ◆ forceCoreUpdate()

bool helics::ValueFederate::forceCoreUpdate | ( | Input & | inp | ) |

force an input to get Data From the Core

Parameters

  inp | an input object to get the data from

Returns
  true if the value was registered as an update, which will be true in most cases

Exceptions

  std::invalid_argument | if id is invalid

## ◆ getBytes()

data_view helics::ValueFederate::getBytes | ( | const Input & | inp | ) |

get a value as raw data block from the system

Parameters

  inp | an input object to get the data from

Returns
  a constant data block

Exceptions

  std::invalid_argument | if id is invalid

Referenced by helics::Input::checkUpdate(), helics::Input::getByteCount(), and helics::Input::getBytes().

## ◆ getInput() [1/6]

Input & helics::ValueFederate::getInput | ( | int | index | ) |

get an input object by index

Returns
  an invalid input object if the target is invalid otherwise a reference to the corresponding input

## ◆ getInput() [2/6]

const Input & helics::ValueFederate::getInput | ( | int | index | ) | const

get an input by index

Returns
  an invalid input object if the index is invalid otherwise a reference to the corresponding input

## ◆ getInput() [3/6]

Input & helics::ValueFederate::getInput | ( | std::string_view | name | ) |

get the id of an input

Returns
  an invalid input object if the target is valid otherwise a reference to the corresponding input

References helics::Federate::localNameGenerator().

## ◆ getInput() [4/6]

const Input & helics::ValueFederate::getInput | ( | std::string_view | name | ) | const

get the id of a subscription

Returns
  an invalid input object if the name is invalid otherwise a reference to the corresponding input

References helics::Federate::localNameGenerator().

## ◆ getInput() [5/6]

const Input & helics::ValueFederate::getInput | ( | std::string_view | name,
|  | int | index1
| ) |  | const

get an indexed input object using the name and index

Returns
  an invalid input object if the target is valid otherwise a reference to the corresponding input

## ◆ getInput() [6/6]

const Input & helics::ValueFederate::getInput | ( | std::string_view | name,
|  | int | index1,
|  | int | index2
| ) |  | const

get an input object from a 2-d vector of inputs

Returns
  an invalid input object if the target is valid otherwise a reference to the corresponding input

## ◆ getInputByTarget() [1/2]

Input & helics::ValueFederate::getInputByTarget | ( | std::string_view | target | ) |

get an input based on target

this will only get the first input with a specific target

Returns
  an invalid input object if the target is not valid, otherwise a reference to the corresponding input

## ◆ getInputByTarget() [2/2]

const Input & helics::ValueFederate::getInputByTarget | ( | std::string_view | target | ) | const

get the input id based on target

Returns
  an invalid input object if the target is not valid, otherwise a reference to the corresponding input

## ◆ getInputCount()

int helics::ValueFederate::getInputCount | ( |  | ) | const

get a count of the number subscriptions registered

## ◆ getLastUpdateTime()

Time helics::ValueFederate::getLastUpdateTime | ( | const Input & | inp | ) | const

get the time of the last update

Referenced by helics::Input::getLastUpdate().

## ◆ getPublication() [1/6]

Publication & helics::ValueFederate::getPublication | ( | int | index | ) |

get a publication from its index

Parameters

  index | the 0 based index of the publication to retrieve

Returns
  an invalid publication if the index is valid otherwise a reference to the corresponding publication

## ◆ getPublication() [2/6]

const Publication & helics::ValueFederate::getPublication | ( | int | index | ) | const

get a publication from its index

Parameters

  index | the 0 based index of the publication to retrieve

Returns
  an invalid publication if the index is valid otherwise the corresponding publication

## ◆ getPublication() [3/6]

Publication & helics::ValueFederate::getPublication | ( | std::string_view | name | ) |

get a publication from its name

Parameters

  name | the name of the publication

Returns
  an invalid publication if the index is valid otherwise a reference to the corresponding publication

References helics::Federate::localNameGenerator().

Referenced by helics::Publication::Publication(), helics::publish(), and publishJSON().

## ◆ getPublication() [4/6]

const Publication & helics::ValueFederate::getPublication | ( | std::string_view | name | ) | const

get a publication from its name

Parameters

  name | the name of the publication

Returns
  an invalid publication if the index is valid otherwise a reference to the corresponding publication

References helics::Federate::localNameGenerator().

## ◆ getPublication() [5/6]

const Publication & helics::ValueFederate::getPublication | ( | std::string_view | name,
|  | int | index1
| ) |  | const

get a publication from its name

Parameters

  name | the name of the publication
  index1 | the index into a vector of publications

Returns
  an invalid publication if the index is valid otherwise the corresponding publication

## ◆ getPublication() [6/6]

const Publication & helics::ValueFederate::getPublication | ( | std::string_view | name,
|  | int | index1,
|  | int | index2
| ) |  | const

get a publication from a 2-d array of publications

Parameters

  name | the name of the publication
  index1 | the first index of 2d array
  index2 | the second index of a 2d array of publications

Returns
  an invalid publication if the index is valid otherwise the corresponding publication

## ◆ getPublicationCount()

int helics::ValueFederate::getPublicationCount | ( |  | ) | const

get a count of the number publications registered

## ◆ getSubscription() [1/2]

Input& helics::ValueFederate::getSubscription | ( | std::string_view | target | ) |
| inline

get an input based on target

this will only get the first input with a specific target

Returns
  an invalid input object if the target is not valid, otherwise a reference to the corresponding input

## ◆ getSubscription() [2/2]

const Input& helics::ValueFederate::getSubscription | ( | std::string_view | target | ) | const
| inline

get the input id based on target

Returns
  an invalid input object if the target is not valid, otherwise a reference to the corresponding input

## ◆ getTarget()

const std::string & helics::ValueFederate::getTarget | ( | const Input & | inp | ) | const

get the name of the first target for an input

Returns
  empty string if an invalid input is passed or it has no target

## ◆ initializeToExecuteStateTransition()

void helics::ValueFederate::initializeToExecuteStateTransition | ( | iteration_time | iterate | ) |
| override protected virtual

function to deal with any operations that need to occur on the transition from startup to initialize

Reimplemented from helics::Federate.

Reimplemented in helics::CombinationFederate.

Referenced by helics::CombinationFederate::initializeToExecuteStateTransition().

## ◆ isUpdated()

bool helics::ValueFederate::isUpdated | ( | const Input & | inp | ) | const

check if a given subscription has an update

Returns
  true if the subscription id is valid and has an update

Referenced by helics::Input::checkUpdate(), and helics::Input::isUpdated().

## ◆ localQuery()

std::string helics::ValueFederate::localQuery | ( | std::string_view | queryStr | ) | const
| override protected virtual

function to generate results for a local Query

should return an empty string if the query is not recognized

Reimplemented from helics::Federate.

Reimplemented in helics::CombinationFederate.

Referenced by helics::CombinationFederate::localQuery().

## ◆ operator=() [1/2]

ValueFederate& helics::ValueFederate::operator= | ( | const ValueFederate & | fed | ) |
| delete

delete copy assignment

## ◆ operator=() [2/2]

ValueFederate & helics::ValueFederate::operator= | ( | ValueFederate && | fed | ) |
| noexcept

default move assignment

References helics::Federate::operator=().

## ◆ publishBytes() [1/2]

void helics::ValueFederate::publishBytes | ( | const Publication & | pub,
|  | const char * | data,
|  | size_t | data_size
| ) |  |
| inline

publish data

Parameters

  pub | the publication identifier
  data | a const char pointer to raw data
  data_size | the length of the data

Exceptions

  invalid_argument | if the publication id is invalid

## ◆ publishBytes() [2/2]

void helics::ValueFederate::publishBytes | ( | const Publication & | pub,
|  | data_view | block
| ) |  |

publish a value

Parameters

  pub | the publication identifier
  block | a data block containing the data

Exceptions

  invalid_argument | if the publication id is invalid

References helics::Federate::currentMode, helics::Federate::EXECUTING, and helics::Federate::INITIALIZING.

Referenced by helics::Publication::publish(), and helics::Publication::publishComplex().

## ◆ publishJSON()

void helics::ValueFederate::publishJSON | ( | const std::string & | jsonString | ) |

publish a set of values in json format

Parameters

  jsonString | a json string containing the data to publish

References getPublication(), and helics::Federate::nameSegmentSeparator.

## ◆ queryUpdates()

std::vector< int > helics::ValueFederate::queryUpdates | ( |  | ) |

get a list of all the indices of all inputs that have been updated since the last call

Returns
  a vector of input indices with all the values that have not been retrieved since updated

## ◆ registerFromPublicationJSON()

void helics::ValueFederate::registerFromPublicationJSON | ( | const std::string & | jsonString | ) |

register a set of publications based on a publication JSON

Parameters

  jsonString | a json string containing the data to publish and establish publications from

References helics::Federate::nameSegmentSeparator.

## ◆ registerGlobalInput() [1/2]

Input & helics::ValueFederate::registerGlobalInput | ( | std::string_view | name,
|  | std::string_view | type,
|  | std::string_view | units = `std::string_view{}`
| ) |  |

register a globally named input

call is only valid in startup mode

Parameters

  name | the name of the input(can be blank in which case it is the same as a subscription
  type | a string defining the type of the input
  units | a string defining the units of the input [optional]

Returns
  a input id object for use as an identifier

## ◆ registerGlobalInput() [2/2]

template<typename X >

Input& helics::ValueFederate::registerGlobalInput | ( | std::string_view | name,
|  | std::string_view | units = `std::string_view{}`
| ) |  |
| inline

register a global named input

## ◆ registerGlobalPublication() [1/2]

Publication & helics::ValueFederate::registerGlobalPublication | ( | std::string_view | name,
|  | std::string_view | type,
|  | std::string_view | units = `std::string_view{}`
| ) |  |

register a publication

call is only valid in startup mode

Parameters

  name | the name of the publication
  type | a string defining the type of the publication
  units | a string defining the units of the publication [optional]

Returns
  a publication object reference for use as an identifier

## ◆ registerGlobalPublication() [2/2]

template<typename X >

Publication& helics::ValueFederate::registerGlobalPublication | ( | std::string_view | name,
|  | std::string_view | units = `std::string_view{}`
| ) |  |
| inline

register a publication

call is only valid in startup mode by default prepends the name with the federate name

Parameters

  name | the name of the publication
  units | the optional units of the publication

Returns
  an identifier for use with this publication

## ◆ registerIndexedInput() [1/2]

template<typename X >

Input& helics::ValueFederate::registerIndexedInput | ( | std::string_view | name,
|  | int | index1,
|  | int | index2,
|  | std::string_view | units = `std::string_view()`
| ) |  |
| inline

register a publication as part of a 2 dimensional indexed structure

call is only valid in startup mode by default prepends the name with the federate name the name is registered as a global structure with the indices appended

Parameters

  name | the name of the publication
  index1 | an index associated with the publication
  index2 | a second index
  units | the optional units of the publication

Returns
  an identifier for use with this publication

## ◆ registerIndexedInput() [2/2]

template<typename X >

Input& helics::ValueFederate::registerIndexedInput | ( | std::string_view | name,
|  | int | index1,
|  | std::string_view | units = `std::string_view()`
| ) |  |
| inline

register a required subscription

call is only valid in startup mode, register an optional subscription for a 1D array of values

Parameters

  name | the name of the subscription
  index1 | the index into a 1 dimensional array of values
  units | the optional units on the subscription

## ◆ registerIndexedPublication() [1/2]

template<typename X >

Publication& helics::ValueFederate::registerIndexedPublication | ( | std::string_view | name,
|  | int | index1,
|  | int | index2,
|  | std::string_view | units = `std::string_view{}`
| ) |  |
| inline

register a publication as part of a 2 dimensional indexed structure

call is only valid in startup mode by default prepends the name with the federate name the name is registered as a global structure with the indices appended

Parameters

  name | the name of the publication
  index1 | an index associated with the publication
  index2 | a second index
  units | the optional units of the publication

Returns
  an identifier for use with this publication

## ◆ registerIndexedPublication() [2/2]

template<typename X >

Publication& helics::ValueFederate::registerIndexedPublication | ( | std::string_view | name,
|  | int | index1,
|  | std::string_view | units = `std::string_view{}`
| ) |  |
| inline

register a publication as part of an indexed structure

call is only valid in startup mode by default prepends the name with the federate name the name is registered as a global structure with the index appended

Parameters

  name | the name of the publication
  index1 | an index associated with the publication
  units | the optional units of the publication

Returns
  an identifier for use with this publication

## ◆ registerIndexedSubscription() [1/2]

Input& helics::ValueFederate::registerIndexedSubscription | ( | std::string_view | target,
|  | int | index1,
|  | int | index2,
|  | std::string_view | units = `std::string_view{}`
| ) |  |
| inline

register a subscription for an index of a 2-D array of values

call is only valid in startup mode

Parameters

  target | the name of the publication to subscribe to
  index1 | the first index of a 2-D value structure
  index2 | the 2nd index of a 2-D value structure
  units | the optional units on the subscription

## ◆ registerIndexedSubscription() [2/2]

Input& helics::ValueFederate::registerIndexedSubscription | ( | std::string_view | target,
|  | int | index1,
|  | std::string_view | units = `std::string_view{}`
| ) |  |
| inline

register a subscription

register a subscription for a 1D array of values

Parameters

  target | the name of the publication to target
  index1 | the index into a 1 dimensional array of values
  units | the optional units on the subscription

Referenced by helics::VectorSubscription2d< X >::VectorSubscription2d().

## ◆ registerInput() [1/2]

Input & helics::ValueFederate::registerInput | ( | std::string_view | name,
|  | std::string_view | type,
|  | std::string_view | units = `std::string_view{}`
| ) |  |

register an input

call is only valid in startup mode register a subscription with name type and units

Parameters

  name | the name of the publication to subscribe to
  type | a string describing the type of the publication
  units | a string describing the units on the publication

References helics::Federate::localNameGenerator().

## ◆ registerInput() [2/2]

template<typename X >

Input& helics::ValueFederate::registerInput | ( | std::string_view | name,
|  | std::string_view | units = `std::string_view{}`
| ) |  |
| inline

register a named input

## ◆ registerInterfaces()

void helics::ValueFederate::registerInterfaces | ( | const std::string & | configString | ) |
| override virtual

register a set of interfaces defined in a file

call is only valid in startup mode to add an TOML files must have extension .toml or .TOML

Parameters

  configString | the location of the file(JSON or TOML) or JSON String to load to generate the interfaces

Reimplemented from helics::Federate.

Reimplemented in helics::CombinationFederate.

References helics::Federate::registerInterfaces(), and registerValueInterfaces().

## ◆ registerPublication() [1/2]

Publication & helics::ValueFederate::registerPublication | ( | std::string_view | name,
|  | std::string_view | type,
|  | std::string_view | units = `std::string_view{}`
| ) |  |

register a publication

call is only valid in startup mode

Parameters

  name | the name of the publication
  type | a string defining the type of the publication
  units | a string defining the units of the publication [optional]

Returns
  a publication id object for use as an identifier

References helics::Federate::localNameGenerator().

Referenced by helics::Publication::Publication().

## ◆ registerPublication() [2/2]

template<typename X >

Publication& helics::ValueFederate::registerPublication | ( | std::string_view | name,
|  | std::string_view | units = `std::string_view{}`
| ) |  |
| inline

register a publication

call is only valid in startup mode by default prepends the name with the federate name

Parameters

  name | the name of the publication
  units | the optional units of the publication

Returns
  an identifier for use with this publication

## ◆ registerSubscription()

Input & helics::ValueFederate::registerSubscription | ( | std::string_view | target,
|  | std::string_view | units = `std::string_view{}`
| ) |  |

register a subscription

Parameters

  target | the name of the publication to subscribe to
  units | the units associated with the desired output

## ◆ registerValueInterfaces()

void helics::ValueFederate::registerValueInterfaces | ( | const std::string & | configString | ) |

register a set of value interfaces (publications and subscriptions)

call is only valid in startup mode it is a protected call to add an TOML files must have extension .toml or .TOML

Parameters

  configString | the location of the file(JSON or TOML) or JSON String to load to generate the interfaces

Referenced by helics::CombinationFederate::registerInterfaces(), and registerInterfaces().

## ◆ removeTarget() [1/2]

void helics::ValueFederate::removeTarget | ( | const Input & | inp,
|  | std::string_view | target
| ) |  |

remove a publication from an input/subscription

Parameters

  inp | the input object to add a named publication
  target | the name of the publication to remove

## ◆ removeTarget() [2/2]

void helics::ValueFederate::removeTarget | ( | const Publication & | pub,
|  | std::string_view | target
| ) |  |

remove a destination target from a publication

Parameters

  pub | the publication object to add a target to
  target | the name of the input to remove

## ◆ setDefaultValue()

void helics::ValueFederate::setDefaultValue | ( | const Input & | inp,
|  | data_view | block
| ) |  |

set the default value for a subscription

this is the value returned prior to any publications

Parameters

  inp | the subscription identifier
  block | the data view representing the default value

Exceptions

  std::invalid_argument | if id is invalid

## ◆ setFlagOption()

void helics::ValueFederate::setFlagOption | ( | int | flag,
|  | bool | flagValue = `true`
| ) |  |
| override virtual

set a flag for the federate

Parameters

  flag | an index into the flag /ref flag-definitions.h
  flagValue | the value of the flag defaults to true

Reimplemented from helics::Federate.

Reimplemented in helics::CombinationFederate.

References HELICS_FLAG_USE_JSON_SERIALIZATION, helics::Federate::setFlagOption(), and helics::Federate::useJsonSerialization.

Referenced by helics::CombinationFederate::setFlagOption().

## ◆ setInputNotificationCallback() [1/2]

void helics::ValueFederate::setInputNotificationCallback | ( | Input & | inp,
|  | std::function< void(Input &, Time)> | callback
| ) |  |

register a callback function to call when the specified subscription is updated

Parameters

  inp | an input to set the notification callback for
  callback | the function to call

## ◆ setInputNotificationCallback() [2/2]

void helics::ValueFederate::setInputNotificationCallback | ( | std::function< void(Input &, Time)> | callback | ) |

register a callback function to call when any subscribed value is updated

there can only be one generic callback

Parameters

  callback | the function to call signature void(Input &, Time)

Referenced by helics::VectorSubscription< X >::operator=(), helics::VectorSubscription2d< X >::operator=(), helics::Input::registerNotificationCallback(), helics::VectorSubscription< X >::VectorSubscription(), and helics::VectorSubscription2d< X >::VectorSubscription2d().

## ◆ startupToInitializeStateTransition()

void helics::ValueFederate::startupToInitializeStateTransition | ( |  | ) |
| override protected virtual

function to deal with any operations that need to occur on the transition from startup to initialize

Reimplemented from helics::Federate.

Reimplemented in helics::CombinationFederate.

Referenced by helics::CombinationFederate::startupToInitializeStateTransition().

## ◆ updateTime()

void helics::ValueFederate::updateTime | ( | Time | newTime,
|  | Time | oldTime
| ) |  |
| override protected virtual

function to deal with any operations that need to occur on a time update

Reimplemented from helics::Federate.

Reimplemented in helics::CombinationFederate.

Referenced by helics::CombinationFederate::updateTime().

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

- application_api/ValueFederate.hpp
- ValueFederate.cpp