helics  2.8.1
Public Member Functions | Protected Attributes | Friends | List of all members
helics::Input Class Reference

#include <Inputs.hpp>

+ Inheritance diagram for helics::Input:

Public Member Functions

 Input ()=default
 
 Input (ValueFederate *valueFed, interface_handle id, const std::string &actName, const std::string &unitsOut=std::string{})
 
 Input (ValueFederate *valueFed, const std::string &key, const std::string &defaultType="def", const std::string &units=std::string{})
 
template<class FedPtr >
 Input (FedPtr &valueFed, const std::string &key, const std::string &defaultType="def", const std::string &units=std::string{})
 
 Input (interface_visibility locality, ValueFederate *valueFed, const std::string &key, const std::string &defaultType="def", const std::string &units=std::string{})
 
template<class FedPtr >
 Input (interface_visibility locality, FedPtr &valueFed, const std::string &name, const std::string &defaultType="def", const std::string &units=std::string{})
 
 Input (ValueFederate *valueFed, const std::string &name, data_type defType, const std::string &units=std::string{})
 
template<class FedPtr >
 Input (FedPtr &valueFed, const std::string &name, data_type defType, const std::string &units=std::string())
 
 Input (interface_visibility locality, ValueFederate *valueFed, const std::string &name, const std::string &units=std::string{})
 
template<class FedPtr >
 Input (interface_visibility locality, FedPtr &valueFed, const std::string &key, const std::string &units=std::string{})
 
 Input (interface_visibility locality, ValueFederate *valueFed, const std::string &name, data_type defType, const std::string &units=std::string{})
 
template<class FedPtr >
 Input (interface_visibility locality, FedPtr &valueFed, const std::string &name, data_type defType, const std::string &units=std::string{})
 
Time getLastUpdate () const
 
interface_handle getHandle () const
 
 operator interface_handle () const
 
bool isValid () const
 
bool operator< (const Input &inp) const
 
bool operator> (const Input &inp) const
 
void registerNotificationCallback (std::function< void(Time)> callback)
 
const std::string & getName () const
 
const std::string & getKey () const
 
const std::string & getDisplayName () const
 
const std::string & getPublicationType () const
 
const std::string & getType () const
 
const std::string & getUnits () const
 
const std::string & getInjectionUnits () const
 
const std::string & getTarget () const
 
void addTarget (const std::string &newTarget)
 
void removeTarget (const std::string &targetToRemove)
 
const std::string & getInfo () const
 
void setInfo (const std::string &info)
 
void setOption (int32_t option, int32_t value=1)
 
int32_t getOption (int32_t option) const
 
bool checkUpdate (bool assumeUpdate=false)
 
void clearUpdate ()
 
bool isUpdated ()
 
bool isUpdated () const
 
template<class X >
void setInputNotificationCallback (std::function< void(const X &, Time)> callback)
 
template<class X >
void setDefault (X &&val)
 
void setMinimumChange (double deltaV) noexcept
 
void enableChangeDetection (bool enabled=true) noexcept
 
int getValue (double *data, int maxsize)
 
int getValue (char *str, int maxsize)
 
template<class X >
void getValue (X &out)
 
template<class X >
auto getValue ()
 
template<class X >
const X & getValueRef ()
 
data_view getRawValue ()
 
size_t getRawSize ()
 
size_t getStringSize ()
 
size_t getVectorSize ()
 
void close ()
 
data_type getHelicsType () const
 
data_type getHelicsInjectionType () const
 
multi_input_handling_method getMultiInputMode () const
 
bool vectorDataProcess (const std::vector< std::shared_ptr< const data_block >> &dataV)
 

Protected Attributes

ValueFederatefed = nullptr
 reference to the value federate
 
interface_handle handle
 the id as generated by the Federate
 

Friends

class ValueFederateManager
 

Detailed Description

base class for a input object

Constructor & Destructor Documentation

◆ Input() [1/2]

helics::Input::Input ( )
default

Default constructor

◆ Input() [2/2]

helics::Input::Input ( ValueFederate valueFed,
interface_handle  id,
const std::string &  actName,
const std::string &  unitsOut = std::string{} 
)

construct from a federate and handle, mainly used by the valueFederateManager

Member Function Documentation

◆ addTarget()

void helics::Input::addTarget ( const std::string &  newTarget)
inline

subscribe to a named publication

References fed.

◆ checkUpdate()

bool helics::Input::checkUpdate ( bool  assumeUpdate = false)

check if the value has been updated

if changeDetection is Enabled this function also loads the value into the buffer

Parameters
assumeUpdateif set to true will assume there was a publication and not check it first, if set to false[default] it will check the federate first
Returns
true if the value has been updated

References fed, helics::ValueFederate::getValueRaw(), and helics::ValueFederate::isUpdated().

Referenced by isUpdated().

◆ clearUpdate()

void helics::Input::clearUpdate ( )

clear the isUpdated flag

References helics::ValueFederate::clearUpdate(), and fed.

◆ close()

void helics::Input::close ( )
inline

close a input during an active simulation

it is not necessary to call this function unless you are continuing the simulation after the close

References fed.

◆ enableChangeDetection()

void helics::Input::enableChangeDetection ( bool  enabled = true)
inlinenoexcept

enable change detection

Parameters
enabled(optional) set to false to disable change detection true(default) to enable it

◆ getDisplayName()

const std::string& helics::Input::getDisplayName ( ) const
inline

get the display name for an input

the name is the given local name or if empty the name of the target

◆ getHandle()

interface_handle helics::Input::getHandle ( ) const
inline

get the underlying handle that can be used to make direct calls to the Core API

◆ getHelicsInjectionType()

data_type helics::Input::getHelicsInjectionType ( ) const
inline

get the HELICS data type for the publication

◆ getHelicsType()

data_type helics::Input::getHelicsType ( ) const
inline

get the HELICS data type for the input

◆ getInfo()

const std::string& helics::Input::getInfo ( ) const
inline

get the interface information field of the input

References fed.

◆ getInjectionUnits()

const std::string& helics::Input::getInjectionUnits ( ) const
inline

get the units associated with a input

References fed.

◆ getKey()

const std::string& helics::Input::getKey ( ) const
inline

get the Name/Key for the input

the name is the local name if given, key is the full key name

References fed.

◆ getLastUpdate()

Time helics::Input::getLastUpdate ( ) const
inline

get the time of the last update

Returns
the time of the last update

References fed.

◆ getName()

const std::string& helics::Input::getName ( ) const
inline

get the Name/Key for the input

the name is the local name if given, key is the full key name

◆ getOption()

int32_t helics::Input::getOption ( int32_t  option) const

get the current value of a flag for the handle

References fed, helics::Federate::getInterfaceOption(), handle, and helics_handle_option_multi_input_handling_method.

◆ getPublicationType()

const std::string& helics::Input::getPublicationType ( ) const
inline

get the type of the data coming from the publication

◆ getRawSize()

size_t helics::Input::getRawSize ( )

get the size of the raw data

References fed, helics::ValueFederate::getValueRaw(), and isUpdated().

◆ getRawValue()

data_view helics::Input::getRawValue ( )

get the raw binary data

References fed, and helics::ValueFederate::getValueRaw().

◆ getStringSize()

size_t helics::Input::getStringSize ( )

get the size of the data if it were a string

References isUpdated().

◆ getTarget()

const std::string& helics::Input::getTarget ( ) const
inline

get an associated target

References fed.

◆ getType()

const std::string& helics::Input::getType ( ) const
inline

get the type of the input

References fed.

◆ getUnits()

const std::string& helics::Input::getUnits ( ) const
inline

get the units associated with a input

References fed.

◆ getValue() [1/4]

template<class X >
auto helics::Input::getValue ( )
inline

get the most recent value

Returns
the value

◆ getValue() [2/4]

int helics::Input::getValue ( char *  str,
int  maxsize 
)

get string value functions to retrieve data by a C string

◆ getValue() [3/4]

int helics::Input::getValue ( double *  data,
int  maxsize 
)

get double vector value functions to retrieve data by a C array of doubles

References data.

Referenced by helics::ValueFederate::getDouble().

◆ getValue() [4/4]

template<class X >
void helics::Input::getValue ( X &  out)
inline

get the latest value for the input

Parameters
[out]outthe location to store the value

◆ getVectorSize()

size_t helics::Input::getVectorSize ( )

get the number of elements in the data if it were a vector

References isUpdated().

◆ isUpdated() [1/2]

bool helics::Input::isUpdated ( )

check if the value has been updated including interpretation of the change detection

References checkUpdate().

Referenced by getRawSize(), getStringSize(), and getVectorSize().

◆ isUpdated() [2/2]

bool helics::Input::isUpdated ( ) const

check if the value has been updated,

the const version can in some circumstances return true even if the value would not be updated the circumstances in which this is true are a minimum change has been set, checkUpdate has not been call(meaning it is a standalone copy, not the one stored with the federate, and the value has been published but would not trigger the change detection. If this is to be avoided use the non-const version or call checkUpdate before calling this function.

◆ isValid()

bool helics::Input::isValid ( ) const
inline

◆ operator interface_handle()

helics::Input::operator interface_handle ( ) const
inline

implicit conversion operator for extracting the handle

◆ registerNotificationCallback()

void helics::Input::registerNotificationCallback ( std::function< void(Time)>  callback)
inline

register a callback for an update notification

the callback is called in the just before the time request function returns

Parameters
callbacka function with signature void( Time time) time is the time the value was updated This callback is a notification callback and doesn't return the value

References fed.

◆ removeTarget()

void helics::Input::removeTarget ( const std::string &  targetToRemove)
inline

remove a named publication from being a target

References fed.

◆ setDefault()

template<class X >
void helics::Input::setDefault ( X &&  val)
inline

set the default value to use before any update has been published

Referenced by helics::InputT< X >::setDefault().

◆ setInfo()

void helics::Input::setInfo ( const std::string &  info)
inline

set the interface information field of the input

References fed.

◆ setInputNotificationCallback()

template<class X >
void helics::Input::setInputNotificationCallback ( std::function< void(const X &, Time)>  callback)
inline

register a callback for the update

the callback is called in the just before the time request function returns

Parameters
callbacka function with signature void(X val, Time time) val is the new value and time is the time the value was updated

◆ setMinimumChange()

void helics::Input::setMinimumChange ( double  deltaV)
inlinenoexcept

set the minimum delta for change detection

Parameters
deltaVa double with the change in a value in order to register a different value

◆ setOption()

void helics::Input::setOption ( int32_t  option,
int32_t  value = 1 
)

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