FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
SpeciesFields.h
1#pragma once
2
12#include "ParameterLibrary.h"
13
14#include <functional>
15#include <optional>
16#include <string>
17#include <vector>
18
19namespace environment
20{
21class EnvironmentProvider;
22}
23
25enum class WithoutSpecies
26{
27 Allow,
28 Exclude,
29 Refuse,
30};
31
34{
35 std::string namesParameter;
36 std::vector<std::string> removedKeys;
37 std::string removedReason;
38 WithoutSpecies withoutSpecies = WithoutSpecies::Refuse;
39 bool lengthRequired = true;
40};
41
44{
45 std::string name;
46 int handle = -1;
47 std::string speciesKey;
49 double lengthM = 0.0;
50};
51
54{
55 std::optional<ParameterLibrary> library;
56 std::vector<BoundSpeciesField> fields;
57 std::vector<std::string> excluded;
58 std::vector<std::string> errors;
59};
60
62inline constexpr const char* kSpeciesLengthKey = "LengthM";
63
69std::vector<std::string> DiscoverSpeciesFieldNames(const environment::EnvironmentProvider& environment);
70
85SpeciesBinding BindSpeciesFields(const environment::EnvironmentProvider& environment, const std::vector<std::string>& names,
86 const SpeciesFieldRules& rules, const std::function<ParameterLibrary()>& loadLibrary);
One species of the library.
Definition ParameterLibrary.h:29
Definition ParameterLibrary.h:25
One scalar field bound as a species.
Definition SpeciesFields.h:44
std::string name
The scalar field.
Definition SpeciesFields.h:45
std::string speciesKey
The Parameter library key; empty when the field names none.
Definition SpeciesFields.h:47
const ParameterLibrary::Species * model
The species in the library; null when the field names none.
Definition SpeciesFields.h:48
int handle
The scalar field handle.
Definition SpeciesFields.h:46
double lengthM
The LengthM property, m; zero when absent.
Definition SpeciesFields.h:49
The result of binding a sensor's species fields.
Definition SpeciesFields.h:54
std::vector< std::string > errors
Configuration messages, without the sensor's prefix.
Definition SpeciesFields.h:58
std::vector< std::string > excluded
Fields left out because they name no species.
Definition SpeciesFields.h:57
std::vector< BoundSpeciesField > fields
The bound fields, in the order they were named.
Definition SpeciesFields.h:56
std::optional< ParameterLibrary > library
Loaded only when a field names a species; owns every model.
Definition SpeciesFields.h:55
How a sensor binds its species fields.
Definition SpeciesFields.h:34
std::string namesParameter
The parameter that names the fields, for messages.
Definition SpeciesFields.h:35
WithoutSpecies withoutSpecies
A field that names no species.
Definition SpeciesFields.h:38
bool lengthRequired
A field without a positive LengthM is an error.
Definition SpeciesFields.h:39
std::vector< std::string > removedKeys
Properties no longer read; each is a configuration error.
Definition SpeciesFields.h:36
std::string removedReason
Why they are no longer read, for the message.
Definition SpeciesFields.h:37