Skip to content

Commit

Permalink
Add function load Properties
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Jun 10, 2024
1 parent f2b01b3 commit 6df0fd9
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/libs/antares/study/parts/hydro/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,34 @@ void PartHydro::reset()
}
}

using setProp = std::function<void (IniFile::Property*, PartHydro&)>;

static bool loadProperties(Study& study, IniFile::Property* property, const std::string& filename, setProp f)
{
if (!property)
return false;

bool ret = true;

// Browse all properties
for (; property; property = property->next)
{
AreaName id = property->key;
id.toLower();

Area* area = study.areas.find(id);
if (area)
{
f(property, area->hydro);
}
else
{
logs.warning() << filename << ": `" << id << "`: Unknown area";
}
}
return ret;
}

bool PartHydro::LoadFromFolder(Study& study, const AnyString& folder)
{
auto& buffer = study.bufferLoadingTS;
Expand Down Expand Up @@ -402,6 +430,13 @@ bool PartHydro::LoadFromFolder(Study& study, const AnyString& folder)
}
}
}

auto setIntermonthlyBreakdown = [&ret](IniFile::Property* p, PartHydro& h){
ret = p->value.to<double>(h.intermonthlyBreakdown) && ret;
};

loadProperties(study, section->firstProperty, buffer, setIntermonthlyBreakdown);

if ((section = ini.find("follow load")))
{
if ((property = section->firstProperty))
Expand Down

0 comments on commit 6df0fd9

Please sign in to comment.