@@ -612,11 +612,16 @@ void parseConditionsMechanisms(
612
612
}
613
613
614
614
void parseConditionsModifications (const nlohmann::json& it,
615
- SimulationConfig::ModificationMap & buf) {
615
+ std::vector< SimulationConfig::Modification> & buf) {
616
616
const auto sectionIt = it.find (" modifications" );
617
- if (sectionIt == it.end ()) {
617
+ if (sectionIt == it.end () || sectionIt-> is_null () ) {
618
618
return ;
619
619
}
620
+ if (!sectionIt->is_array ()) {
621
+ throw SonataError (" `modifications` must be an array" );
622
+ }
623
+ buf.reserve (sectionIt->size ());
624
+
620
625
for (auto & mIt : sectionIt->items ()) {
621
626
const auto valueIt = mIt .value ();
622
627
const auto debugStr = fmt::format (" modification {}" , mIt .key ());
@@ -628,16 +633,18 @@ void parseConditionsModifications(const nlohmann::json& it,
628
633
case SimulationConfig::ModificationBase::ModificationType::TTX: {
629
634
SimulationConfig::ModificationTTX result;
630
635
result.type = type;
636
+ parseMandatory (valueIt, " name" , debugStr, result.name );
631
637
parseMandatory (valueIt, " node_set" , debugStr, result.nodeSet );
632
- buf[ mIt . key ()] = result;
638
+ buf. push_back ( std::move ( result)) ;
633
639
break ;
634
640
}
635
641
case SimulationConfig::ModificationBase::ModificationType::ConfigureAllSections: {
636
642
SimulationConfig::ModificationConfigureAllSections result;
637
643
result.type = type;
644
+ parseMandatory (valueIt, " name" , debugStr, result.name );
638
645
parseMandatory (valueIt, " node_set" , debugStr, result.nodeSet );
639
646
parseMandatory (valueIt, " section_configure" , debugStr, result.sectionConfigure );
640
- buf[ mIt . key ()] = result;
647
+ buf. push_back ( std::move ( result)) ;
641
648
break ;
642
649
}
643
650
default :
@@ -1383,6 +1390,11 @@ const SimulationConfig::Conditions& SimulationConfig::getConditions() const noex
1383
1390
return _conditions;
1384
1391
}
1385
1392
1393
+ const std::vector<SimulationConfig::Modification>& SimulationConfig::Conditions::getModifications ()
1394
+ const noexcept {
1395
+ return modifications;
1396
+ }
1397
+
1386
1398
const std::string& SimulationConfig::getNetwork () const noexcept {
1387
1399
return _network;
1388
1400
}
@@ -1445,20 +1457,5 @@ const std::string& SimulationConfig::getExpandedJSON() const {
1445
1457
return _expandedJSON;
1446
1458
}
1447
1459
1448
- std::set<std::string> SimulationConfig::Conditions::listModificationNames () const {
1449
- return getMapKeys (modifications);
1450
- }
1451
-
1452
- const SimulationConfig::Modification& SimulationConfig::Conditions::getModification (
1453
- const std::string& name) const {
1454
- const auto it = modifications.find (name);
1455
- if (it == modifications.end ()) {
1456
- throw SonataError (
1457
- fmt::format (" The modification '{}' is not present in the simulation config file" ,
1458
- name));
1459
- }
1460
- return it->second ;
1461
- }
1462
-
1463
1460
} // namespace sonata
1464
1461
} // namespace bbp
0 commit comments