| helics 3.6.1

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
helics::ValueFederateManager Class Reference

`#include <ValueFederateManager.hpp>`

## Public Member Functions
| ValueFederateManager (Core *coreOb, ValueFederate *vfed, LocalFederateId id, bool singleThreaded)
Publication & | registerPublication (std::string_view key, std::string_view type, std::string_view units)
Input & | registerInput (std::string_view key, std::string_view type, std::string_view units)
void | addAlias (const Input &inp, std::string_view shortcutName)
void | addAlias (const Publication &pub, std::string_view shortcutName)
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)
void | setDefaultValue (const Input &inp, const data_view &block)
data_view | getValue (const Input &inp)
void | publish (const Publication &pub, const data_view &block)
void | updateTime (Time newTime, Time oldTime)
void | startupToInitializeStateTransition ()
void | initializeToExecuteStateTransition (iteration_time result)
std::string | localQuery (std::string_view queryStr) const
std::vector< int > | queryUpdates ()
const std::string & | getTarget (const Input &inp) const
Input & | getInput (std::string_view key)
const Input & | getInput (std::string_view key) const
Input & | getInput (int index)
const Input & | getInput (int index) const
const Input & | getInputByTarget (std::string_view key) const
Input & | getInputByTarget (std::string_view key)
Publication & | getPublication (std::string_view key)
const Publication & | getPublication (std::string_view key) const
Publication & | getPublication (int index)
const Publication & | getPublication (int index) const
void | setInputNotificationCallback (std::function< void(Input &, Time)> callback)
void | disconnect ()
int | getPublicationCount () const
int | getInputCount () const
void | clearUpdates ()
bool | getUpdateFromCore (Input &inp)

## Static Public Member Functions
static bool | hasUpdate (const Input &inp)
static Time | getLastUpdateTime (const Input &inp)
static void | setInputNotificationCallback (const Input &inp, std::function< void(Input &, Time)> callback)
static void | clearUpdate (const Input &inp)

## Public Attributes
bool | useJsonSerialization {false}
| all outgoing data should be serialized as JSON

## Detailed Description

class handling the implementation details of a value Federate

## Member Function Documentation

## ◆ addAlias() [1/2]

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

add a shortcut for locating a subscription

primarily for use in looking up an id from a different location creates a local shortcut for referring to a subscription which may have a long actual name

Parameters

  inp | the subscription identifier
  shortcutName | the name of the shortcut

References helics::Interface::getName(), helics::Interface::handle, and helics::Interface::isValid().

## ◆ addAlias() [2/2]

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

add a alias/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 subscription which may have a long actual name

Parameters

  pub | the subscription identifier
  shortcutName | the name of the shortcut

References helics::Interface::getName(), helics::Interface::handle, and helics::Interface::isValid().

## ◆ addTarget() [1/2]

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

add a source target to an input/subscription

Parameters

  inp | the identifier of the publication
  target | the name of the input to send the data to

References helics::Input::getDisplayName(), and helics::Interface::handle.

## ◆ addTarget() [2/2]

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

add a destination target to a publication

Parameters

  pub | the identifier of the input
  target | the name of the input to send the data to

References helics::Interface::handle.

## ◆ clearUpdate()

void helics::ValueFederateManager::clearUpdate | ( | const Input & | inp | ) |
| static

clear an input value as updated without actually retrieving it

Parameters

  inp | the identifier for the subscription

References helics::InputData::hasUpdate.

## ◆ clearUpdates()

void helics::ValueFederateManager::clearUpdates | ( |  | ) |

clear all the updates

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

References helics::Input::clearUpdate().

## ◆ disconnect()

void helics::ValueFederateManager::disconnect | ( |  | ) |

disconnect from the coreObject

disconnect to an empty Core which does nothing

## ◆ getInput() [1/2]

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

get an input by index

References helics::isValidIndex().

## ◆ getInput() [2/2]

Input & helics::ValueFederateManager::getInput | ( | std::string_view | key | ) |

get an Input from Its Name

Parameters

  key | the identifier or shortcut of the input

Returns
  an empty Input if name is not a recognized

## ◆ getInputByTarget()

const Input & helics::ValueFederateManager::getInputByTarget | ( | std::string_view | key | ) | const

get the id of an by the target name

Parameters

  key | the target of a input

Returns
  an invalid input if the target is not found

## ◆ getInputCount()

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

get a count of the number subscriptions registered

get a count of the number inputs registered

## ◆ getLastUpdateTime()

Time helics::ValueFederateManager::getLastUpdateTime | ( | const Input & | inp | ) |
| static

get the time of the last update

References helics::InputData::lastUpdate.

## ◆ getPublication()

Publication & helics::ValueFederateManager::getPublication | ( | std::string_view | key | ) |

get a publication based on its key

Parameters

  key | the publication id

Returns
  ivalid_publication_id if name is not recognized otherwise returns the publication_id

## ◆ getPublicationCount()

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

get a count of the number publications registered

## ◆ getTarget()

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

get the target of a input

References helics::Interface::handle.

## ◆ getValue()

data_view helics::ValueFederateManager::getValue | ( | const Input & | inp | ) |

get a value as raw data block from the system

Parameters

  inp | the identifier for the subscription

Returns
  a constant data block

References helics::InputData::lastQuery.

## ◆ hasUpdate()

bool helics::ValueFederateManager::hasUpdate | ( | const Input & | inp | ) |
| static

check if a given subscription has and update

References helics::InputData::hasUpdate.

## ◆ initializeToExecuteStateTransition()

void helics::ValueFederateManager::initializeToExecuteStateTransition | ( | iteration_time | result | ) |

transition from initialize to execution State

References helics::iteration_time::grantedTime, and helics::initializationTime.

## ◆ localQuery()

std::string helics::ValueFederateManager::localQuery | ( | std::string_view | queryStr | ) | const

generate results for a local query

References helics::fileops::JsonBuilder::addElement(), helics::Input::checkUpdate(), helics::fileops::JsonBuilder::generate(), helics::Input::getDisplayName(), helics::Input::getHelicsInjectionType(), helics::Input::getHelicsType(), and helics::Input::isUpdated().

## ◆ publish()

void helics::ValueFederateManager::publish | ( | const Publication & | pub,
|  | const data_view & | block
| ) |  |

publish a value

References helics::data_view::data(), helics::Interface::handle, and helics::data_view::size().

## ◆ queryUpdates()

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

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

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

## ◆ registerInput()

Input & helics::ValueFederateManager::registerInput | ( | std::string_view | key,
|  | std::string_view | type,
|  | std::string_view | units
| ) |  |

register a subscription

call is only valid in startup mode

References helics::getCleanedTypeName().

## ◆ removeTarget() [1/2]

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

remove a source target from an input/subscription

Parameters

  inp | the identifier of the publication
  target | the name of the publication to remove

References helics::Interface::handle.

## ◆ removeTarget() [2/2]

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

remove a destination target from a publication

Parameters

  pub | the identifier of the input
  target | the name of the input to remove

References helics::Interface::handle.

## ◆ setDefaultValue()

void helics::ValueFederateManager::setDefaultValue | ( | const Input & | inp,
|  | const 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 block representing the default value

copy the data first since we are not entirely sure of the lifetime of the data_view

References helics::data_view::data(), helics::Interface::isValid(), helics::InputData::lastData, and helics::data_view::size().

## ◆ setInputNotificationCallback() [1/2]

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

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

Parameters

  inp | the id to register the callback for
  callback | the function to call

References helics::InputData::callback.

## ◆ setInputNotificationCallback() [2/2]

void helics::ValueFederateManager::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

## ◆ startupToInitializeStateTransition()

void helics::ValueFederateManager::startupToInitializeStateTransition | ( |  | ) |

transition from Startup To the Initialize State

## ◆ updateTime()

void helics::ValueFederateManager::updateTime | ( | Time | newTime,
|  | Time | oldTime
| ) |  |

update the time from oldTime to newTime

Parameters

  newTime | the newTime of the federate
  oldTime | the oldTime of the federate

find the id

References helics::InputData::lastUpdate.

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

- ValueFederateManager.hpp
- ValueFederateManager.cpp