32#include "Bmi_Adapter.hpp"
33#include "JSONProperty.hpp"
34#include <nonstd/expected.hpp>
36namespace models{
namespace bmi{
namespace protocols{
37using nonstd::expected;
38using nonstd::make_unexpected;
65 default:
return "Unknown Error: " +
message;
72 char const *
what() const noexcept
override {
86 const std::string&
id;
89using ModelPtr = std::shared_ptr<models::bmi::Bmi_Adapter>;
114 switch(err.error_code()){
122 std::cerr << err.to_string() << std::endl;
123 return make_unexpected<ProtocolError>(
ProtocolError(std::move(err) ) );
127 assert (
false &&
"Unreachable code reached in error_or_warning");
146 nsel_NODISCARD
virtual auto run(
const ModelPtr& model,
const Context& ctx)
const -> expected<void, ProtocolError> = 0;
Definition protocol.hpp:92
virtual bool is_supported() const =0
Whether the protocol is supported by the model.
virtual nsel_NODISCARD expected< void, ProtocolError > check_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 ~NgenBmiProtocol()=default
Abstract interface for a generic BMI protocol.
static auto error_or_warning(const ProtocolError &err) -> expected< void, ProtocolError >
Handle a ProtocolError by either throwing it or logging it as a warning.
Definition protocol.hpp:112
virtual nsel_NODISCARD auto run(const ModelPtr &model, const Context &ctx) const -> expected< void, ProtocolError >=0
Run the BMI protocol against the given model.
Definition protocols.hpp:51
Definition protocol.hpp:48
std::string message
Definition protocol.hpp:79
Error err
Definition protocol.hpp:78
char const * what() const noexcept override
Definition protocol.hpp:72
auto error_code() const -> const Error &
Definition protocol.hpp:69
ProtocolError & operator=(ProtocolError &&other) noexcept=default
ProtocolError(Error err, const std::string &message="")
Definition protocol.hpp:51
ProtocolError(const ProtocolError &other)=default
ProtocolError & operator=(const ProtocolError &other)=default
auto get_message() const -> const std::string &
Definition protocol.hpp:70
ProtocolError(ProtocolError &&other) noexcept=default
auto to_string() const -> std::string
Definition protocol.hpp:58
std::map< std::string, JSONProperty > PropertyMap
Shorthand for a mapping between strings and properties.
Definition JSONProperty.hpp:21
std::shared_ptr< models::bmi::Bmi_Adapter > ModelPtr
Definition protocol.hpp:89
geojson::PropertyMap Properties
Definition protocol.hpp:90
Error
Definition protocol.hpp:40
Definition AbstractCLibBmiAdapter.hpp:6
Definition protocol.hpp:82
const std::string & id
Definition protocol.hpp:86
const std::string & timestamp
Definition protocol.hpp:85
const int total_steps
Definition protocol.hpp:84
const int current_time_step
Definition protocol.hpp:83