NGen
Loading...
Searching...
No Matches
models::bmi::protocols::NgenBmiProtocol Class Referenceabstract

#include <protocol.hpp>

+ Inheritance diagram for models::bmi::protocols::NgenBmiProtocol:
+ Collaboration diagram for models::bmi::protocols::NgenBmiProtocol:

Public Member Functions

virtual ~NgenBmiProtocol ()=default
 Abstract interface for a generic BMI protocol.
 

Protected Member Functions

virtual nsel_NODISCARD auto run (const ModelPtr &model, const Context &ctx) const -> expected< void, ProtocolError >=0
 Run the BMI protocol against the given model.
 
virtual nsel_NODISCARD expected< void, ProtocolErrorcheck_support (const ModelPtr &model)=0
 Check if the BMI protocol is supported by the model.
 
virtual auto initialize (const ModelPtr &model, const Properties &properties) -> expected< void, ProtocolError >=0
 Initialize the BMI protocol from a set of key/value properties.
 
virtual bool is_supported () const =0
 Whether the protocol is supported by the model.
 

Static Protected Member Functions

static auto error_or_warning (const ProtocolError &err) -> expected< void, ProtocolError >
 Handle a ProtocolError by either throwing it or logging it as a warning.
 

Friends

class NgenBmiProtocols
 Friend class for managing one or more protocols.
 

Constructor & Destructor Documentation

◆ ~NgenBmiProtocol()

virtual models::bmi::protocols::NgenBmiProtocol::~NgenBmiProtocol ( )
virtualdefault

Abstract interface for a generic BMI protocol.

Member Function Documentation

◆ check_support()

virtual nsel_NODISCARD expected< void, ProtocolError > models::bmi::protocols::NgenBmiProtocol::check_support ( const ModelPtr & model)
protectedpure virtual

Check if the BMI protocol is supported by the model.

It is the caller's responsibility to ensure that the model provided is consistent with the model provided to the object's initialize() and run() methods, hence the protected nature of this function.

Parameters
modelA shared pointer to a Bmi_Adapter object which should be initialized before being passed to this method.
Returns
expected<void, ProtocolError> May contain a ProtocolError if the protocol is not supported by the model.

Implemented in models::bmi::protocols::NgenMassBalance.

◆ error_or_warning()

static auto models::bmi::protocols::NgenBmiProtocol::error_or_warning ( const ProtocolError & err) -> expected<void, ProtocolError>
inlinestaticprotected

Handle a ProtocolError by either throwing it or logging it as a warning.

Parameters
errThe ProtocolError to handle
Returns
expected<void, ProtocolError> Returns an empty expected if the error was logged as a warning, otherwise throws the ProtocolError.
Exceptions
ProtocolErrorif the error is of type PROTOCOL_ERROR

References models::bmi::protocols::INTEGRATION_ERROR, models::bmi::protocols::PROTOCOL_ERROR, models::bmi::protocols::PROTOCOL_WARNING, models::bmi::protocols::UNITIALIZED_MODEL, and models::bmi::protocols::UNSUPPORTED_PROTOCOL.

Referenced by models::bmi::protocols::NgenBmiProtocols::run().

◆ initialize()

virtual auto models::bmi::protocols::NgenBmiProtocol::initialize ( const ModelPtr & model,
const Properties & properties ) -> expected< void, ProtocolError >
protectedpure virtual

Initialize the BMI protocol from a set of key/value properties.

It is the caller's responsibility to ensure that the model provided is consistent with the model provided to the object's run() and check_support() methods, hence the protected nature of this function.

Parameters
propertieskey/value pairs for initializing the protocol
modelA shared pointer to a Bmi_Adapter object which should be initialized before being passed to this method.
Returns
expected<void, ProtocolError> May contain a ProtocolError if initialization fails for any reason, since the protocol must be effectively "optional", failed initialization results in the protocol being disabled for the duration of the simulation.

Implemented in models::bmi::protocols::NgenMassBalance.

◆ is_supported()

virtual bool models::bmi::protocols::NgenBmiProtocol::is_supported ( ) const
protectedpure virtual

Whether the protocol is supported by the model.

Implemented in models::bmi::protocols::NgenMassBalance.

◆ run()

virtual nsel_NODISCARD auto models::bmi::protocols::NgenBmiProtocol::run ( const ModelPtr & model,
const Context & ctx ) const -> expected< void, ProtocolError >
protectedpure virtual

Run the BMI protocol against the given model.

Execute the logic of the protocol with the provided context and model. It is the caller's responsibility to ensure that the model provided is consistent with the model provided to the object's initialize() and check_support() methods, hence the protected nature of this function.

Parameters
ctxContextual information for the protocol run
modelA shared pointer to a Bmi_Adapter object which should be initialized before being passed to this method.
Returns
expected<void, ProtocolError> May contain a ProtocolError if the protocol fails for any reason. Errors of ProtocolError::PROTOCOL_WARNING severity should be logged as warnings, but not cause the simulation to fail.

Implemented in models::bmi::protocols::NgenMassBalance.

Friends And Related Symbol Documentation

◆ NgenBmiProtocols

friend class NgenBmiProtocols
friend

Friend class for managing one or more protocols.

This allows the NgenBmiProtocols container class to access the protected run() method. This allows the container to ensure consistent application of the protocol with a particular bmi model instance throughout the lifecycle of a given protocol.


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