NGen
Loading...
Searching...
No Matches
layer.hpp
1#ifndef NGEN_REALIZATION_CONFIG_LAYER_H
2#define NGEN_REALIZATION_CONFIG_LAYER_H
3
4#include <boost/property_tree/ptree.hpp>
5
6#include "LayerData.hpp"
7#include "config.hpp"
8
9namespace realization{
10 namespace config{
11
16 struct Layer{
23 Layer():descriptor( {"surface layer", "s", 0, 3600 } ){};
24
30 Layer(const boost::property_tree::ptree& tree):formulation(tree){
31 std::vector<std::string> missing_keys;
32 auto name = tree.get_optional<std::string>("name");
33 if(!name) missing_keys.push_back("name");
34 auto unit = tree.get<std::string>("time_step_units", "s");
35
36 auto id = tree.get_optional<int>("id");
37 if(!id) missing_keys.push_back("id");
38
39 auto ts = tree.get_optional<double>("time_step");
40 //TODO is time_step required? e.g. need to add to missing_keys?
41 auto tmp = tree.get_optional<std::string>("domain");
42 if(tmp) domain = *tmp;
43 if(missing_keys.empty()){
44 descriptor = {*name, unit, *id, *ts};// ngen::LayerDescription( );
45 }
46 else{
47 std::string message = "ERROR: Layer cannot be created; the following parameters are missing or invalid: ";
48
49 for (const auto& missing : missing_keys) {
50 message += missing;
51 message += ", ";
52 }
53 //pop off the extra ", "
54 message.pop_back();
55 message.pop_back();
56 throw std::runtime_error(message);
57 }
58 }
59
66 return descriptor;
67 }
68
76 return formulation.has_formulation();
77 }
78
84 const std::string& get_domain(){ return domain; }
85
91 private:
92 std::string domain;
94
95 };
96
97 }//end namespace config
98}//end namespace realization
99#endif //NGEN_REALIZATION_CONFIG_LAYER_H
Definition Bmi_C_Formulation.hpp:11
A simple structure to hold meta data related to a computational layer.
Definition LayerData.hpp:18
Structure representing the configuration for a general Formulation.
Definition config.hpp:16
Layer configuration information.
Definition layer.hpp:16
Layer()
Construct a new default surface layer.
Definition layer.hpp:23
ngen::LayerDescription descriptor
Definition layer.hpp:93
const std::string & get_domain()
Get the domain description.
Definition layer.hpp:84
Layer(const boost::property_tree::ptree &tree)
Construct a new Layer from a property tree.
Definition layer.hpp:30
const ngen::LayerDescription & get_descriptor()
Get the descriptor associated with this layer configuration.
Definition layer.hpp:65
Config formulation
The formulation configuration associated with the layer.
Definition layer.hpp:90
bool has_formulation()
Determines if the layer has a valid configured formulation.
Definition layer.hpp:75
std::string domain
Definition layer.hpp:92