Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Dec 16, 2024
1 parent 9ce46f8 commit a03866d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
18 changes: 11 additions & 7 deletions src/solver/systemParser/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#include "antares/solver/systemParser/converter.h"

#include <algorithm>

#include "antares/solver/systemParser/converter.h"
#include "antares/solver/systemParser/system.h"
#include "antares/study/system-model/system.h"

Expand All @@ -35,8 +36,8 @@ static std::pair<std::string, std::string> splitLibraryModelString(const std::st
size_t pos = s.find('.');
if (pos == std::string::npos)
{
throw std::runtime_error("Error while splitting library model: " + s +
"Correct format is lirabry.model");
throw std::runtime_error("Error while splitting library model: " + s
+ "Correct format is lirabry.model");
}

std::string library = s.substr(0, pos);
Expand All @@ -48,7 +49,8 @@ static const SystemModel::Model* getModel(const std::vector<SystemModel::Library
const std::string& libraryId,
const std::string& modelId)
{
auto lib = std::ranges::find_if(libraries, [&libraryId](const auto& l) { return l.Id() == libraryId; });
auto lib = std::ranges::find_if(libraries,
[&libraryId](const auto& l) { return l.Id() == libraryId; });
if (lib == libraries.end())
{
throw std::runtime_error("No libraries named: " + libraryId);
Expand All @@ -58,7 +60,8 @@ static const SystemModel::Model* getModel(const std::vector<SystemModel::Library
return &model;
}

static SystemModel::Component createComponent(const SystemParser::Component& c, const std::vector<SystemModel::Library>& libraries)
static SystemModel::Component createComponent(const SystemParser::Component& c,
const std::vector<SystemModel::Library>& libraries)
{
const auto [libraryId, modelId] = splitLibraryModelString(c.model);
SystemModel::ModelBuilder model_builder;
Expand All @@ -68,7 +71,7 @@ static SystemModel::Component createComponent(const SystemParser::Component& c,
SystemModel::ComponentBuilder component_builder;

std::map<std::string, double> parameters;
for (const auto& p : c.parameters)
for (const auto& p: c.parameters)
{
parameters.try_emplace(p.id, p.value);
}
Expand All @@ -81,7 +84,8 @@ static SystemModel::Component createComponent(const SystemParser::Component& c,
return component;
}

SystemModel::System convert(const SystemParser::System& parserSystem, const std::vector<SystemModel::Library>& libraries)
SystemModel::System convert(const SystemParser::System& parserSystem,
const std::vector<SystemModel::Library>& libraries)
{
std::vector<SystemModel::Component> components;
for (const auto& c: parserSystem.components)
Expand Down
5 changes: 3 additions & 2 deletions src/tests/src/solver/modelParser/testSystemConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

#include <antares/solver/systemParser/converter.h>
#include <antares/solver/systemParser/parser.h>
#include "antares/solver/modelParser/Library.h"
#include "antares/solver/modelConverter/modelConverter.h"
#include <antares/study/system-model/system.h>
#include "antares/solver/modelConverter/modelConverter.h"
#include "antares/solver/modelParser/Library.h"
#include "antares/study/system-model/library.h"

using namespace std::string_literals;
Expand All @@ -48,6 +48,7 @@ struct Fixture
SystemParser::Parser parser;
ModelParser::Library library;
SystemModel::Library lib;

Fixture()
{
library.id = "std";
Expand Down

0 comments on commit a03866d

Please sign in to comment.