Skip to content

Commit 3af14d7

Browse files
committed
Use inline definitions for simple getters
1 parent 01a04e5 commit 3af14d7

2 files changed

Lines changed: 22 additions & 44 deletions

File tree

lib/include/resdata/smspec_node.hpp

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,29 @@ class smspec_node {
117117
return this->cmp(other) > 0;
118118
}
119119

120-
int get_R1() const;
121-
int get_R2() const;
122-
const char *get_gen_key1() const;
123-
const char *get_gen_key2() const;
124-
rd_smspec_var_type get_var_type() const;
125-
int get_num() const;
126-
const char *get_wgname() const;
127-
const char *get_keyword() const;
128-
const char *get_unit() const;
129-
bool is_rate() const;
130-
bool is_total() const;
131-
bool is_historical() const;
132-
bool need_nums() const;
120+
[[nodiscard]] int get_R1() const;
121+
[[nodiscard]] int get_R2() const;
122+
[[nodiscard]] const char *get_gen_key1() const;
123+
[[nodiscard]] const char *get_gen_key2() const;
124+
[[nodiscard]] rd_smspec_var_type get_var_type() const { return var_type; };
125+
[[nodiscard]] int get_num() const { return num; };
126+
[[nodiscard]] const char *get_wgname() const;
127+
[[nodiscard]] const char *get_keyword() const;
128+
[[nodiscard]] const char *get_unit() const;
129+
[[nodiscard]] bool is_rate() const { return rate_variable; };
130+
[[nodiscard]] bool is_total() const { return total_variable; };
131+
[[nodiscard]] bool is_historical() const { return historical; };
132+
[[nodiscard]] bool need_nums() const;
133133
void fprintf__(FILE *stream) const;
134-
int get_params_index() const;
135-
float get_default() const;
136-
const std::array<int, 3> &get_ijk() const;
137-
const char *get_lgr_name() const;
138-
const std::array<int, 3> &get_lgr_ijk() const;
134+
[[nodiscard]] int get_params_index() const { return params_index; };
135+
[[nodiscard]] float get_default() const { return default_value; };
136+
// Will be garbage for smspec_nodes which do not have i,j,k
137+
[[nodiscard]] const std::array<int, 3> &get_ijk() const { return ijk; };
138+
[[nodiscard]] const char *get_lgr_name() const;
139+
// Will be garbage for smspec_nodes which are not related to an LGR.
140+
[[nodiscard]] const std::array<int, 3> &get_lgr_ijk() const {
141+
return lgr_ijk;
142+
};
139143
};
140144

141145
} // namespace rd

lib/resdata/smspec_node.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,6 @@ bool smspec_node_identify_total(const char *keyword,
533533

534534
namespace rd {
535535

536-
float smspec_node::get_default() const { return this->default_value; }
537-
538536
void smspec_node::set_lgr_ijk(int lgr_i, int lgr_j, int lgr_k) {
539537
lgr_ijk[0] = lgr_i;
540538
lgr_ijk[1] = lgr_j;
@@ -1032,12 +1030,6 @@ smspec_node::smspec_node(int param_index_, const char *keyword_,
10321030
set_gen_keys(key_join_string_);
10331031
}
10341032

1035-
int smspec_node::get_params_index() const { return this->params_index; }
1036-
1037-
// void smspec_node::set_params_index( int params_index_) {
1038-
// this->params_index = params_index_;
1039-
// }
1040-
10411033
namespace {
10421034

10431035
const char *get_cstring(const std::string &s) {
@@ -1065,31 +1057,13 @@ const char *smspec_node::get_keyword() const {
10651057
return get_cstring(this->keyword);
10661058
}
10671059

1068-
rd_smspec_var_type smspec_node::get_var_type() const { return this->var_type; }
1069-
1070-
int smspec_node::get_num() const { return this->num; }
1071-
1072-
bool smspec_node::is_rate() const { return this->rate_variable; }
1073-
1074-
bool smspec_node::is_total() const { return this->total_variable; }
1075-
1076-
bool smspec_node::is_historical() const { return this->historical; }
1077-
10781060
const char *smspec_node::get_unit() const { return this->unit.c_str(); }
10791061

1080-
// Will be garbage for smspec_nodes which do not have i,j,k
1081-
const std::array<int, 3> &smspec_node::get_ijk() const { return this->ijk; }
1082-
10831062
// Will be NULL for smspec_nodes which are not related to an LGR.
10841063
const char *smspec_node::get_lgr_name() const {
10851064
return get_cstring(this->lgr_name);
10861065
}
10871066

1088-
// Will be garbage for smspec_nodes which are not related to an LGR.
1089-
const std::array<int, 3> &smspec_node::get_lgr_ijk() const {
1090-
return this->lgr_ijk;
1091-
}
1092-
10931067
/*
10941068
Will return -1 for smspec_node variables which are not
10951069
of type RD_SMSPEC_REGION_2_REGION_VAR.

0 commit comments

Comments
 (0)