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

IArgument interface class used to set the arguments for components. More...

#include <hydrocouple.h>

Inheritance diagram for HydroCouple::IArgument:
Collaboration diagram for HydroCouple::IArgument:

Public Types

enum class  ArgumentInputType {
  String ,
  File ,
  JSON ,
  YAML ,
  XML ,
  URL ,
  MEMORY_OBJECT
}
 Enumeration indicating the type of input for the argument. More...
 
enum class  ArgumentRole : uint8_t {
  Configuration = 0 ,
  Parameter ,
  InitialCondition ,
  Forcing ,
  Geometry
}
 What kind of thing an argument is to the model that owns it. More...
 

Public Member Functions

virtual ~IArgument ()=default
 IArgument::~IArgument is a virtual destructor.
 
virtual ArgumentRole role () const =0
 What this argument is to the model.
 
virtual bool isOptional () const =0
 Specifies whether the argument is optional or not.
 
virtual bool isReadOnly () const =0
 Whether the argument's values may be changed (through initialize() or setValuesFrom()).
 
virtual std::string toString () const =0
 A human-readable rendering of this argument's current value, for display and logs.
 
virtual void saveData ()=0
 Writes data to files associated with this argument if they exist.
 
virtual std::vector< std::string > fileFilters () const =0
 File type extensions that can be read by this IArgument.
 
virtual std::vector< const std::type_info * > validComponentDataItemTypes () const =0
 Gets the valid IComponentDataItem instance types that can be read by this argument.
 
virtual bool isValidArgType (ArgumentInputType argType) const =0
 Whether this argument can be initialized from, and serialized to, the given representation.
 
virtual ArgumentInputType currentArgumentInputType () const =0
 Gets the current input type used for this argument.
 
virtual bool initialize (const std::string &value, ArgumentInputType argType, std::string &message)=0
 Reads values from a string in the given representation (a JSON/YAML/XML document, a file path, a URL, ...).
 
virtual bool initialize (const IComponentDataItem &componentDataItem, std::string &message)=0
 Reads values from an equivalent IComponentDataItem.
 
virtual bool serialize (ArgumentInputType argType, std::string &value, std::string &message) const =0
 Serializes this argument's current value to the requested representation.
 
- 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

IArgument interface class used to set the arguments for components.

They can be complex or simple multi-dimensional datasets

IArgument is primarily used to set arguments of IModelComponent and IAdaptedOutput

Member Enumeration Documentation

◆ ArgumentInputType

Enumeration indicating the type of input for the argument.

Enumerator
String 

Enumeration indicating that the argument was read from string.

File 

Enumeration indicating that the argument was read from a file.

JSON 

Enumeration indicating that the argument input is in JSON format.

YAML 

Enumeration indicating that the argument input is in YAML format.

XML 

Enumeration indicating that the argument input is in XML format.

URL 

Enumeration indicating that the argument was read from a URL.

MEMORY_OBJECT 

Enumeration indicating that the argument was read from a memory object.

◆ ArgumentRole

enum class HydroCouple::IArgument::ArgumentRole : uint8_t
strong

What kind of thing an argument is to the model that owns it.

A calibration driver perturbs Parameters and leaves Configuration alone; a data-assimilation driver perturbs InitialConditions; a scenario generator swaps Forcings. Without this distinction each of those tools invents its own tag.

Enumerator
Configuration 

How the model runs: paths, options, solver settings, output selection.

Parameter 

A coefficient of the process equations (roughness, conductivity, rate constants).

InitialCondition 

The state at the start of the simulation.

Forcing 

A prescribed time-varying input that is not supplied through an IInput (a boundary time series read from file).

Geometry 

The spatial discretization itself (a mesh, a network, a raster grid).

Constructor & Destructor Documentation

◆ ~IArgument()

virtual HydroCouple::IArgument::~IArgument ( )
virtualdefault

IArgument::~IArgument is a virtual destructor.

Member Function Documentation

◆ currentArgumentInputType()

virtual ArgumentInputType HydroCouple::IArgument::currentArgumentInputType ( ) const
nodiscardpure virtual

Gets the current input type used for this argument.

Returns
The ArgumentInputType indicating how this argument was initialized.

◆ fileFilters()

virtual std::vector< std::string > HydroCouple::IArgument::fileFilters ( ) const
nodiscardpure virtual

File type extensions that can be read by this IArgument.

File filters are specified as a description followed by glob patterns in parentheses, e.g. "Configuration Files (*.yaml *.yml *.json)".

Returns
a list of strings for compatible file extensions.

◆ initialize() [1/2]

virtual bool HydroCouple::IArgument::initialize ( const IComponentDataItem & componentDataItem,
std::string & message )
nodiscardpure virtual

Reads values from an equivalent IComponentDataItem.

IComponentDataItem has been used instead of IArgument so that outputs from one model can be used as initialization arguments for another.

Parameters
[in]componentDataItemis the IArgument from which to copy values from.
[out]messagemessage returned from file read operation.
Returns
boolean indicating whether file reading was successful.

◆ initialize() [2/2]

virtual bool HydroCouple::IArgument::initialize ( const std::string & value,
ArgumentInputType argType,
std::string & message )
nodiscardpure virtual

Reads values from a string in the given representation (a JSON/YAML/XML document, a file path, a URL, ...).

Parameters
[in]valueis the string to read; for File and URL it names the source.
[in]argTypeis the representation of value.
[out]messagedescribes the failure when the return value is false.
Returns
True on success.

◆ isOptional()

virtual bool HydroCouple::IArgument::isOptional ( ) const
nodiscardpure virtual

Specifies whether the argument is optional or not.

A non-optional argument must be given a value (through initialize() or setValuesFrom()) before the owning component's initialize() is called.

◆ isReadOnly()

virtual bool HydroCouple::IArgument::isReadOnly ( ) const
nodiscardpure virtual

Whether the argument's values may be changed (through initialize() or setValuesFrom()).

This is used to let a IModelComponent or an IAdaptedOutput present the actual value of an argument that can not be changed by the user, but is needed to determine the values of other arguments or is informative in any other way.

◆ isValidArgType()

virtual bool HydroCouple::IArgument::isValidArgType ( ArgumentInputType argType) const
nodiscardpure virtual

Whether this argument can be initialized from, and serialized to, the given representation.

Parameters
argTypeis the representation to query.
Returns
True if initialize(value, argType, ...) and serialize(argType, ...) are supported.

◆ role()

virtual ArgumentRole HydroCouple::IArgument::role ( ) const
nodiscardpure virtual

What this argument is to the model.

◆ saveData()

virtual void HydroCouple::IArgument::saveData ( )
pure virtual

Writes data to files associated with this argument if they exist.

◆ serialize()

virtual bool HydroCouple::IArgument::serialize ( ArgumentInputType argType,
std::string & value,
std::string & message ) const
nodiscardpure virtual

Serializes this argument's current value to the requested representation.

This is the write-side counterpart of initialize() and makes IArgument the normative serialization unit: a component's entire persistent configuration must be expressible through its arguments, so any driver can round-trip a component without knowing its internals. For large field payloads (meshes, time series, initial conditions) implementations must not inline bulk data into text formats; the serialized form should carry an external binary payload reference (URI, DataKind, and shape inline; bulk bytes in a sidecar produced through the BufferDescriptor path), with inline text arrays used only for small payloads.

Parameters
[in]argTypeis the requested representation (e.g., JSON or YAML).
[out]valuereceives the serialized representation.
[out]messagedescribes the failure when the return value is false.
Returns
True on success; false if argType is unsupported (see isValidArgType()) or serialization failed.

◆ toString()

virtual std::string HydroCouple::IArgument::toString ( ) const
nodiscardpure virtual

A human-readable rendering of this argument's current value, for display and logs.

serialize() is the round-trippable form.

◆ validComponentDataItemTypes()

virtual std::vector< const std::type_info * > HydroCouple::IArgument::validComponentDataItemTypes ( ) const
nodiscardpure virtual

Gets the valid IComponentDataItem instance types that can be read by this argument.

Returns
A list of pointers to type_info objects representing the valid component data item types.

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