16 #include "eckit/config/Configuration.h"
17 #include "eckit/exception/Exceptions.h"
18 #include "eckit/types/Types.h"
20 #include "oops/util/IntSetParser.h"
21 #include "oops/util/Logger.h"
28 : convention_(
""), vars_(0) {
29 Log::trace() <<
"Variables::Variables" << std::endl;
35 : convention_(
""), vars_(0), channels_(0) {
36 Log::trace() <<
"Variables::Variables start " << conf << std::endl;
37 std::vector<std::string> vars;
38 if (!conf.get(name, vars)) {
39 Log::error() << name <<
" not found in " << conf << std::endl;
40 throw eckit::BadParameter(
"Undefined variable: '" + name +
"'");
43 if (conf.has(
"channels")) {
44 std::string chlist = conf.getString(
"channels");
45 std::set<int>
channels = parseIntSet(chlist);
48 for (
size_t jvar = 0; jvar < vars.size(); ++jvar) {
49 for (
size_t jch = 0; jch <
channels_.size(); ++jch) {
56 Log::trace() <<
"Variables::Variables done" << std::endl;
62 : convention_(conv), vars_(vars) {
63 Log::trace() <<
"Variables::Variables start " << vars << std::endl;
64 Log::trace() <<
"Variables::Variables done" << std::endl;
70 : convention_(
""), vars_(0), channels_(channels) {
71 Log::trace() <<
"Variables::Variables start " << vars <<
" @ " <<
channels << std::endl;
75 for (
size_t jvar = 0; jvar < vars.size(); ++jvar) {
76 for (
size_t jch = 0; jch <
channels_.size(); ++jch) {
81 Log::trace() <<
"Variables::Variables done" << std::endl;
87 : convention_(other.convention_), vars_(other.vars_), channels_(other.channels_)
118 bool is_in_rhs =
true;
119 for (
size_t jj = 0; jj <
vars_.size(); ++jj) {
120 is_in_rhs = is_in_rhs && rhs.
has(
vars_[jj]);
129 for (
size_t jj = 0; jj <
vars_.size(); ++jj) {
130 found = found ||
vars_[jj] == var;
138 size_t ii =
vars_.size();
139 for (
size_t jj = 0; jj <
vars_.size(); ++jj) {
140 if (
vars_[jj] == var) ii = jj;
142 ASSERT(ii <
vars_.size());
149 vars_.push_back(vname);
159 os <<
vars_.size() <<
" variables: ";
160 for (
size_t jj = 0; jj <
vars_.size(); ++jj) {
161 if (jj > 0) os <<
", ";
bool operator==(const Variables &) const
bool has(const std::string &) const
void push_back(const std::string &)
const std::vector< int > & channels() const
void print(std::ostream &) const
std::vector< std::string > vars_
size_t find(const std::string &) const
bool operator<=(const Variables &) const
Variables & operator+=(const Variables &)
std::vector< int > channels_
The namespace for the main oops code.