NGen
Loading...
Searching...
No Matches
protocols.hpp
1/*
2Author: Nels Frazier
3Copyright (C) 2025 Lynker
4------------------------------------------------------------------------
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16------------------------------------------------------------------------
17Version 0.2.1
18Fix NgenBmiProtocols constructor to initialize protocols map when model is null
19Fix run() to return the expected<void, ProtocolError> returned by the wrapped call
20
21Version 0.2
22Enumerate protocol types/names
23The container now holds a single model pointer and passes it to each protocol
24per the updated (v0.2) protocol interface
25Keep protocols in a map for dynamic access by enumeration name
26add operator<< for Protocol enum
27
28Version 0.1
29Container and management for abstract BMI protocols
30*/
31#pragma once
32
33#include <string>
34#include <vector>
35#include <boost/type_index.hpp>
36#include <unordered_map>
37#include "Bmi_Adapter.hpp"
38#include "JSONProperty.hpp"
39
40#include "mass_balance.hpp"
41
42
43namespace models{ namespace bmi{ namespace protocols{
44
45enum class Protocol {
47};
48
49auto operator<<(std::ostream& os, Protocol p) -> std::ostream&;
50
57 public:
63
70 NgenBmiProtocols(std::shared_ptr<models::bmi::Bmi_Adapter> model, const geojson::PropertyMap& properties);
71
81 auto run(const Protocol& protocol_name, const Context& ctx) const -> expected<void, ProtocolError>;
82
83 private:
84
92 std::shared_ptr<models::bmi::Bmi_Adapter> model;
97 std::unordered_map<Protocol, std::unique_ptr<NgenBmiProtocol>> protocols;
98 };
99
100}}}
Definition protocols.hpp:51
auto run(const Protocol &protocol_name, const Context &ctx) const -> expected< void, ProtocolError >
Run a specific BMI protocol by name with a given context.
Definition protocols.cpp:49
std::unordered_map< Protocol, std::unique_ptr< NgenBmiProtocol > > protocols
Map of protocol name to protocol instance.
Definition protocols.hpp:97
NgenBmiProtocols()
Container and management interface for BMI protocols for use in ngen.
Definition protocols.cpp:38
std::shared_ptr< models::bmi::Bmi_Adapter > model
All protocols managed by this container will utilize the same model.
Definition protocols.hpp:92
Definition bmi.hpp:16
std::map< std::string, JSONProperty > PropertyMap
Shorthand for a mapping between strings and properties.
Definition JSONProperty.hpp:21
Protocol
Definition protocols.hpp:45
auto operator<<(std::ostream &os, Protocol p) -> std::ostream &
Definition protocols.cpp:30
Definition AbstractCLibBmiAdapter.hpp:6
Definition protocol.hpp:82