Loading...
Searching...
No Matches
HydroCouple::IOutput Class Referenceabstract

An output exchange item that can deliver values from an IModelComponent. More...

#include <hydrocouple.h>

Inheritance diagram for HydroCouple::IOutput:
Collaboration diagram for HydroCouple::IOutput:

Public Member Functions

virtual ~IOutput ()=default
 IOutput::~IOutput is a virtual destructor.
 
virtual std::vector< IInput * > consumers () const =0
 Input items that will consume the values by calling the IOutput::updateValues() method.
 
virtual void addConsumer (IInput *consumer, const IIdentity *providerRole=nullptr)=0
 Connects a consumer to this output item.
 
virtual bool removeConsumer (IInput *consumer)=0
 Disconnects a consumer.
 
virtual std::vector< IAdaptedOutput * > adaptedOutputs () const =0
 The adaptedOutputs that have this current output item as adaptee.
 
virtual void addAdaptedOutput (IAdaptedOutput *adaptedOutput)=0
 Add a IAdaptedOutput to this output item.
 
virtual bool removeAdaptedOutput (IAdaptedOutput *adaptedOutput)=0
 Removes an IAdaptedOutput.
 
virtual void updateValues (const IInput *querySpecifier)=0
 Brings this output's values up to what the querySpecifier requires.
 
- Public Member Functions inherited from HydroCouple::IExchangeItem
virtual ~IExchangeItem ()=default
 IExchangeItem::~IExchangeItem is a virtual destructor.
 
- Public Member Functions inherited from HydroCouple::IComponentDataItem
virtual ~IComponentDataItem ()=default
 IComponentDataItem::~IComponentDataItem is a virtual destructor.
 
virtual IModelComponent * modelComponent () const =0
 Gets the owner IModelComponent of this IComponentItem.
 
virtual std::vector< IDimension * > dimensions () const =0
 The axes of this item's index space, in storage order.
 
virtual std::vector< int64_t > shape () const =0
 The extent of each dimension of this data item's index space.
 
virtual DataKind dataKind () const =0
 The element type of this data item's values.
 
virtual IValueDefinition * valueDefinition () const =0
 IValueDefinition for this IComponentDataItem defines the variable type associated with this object.
 
virtual bool getValuesInto (const BufferDescriptor &destination, std::span< const int64_t > start, std::span< const int64_t > count, std::string *message=nullptr) const =0
 Copies a hyperslab of this item's values into a caller-described buffer.
 
virtual bool setValuesFrom (const BufferDescriptor &source, std::span< const int64_t > start, std::span< const int64_t > count, std::string *message=nullptr)=0
 Copies values from a caller-described buffer into a hyperslab of this item.
 
- Public Member Functions inherited from HydroCouple::IIdentity
virtual ~IIdentity ()=default
 IIdentity::~IIdentity is a virtual destructor.
 
virtual const std::string & id () const =0
 Gets a unique identifier for the entity.
 
- Public Member Functions inherited from HydroCouple::IDescription
virtual ~IDescription ()=default
 IDescription::~IDescription is a virtual destructor.
 
virtual const std::string & caption () const =0
 Gets caption for the entity.
 
virtual void setCaption (const std::string &caption)=0
 Sets caption for the entity.
 
virtual const std::string & description () const =0
 Gets additional descriptive information for the entity.
 
virtual void setDescription (const std::string &description)=0
 Gets additional descriptive information for the entity.
 
- Public Member Functions inherited from HydroCouple::IPropertyChanged
virtual ~IPropertyChanged ()=default
 IPropertyChanged::~IPropertyChanged is a virtual destructor.
 
- Public Member Functions inherited from HydroCouple::ISignal< std::string >
virtual ~ISignal ()=default
 ISignal::~ISignal is a virtual destructor.
 
virtual void connect (const std::shared_ptr< ISlot< Args... > > &slot)=0
 connect is used to connect a slot to the signal.
 
virtual void disconnect (const std::shared_ptr< ISlot< Args... > > &slot)=0
 disconnect is used to disconnect a slot from the signal.
 
virtual void blockSignals (bool block)=0
 blockSignals is used to block signals from being emitted.
 
- Public Member Functions inherited from HydroCouple::ISignal< const std::shared_ptr< IComponentDataItemValueChanged > & >
virtual ~ISignal ()=default
 ISignal::~ISignal is a virtual destructor.
 
virtual void connect (const std::shared_ptr< ISlot< Args... > > &slot)=0
 connect is used to connect a slot to the signal.
 
virtual void disconnect (const std::shared_ptr< ISlot< Args... > > &slot)=0
 disconnect is used to disconnect a slot from the signal.
 
virtual void blockSignals (bool block)=0
 blockSignals is used to block signals from being emitted.
 

Additional Inherited Members

- Protected Member Functions inherited from HydroCouple::ISignal< std::string >
virtual void emit (Args... args)=0
 emit is used to emit the signal.
 
- Protected Member Functions inherited from HydroCouple::ISignal< const std::shared_ptr< IComponentDataItemValueChanged > & >
virtual void emit (Args... args)=0
 emit is used to emit the signal.
 

Detailed Description

An output exchange item that can deliver values from an IModelComponent.

If an output does not provide the data in the way a consumer would like to have it the output can be adapted by an IAdaptedOutput, which can transform the data according to the consumer's wishes. E.g. by performing interpolation in time, spatial aggregation, etc.).

Constructor & Destructor Documentation

◆ ~IOutput()

virtual HydroCouple::IOutput::~IOutput ( )
virtualdefault

IOutput::~IOutput is a virtual destructor.

Member Function Documentation

◆ adaptedOutputs()

virtual std::vector< IAdaptedOutput * > HydroCouple::IOutput::adaptedOutputs ( ) const
nodiscardpure virtual

The adaptedOutputs that have this current output item as adaptee.

As soon as the output item's values have been updated, for each adaptedOutput its IAdaptedOutput.refresh() method must be called.

The list is readonly. Add and remove from the list by using addAdaptedOutput() and removeAdaptedOutput().

◆ addAdaptedOutput()

virtual void HydroCouple::IOutput::addAdaptedOutput ( IAdaptedOutput * adaptedOutput)
pure virtual

Add a IAdaptedOutput to this output item.

Every adaptedOutput that uses data from this output item, needs to add itself as a consumer first.

Registration is non-owning: whoever holds the std::unique_ptr returned by IAdaptedOutputFactory::createAdaptedOutput() owns the adapter, and an adapter's destructor must call adaptee()->removeAdaptedOutput(this) so that this list never dangles.

If a adaptedOutput is added that can not be handled, or that is incompatible with the already added adaptedOutputs, a Severity::Error entry is queued and an exception may be thrown.

Parameters
[in]adaptedOutputis consumer that has to be added

◆ addConsumer()

virtual void HydroCouple::IOutput::addConsumer ( IInput * consumer,
const IIdentity * providerRole = nullptr )
pure virtual

Connects a consumer to this output item.

Every input item that wants to call the IOutput::updateValues() method must be connected first.

This is the single entry point for wiring a connection, for every kind of input. Orchestrators call addConsumer()/removeConsumer() only, never IInput::setProvider() or IMultiInput::addProvider()/removeProvider() directly; those are the callbacks through which the output makes both ends agree:

  • when consumer is an IMultiInput, the output checks canConsume(this, message, providerRole) and then calls addProvider(this, providerRole);
  • otherwise providerRole must be nullptr, and the output checks canConsume(this, message) and then calls setProvider(this). Only when the check and the callback both succeed does the output record the consumer. On failure it records nothing, queues a Severity::Error entry on its owning component and may throw.
Parameters
[in]consumerthat has to be added (non-owning; the consumer's component owns it)
[in]providerRolethe role this output fills for a multi-input consumer (one of its providerLabels()), or nullptr for none.

◆ consumers()

virtual std::vector< IInput * > HydroCouple::IOutput::consumers ( ) const
nodiscardpure virtual

Input items that will consume the values by calling the IOutput::updateValues() method.

Every connected input appears here, multi-inputs included. The list is read-only; it changes only through addConsumer() and removeConsumer(). This output's own values (getValuesInto()) may be read whether or not it has consumers.

◆ removeAdaptedOutput()

virtual bool HydroCouple::IOutput::removeAdaptedOutput ( IAdaptedOutput * adaptedOutput)
nodiscardpure virtual

Removes an IAdaptedOutput.

Called by an adapted output's destructor (see addAdaptedOutput()), and by an adapter that no longer wants this output's data.

Parameters
[in]adaptedOutputis the adapter to deregister.
Returns
True if the adapter was registered and has been removed.

◆ removeConsumer()

virtual bool HydroCouple::IOutput::removeConsumer ( IInput * consumer)
nodiscardpure virtual

Disconnects a consumer.

The counterpart of addConsumer(): on success the output calls removeProvider(this) on a multi-input consumer and setProvider(nullptr) on any other.

Parameters
[in]consumerthat has to be removed
Returns
True if the consumer was registered and has been removed.

◆ updateValues()

virtual void HydroCouple::IOutput::updateValues ( const IInput * querySpecifier)
pure virtual

Brings this output's values up to what the querySpecifier requires.

The query is the input itself. What it asks for is read from the input's own metadata, by the specialization the two sides share:

  • time: if the input is a Temporal::ITimeSeriesComponentDataItem, its times() are the instants the consumer needs values for, and its timeInterpolation()/timeExtrapolation() say what the provider may do to produce them; the provider (or the adapted output between them) advances its owning component through update() until it can serve the last of them, or sets WaitingForData when it cannot yet;
  • space: if the input is a spatial item, its geometry/mesh/grid is the target the values must be resolved on; a mismatch with this output's geometry is an adapted output's job, and an unadapted mismatch fails canConsume() at wiring time rather than here;
  • values: the input's valueDefinition() (unit, valueKind()) is what the values must be expressed in. A base IInput with none of these carries no query beyond "your current values".

Synchronous: on return the values the consumer asked for are readable through this output's getValuesInto(). Asynchronous exchange exists only at the distributed layer (hydrocoupledistributed.h).

Parameters
[in]querySpecifierThe IInput specifying the required values. Must be a registered consumer of this output.

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