Skip to content

Commit 3c06b3c

Browse files
committed
Add TomlConfig typedef to insulate downstream code from TOML library
1 parent 219d709 commit 3c06b3c

6 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/core/param/param.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void Param::MergeJsonPatch(const std::string& patch) {
146146
}
147147

148148
// -----------------------------------------------------------------------------
149-
void AssignThreadSafetyMechanism(const toml::table& config, Param* param) {
149+
void AssignThreadSafetyMechanism(const TomlConfig& config, Param* param) {
150150
auto value =
151151
config.at_path("simulation.thread_safety_mechanism").value<std::string>();
152152
if (!value) {
@@ -164,7 +164,7 @@ void AssignThreadSafetyMechanism(const toml::table& config, Param* param) {
164164
}
165165

166166
// -----------------------------------------------------------------------------
167-
void AssignMappedDataArrayMode(const toml::table& config, Param* param) {
167+
void AssignMappedDataArrayMode(const TomlConfig& config, Param* param) {
168168
auto value =
169169
config.at_path("performance.mapped_data_array_mode").value<std::string>();
170170
if (!value) {
@@ -186,7 +186,7 @@ void AssignMappedDataArrayMode(const toml::table& config, Param* param) {
186186
}
187187

188188
// -----------------------------------------------------------------------------
189-
void AssignBoundSpaceMode(const toml::table& config, Param* param) {
189+
void AssignBoundSpaceMode(const TomlConfig& config, Param* param) {
190190
auto value = config.at_path("simulation.bound_space").value<std::string>();
191191
if (!value) {
192192
return;
@@ -206,7 +206,7 @@ void AssignBoundSpaceMode(const toml::table& config, Param* param) {
206206
}
207207

208208
// -----------------------------------------------------------------------------
209-
void Param::AssignFromConfig(const toml::table& config) {
209+
void Param::AssignFromConfig(const TomlConfig& config) {
210210
// group parameters
211211
for (auto& el : groups_) {
212212
el.second->AssignFromConfig(config);

src/core/param/param.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ struct Param {
645645
bool plot_memory_layout = false;
646646

647647
/// Assign values from config file to variables
648-
void AssignFromConfig(const toml::table&);
648+
void AssignFromConfig(const TomlConfig&);
649649

650650
private:
651651
friend class DiffusionTest_CopyOldData_Test;

src/core/param/param_group.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ ParamGroupUid ParamGroupUidGenerator::NewUid() { return counter_++; }
2828

2929
ParamGroup::~ParamGroup() = default;
3030

31-
void ParamGroup::AssignFromConfig(const toml::table&) {}
31+
void ParamGroup::AssignFromConfig(const TomlConfig&) {}
3232

3333
} // namespace bdm

src/core/param/param_group.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
namespace bdm {
2323

24+
/// Typedef for TOML config table, insulating downstream code from the
25+
/// concrete TOML library in use.
26+
using TomlConfig = toml::table;
27+
2428
struct Param;
2529

2630
using ParamGroupUid = uint64_t;
@@ -52,7 +56,7 @@ struct ParamGroup {
5256
protected:
5357
/// Assign values from a toml config file.\n
5458
/// Can be omitted if toml file support is not required.
55-
virtual void AssignFromConfig(const toml::table&);
59+
virtual void AssignFromConfig(const TomlConfig&);
5660

5761
private:
5862
friend struct Param;

src/neuroscience/param.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace neuroscience {
2020

2121
const ParamGroupUid Param::kUid = ParamGroupUidGenerator::Get()->NewUid();
2222

23-
void Param::AssignFromConfig(const toml::table& config) {
23+
void Param::AssignFromConfig(const TomlConfig& config) {
2424
BDM_ASSIGN_CONFIG_VALUE(neurite_default_actual_length,
2525
"neuroscience.neurite_default_actual_length");
2626
BDM_ASSIGN_CONFIG_VALUE(neurite_default_density,

src/neuroscience/param.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ struct Param : public ParamGroup {
107107

108108
protected:
109109
/// Assign values from config file to variables
110-
void AssignFromConfig(const toml::table&) override;
110+
void AssignFromConfig(const TomlConfig&) override;
111111
};
112112

113113
} // namespace neuroscience

0 commit comments

Comments
 (0)