Skip to content

Commit

Permalink
Data for new modeler (4.1) : coding the data series repository
Browse files Browse the repository at this point in the history
  • Loading branch information
guilpier-code committed Jan 17, 2025
1 parent 965173f commit fe02503
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/solver/modeler/dataSeries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(SRC_DATA_SERIES
include/antares/solver/modeler/dataSeries/scenarioGroupRepo.h

timeSeriesSet.cpp
dataSeriesRepo.cpp
scenarioGroupRepo.cpp
)

Expand Down
19 changes: 19 additions & 0 deletions src/solver/modeler/dataSeries/dataSeriesRepo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdexcept>
#include "antares/solver/modeler/dataSeries/dataSeriesRepo.h"

namespace Antares::Solver::Modeler::DataSeries
{
void DataSeriesRepository::addDataSeries(std::unique_ptr<IDataSeries> dataSeries)
{
dataSeries_[dataSeries->name()] = std::move(dataSeries);
}
IDataSeries& DataSeriesRepository::getDataSeries(std::string setId)
{
if (!dataSeries_.contains(setId))
{
std::string error_message = "Data series repo : data series named '" + setId + "' does not exist.";
throw std::invalid_argument(error_message);
}
return *(dataSeries_[setId]);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@

#pragma once

#include <string>

namespace Antares::Solver::Modeler::DataSeries
{

class IDataSeries
{
public:
std::string name()
{
return name_;
}

virtual double getData(unsigned int rank, unsigned int hour) = 0;

private:
std::string name_;
};

} // namespace Antares::Solver::Modeler::DataSeries
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Antares::Solver::Modeler::DataSeries
class DataSeriesRepository
{
public:
void addDataSeries(std::string setId, IDataSeries* dataSeries);
void addDataSeries(std::unique_ptr<IDataSeries> dataSeries);
IDataSeries& getDataSeries(std::string setId);

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class TimeSeriesSet: public IDataSeries
public:
explicit TimeSeriesSet(std::string name, unsigned height);
void add(std::vector<double> ts);
std::string name();
double getData(unsigned int rank, unsigned int hour) override;

private:
Expand Down

0 comments on commit fe02503

Please sign in to comment.