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

ICheckpointableAdaptedOutput is an adapted output that can save and restore the state it carries between refreshes. More...

#include <hydrocouple.h>

Inheritance diagram for HydroCouple::ICheckpointableAdaptedOutput:
Collaboration diagram for HydroCouple::ICheckpointableAdaptedOutput:

Public Member Functions

virtual ~ICheckpointableAdaptedOutput ()=default
 ~ICheckpointableAdaptedOutput destructor.
 
virtual bool saveState (std::string &token, std::string &message)=0
 Saves the adapter's complete state.
 
virtual bool restoreState (const std::string &token, std::string &message)=0
 Restores state previously saved by saveState().
 
virtual bool releaseState (const std::string &token, std::string &message)=0
 Releases a state saved by saveState() that will not be restored.
 
- Public Member Functions inherited from HydroCouple::IAdaptedOutput
virtual ~IAdaptedOutput ()=default
 IAdaptedOutput::~IAdaptedOutput is a virtual destructor.
 
virtual IAdaptedOutputFactory * adaptedOutputFactory () const =0
 IAdaptedOutputFactory that generated this IAdaptedOutput.
 
virtual std::vector< IArgument * > arguments () const =0
 IArgument represents input parameters needed for this IAdaptedOutput.
 
virtual void initialize ()=0
 Lets this IAdaptedOutput initialize() itself, based on the current values specified by the arguments.
 
virtual IOutput * adaptee () const =0
 IOutput that this IAdaptedOutput extracts content from.
 
virtual void refresh ()=0
 Requests the IAdaptedOutput to refresh itself and perform any necessary calculations.
 
virtual std::vector< IComponentDataItem * > states () const =0
 The data items that make up the state carried from one refresh() to the next.
 
- Public Member Functions inherited from HydroCouple::IOutput
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

ICheckpointableAdaptedOutput is an adapted output that can save and restore the state it carries between refreshes.

The adapter's counterpart of ICheckpointableModelComponent. An orchestrator that returns a composition to an earlier step – to replay it for reverse-mode differentiation, to rewind a training loop, to restart a run – restores every component, and every adapter whose states() is not empty, to the same moment. An adapter with state that cannot be restored makes that impossible, and the orchestrator must refuse rather than replay through it.

Semantics are those of ICheckpointableModelComponent: saveState() returns an opaque token, possibly usable by a different process; restoreState() makes the adapter behave as if it had refreshed its way to the checkpointed state (it does not refresh its children, which an orchestrator restores in their own right); releaseState() frees whatever the token names, after which the token is dead. A restore is not a refresh: an adapter that is also an IDifferentiableAdaptedOutput has nothing to differentiate until its next refresh(). Adapters have no status, so all three are legal at any time after initialize(). What a checkpoint captures is at least every item in states() plus whatever private state refresh() depends on.

Constructor & Destructor Documentation

◆ ~ICheckpointableAdaptedOutput()

virtual HydroCouple::ICheckpointableAdaptedOutput::~ICheckpointableAdaptedOutput ( )
virtualdefault

~ICheckpointableAdaptedOutput destructor.

Member Function Documentation

◆ releaseState()

virtual bool HydroCouple::ICheckpointableAdaptedOutput::releaseState ( const std::string & token,
std::string & message )
nodiscardpure virtual

Releases a state saved by saveState() that will not be restored.

An adapter whose token IS the state has nothing to free and returns true. After this call the token is dead: restoring or releasing it again is an error the adapter may refuse.

Parameters
[in]tokenis an opaque identifier returned by saveState().
[out]messagedescribes the failure when the return value is false.
Returns
True on success.

◆ restoreState()

virtual bool HydroCouple::ICheckpointableAdaptedOutput::restoreState ( const std::string & token,
std::string & message )
nodiscardpure virtual

Restores state previously saved by saveState().

On success the adapter's values and state are those it held when the token was saved.

Parameters
[in]tokenis the opaque identifier returned by saveState().
[out]messagedescribes the failure when the return value is false.
Returns
True on success.

◆ saveState()

virtual bool HydroCouple::ICheckpointableAdaptedOutput::saveState ( std::string & token,
std::string & message )
nodiscardpure virtual

Saves the adapter's complete state.

Parameters
[out]tokenis an opaque identifier for the saved state.
[out]messagedescribes the failure when the return value is false.
Returns
True on success.

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