helics  3.5.3
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, InterfaceHandle id, std::string_view actName, std::string_view unitsOut={})
 
 Input (ValueFederate *valueFed, std::string_view key, std::string_view defaultType="def", std::string_view units={})
 
template<class FedPtr >
 Input (FedPtr &valueFed, std::string_view key, std::string_view defaultType="def", std::string_view units={})
 
 Input (InterfaceVisibility locality, ValueFederate *valueFed, std::string_view key, std::string_view defaultType="def", std::string_view units={})
 
template<class FedPtr >
 Input (InterfaceVisibility locality, FedPtr &valueFed, std::string_view key, std::string_view defaultType="def", std::string_view units={})
 
 Input (ValueFederate *valueFed, std::string_view key, DataType defType, std::string_view units={})
 
template<class FedPtr >
 Input (FedPtr &valueFed, std::string_view key, DataType defType, std::string_view units={})
 
 Input (InterfaceVisibility locality, ValueFederate *valueFed, std::string_view key, std::string_view units={})
 
template<class FedPtr >
 Input (InterfaceVisibility locality, FedPtr &valueFed, std::string_view key, std::string_view units={})
 
 Input (InterfaceVisibility locality, ValueFederate *valueFed, std::string_view key, DataType defType, std::string_view units={})
 
template<class FedPtr >
 Input (InterfaceVisibility locality, FedPtr &valueFed, std::string_view key, DataType defType, std::string_view units={})
 
Time getLastUpdate () const
 
void registerNotificationCallback (std::function< void(Time)> callback)
 
const std::string & getPublicationType () const
 
const std::string & getType () const
 
const std::string & getUnits () const
 
void addPublication (std::string_view target)
 
void addTarget (std::string_view target)
 
bool checkUpdate (bool assumeUpdate=false)
 
void clearUpdate ()
 
bool isUpdated ()
 
bool isUpdated () const
 
virtual void setOption (int32_t option, int32_t value=1) override
 
virtual int32_t getOption (int32_t option) const override
 
template<class X >
void setInputNotificationCallback (std::function< void(const X &, Time)> callback)
 
template<class X >
void setDefault (X &&val)
 
void setDefaultBytes (data_view val)
 
void setMinimumChange (double deltaV) noexcept
 
void enableChangeDetection (bool enabled=true) noexcept
 
int getValue (double *data, int maxsize)
 
int getComplexValue (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 ()
 
double getDouble ()
 
const std::string & getString ()
 
data_view getBytes ()
 
size_t getByteCount ()
 
size_t getStringSize ()
 
size_t getVectorSize ()
 
DataType getHelicsType () const
 
DataType getHelicsInjectionType () const
 
MultiInputHandlingMethod getMultiInputMode () const
 
bool vectorDataProcess (const std::vector< std::shared_ptr< const SmallBuffer >> &dataV)
 
const std::string & getTarget () const
 
virtual const std::string & getDisplayName () const override
 
- Public Member Functions inherited from helics::Interface
 Interface (Federate *federate, InterfaceHandle hid, std::string_view actName)
 
 Interface (Core *core, InterfaceHandle hid, std::string_view actName)
 
InterfaceHandle getHandle () const
 
 operator InterfaceHandle () const
 
bool isValid () const
 
bool operator< (const Interface &inp) const
 
bool operator> (const Interface &inp) const
 
bool operator== (const Interface &inp) const
 
bool operator!= (const Interface &inp) const
 
const std::string & getLocalName () const
 
const std::string & getName () const
 
const std::string & getTarget () const
 
void addSourceTarget (std::string_view newTarget, InterfaceType hint=InterfaceType::UNKNOWN)
 
void addDestinationTarget (std::string_view newTarget, InterfaceType hint=InterfaceType::UNKNOWN)
 
void removeTarget (std::string_view targetToRemove)
 
void addAlias (std::string_view alias)
 
const std::string & getInfo () const
 
void setInfo (std::string_view info)
 
void setTag (std::string_view tag, std::string_view value)
 
const std::string & getTag (std::string_view tag) const
 
const std::string & getInjectionType () const
 
const std::string & getExtractionType () const
 
const std::string & getInjectionUnits () const
 
const std::string & getExtractionUnits () const
 
const std::string & getSourceTargets () const
 
const std::string & getDestinationTargets () const
 
std::size_t getSourceTargetCount () const
 
std::size_t getDestinationTargetCount () const
 
void close ()
 
void disconnectFromCore ()
 

Protected Attributes

ValueFederatefed = nullptr
 reference to the value federate
 
- Protected Attributes inherited from helics::Interface
CoremCore {nullptr}
 pointer to the core object
 
InterfaceHandle handle {}
 the id as generated by the Federate
 
std::string mName
 the name or key of the interface
 

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,
InterfaceHandle  id,
std::string_view  actName,
std::string_view  unitsOut = {} 
)

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

Member Function Documentation

◆ addPublication()

void helics::Input::addPublication ( std::string_view  target)

add a publication for the inputs information

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

◆ addTarget()

void helics::Input::addTarget ( std::string_view  target)
inline

add a target to the input

◆ 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::getBytes(), and helics::ValueFederate::isUpdated().

Referenced by isUpdated(), and helics::ValueFederateManager::localQuery().

◆ clearUpdate()

void helics::Input::clearUpdate ( )

clear the isUpdated flag

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

Referenced by helics::ValueFederateManager::clearUpdates().

◆ 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

◆ getByteCount()

size_t helics::Input::getByteCount ( )

get the size of the raw data

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

◆ getBytes()

data_view helics::Input::getBytes ( )

get the raw binary data

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

◆ getComplexValue()

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

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

◆ getDisplayName()

virtual const std::string& helics::Input::getDisplayName ( ) const
inlineoverridevirtual

get the display name for an input

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

Implements helics::Interface.

Referenced by helics::ValueFederateManager::addTarget(), and helics::ValueFederateManager::localQuery().

◆ getDouble()

double helics::Input::getDouble ( )
inline

get the current value as a Double

◆ getHelicsInjectionType()

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

get the HELICS data type for the publication

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

◆ getHelicsType()

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

get the HELICS data type for the input

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

◆ getLastUpdate()

Time helics::Input::getLastUpdate ( ) const

get the time of the last update

Returns
the time of the last update

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

◆ getOption()

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

get the current value of a flag for the handle

Reimplemented from helics::Interface.

References helics::Interface::getOption(), 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

◆ getString()

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

get the current value as a string

◆ getStringSize()

size_t helics::Input::getStringSize ( )

get the size of the data if it were a string

References isUpdated().

◆ getType()

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

get the type of the input

◆ getUnits()

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

get the units associated with a input

◆ 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

◆ 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 getByteCount(), getStringSize(), getVectorSize(), helics::ValueFederateManager::localQuery(), and registerNotificationCallback().

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

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

◆ registerNotificationCallback()

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

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) where time is the time the value was updated. This callback is a notification callback and doesn't return the value

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

◆ setDefault()

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

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

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

set a handle flag for the input

Reimplemented from helics::Interface.

References HELICS_HANDLE_OPTION_MULTI_INPUT_HANDLING_METHOD, and helics::Interface::setOption().


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