Skip to content

Commit

Permalink
remove clusterName typedef
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Jan 27, 2025
1 parent 195a6a0 commit e4b34b3
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ ThermalCluster* AreaList::findClusterFromINIKey(const AnyString& key)
return nullptr;
}
AreaName parentName(key.c_str(), offset);
ClusterName id(key.c_str() + offset + 1, key.size() - (offset + 1));
std::string id(key.c_str() + offset + 1, key.size() - (offset + 1));
Area* parentArea = findFromName(parentName);
if (parentArea == nullptr)
{
Expand Down
2 changes: 0 additions & 2 deletions src/libs/antares/study/include/antares/study/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ class Correlation;
using AreaName = Yuni::CString<ant_k_area_name_max_length, false>;
//! Name of a single link
using AreaLinkName = Yuni::CString<ant_k_area_name_max_length * 2 + 1, false>;
//! Name of a single thermal
using ClusterName = std::string;

using ConstraintName = Yuni::CString<ant_k_constraint_name_max_length, false>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class Cluster

virtual ~Cluster() = default;

const ClusterName& id() const;
const ClusterName& name() const;
const std::string& id() const;
const std::string& name() const;
void setName(const AnyString& newname);
Yuni::String getFullName() const;

Expand Down Expand Up @@ -134,8 +134,8 @@ class Cluster
Matrix<> modulation;

protected:
Data::ClusterName pName;
Data::ClusterName pID;
std::string pName;
std::string pID;

std::string group_ = "OTHER";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ClusterList
** \param id ID of the cluster to find
** \return True if the cluster exists
*/
bool exists(const Data::ClusterName& id) const;
bool exists(const std::string& id) const;

auto each_enabled() const
{
Expand All @@ -83,12 +83,12 @@ class ClusterList
**
** The indexes for clusters will be rebuilt.
*/
bool rename(Data::ClusterName idToFind, Data::ClusterName newName);
bool rename(std::string idToFind, std::string newName);

/*!
** \brief Remove properly a cluster
*/
virtual bool remove(const Data::ClusterName& id);
virtual bool remove(const std::string& id);

//@}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/include/antares/study/study.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class Study: public Yuni::NonCopyable<Study>, public LayerData
** \param cluster The cluster
** \return True if the operation succeeded, false otherwise
*/
bool clusterRename(Cluster* cluster, ClusterName newName);
bool clusterRename(Cluster* cluster, std::string newName);
//@}

//! \name Read-only
Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/study/parts/common/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ Cluster::Cluster(Area* parent):
{
}

const ClusterName& Cluster::name() const
const std::string& Cluster::name() const
{
return pName;
}

const ClusterName& Cluster::id() const
const std::string& Cluster::id() const
{
return pID;
}
Expand Down
8 changes: 4 additions & 4 deletions src/libs/antares/study/parts/common/cluster_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ std::vector<std::shared_ptr<ClusterT>> ClusterList<ClusterT>::all() const
}

template<class ClusterT>
bool ClusterList<ClusterT>::exists(const Data::ClusterName& id) const
bool ClusterList<ClusterT>::exists(const std::string& id) const
{
return std::ranges::any_of(allClusters_, [&id](const auto& c) { return c->id() == id; });
}
Expand Down Expand Up @@ -164,7 +164,7 @@ void ClusterList<ClusterT>::rebuildIndexes()
}

template<class ClusterT>
bool ClusterList<ClusterT>::rename(Data::ClusterName idToFind, Data::ClusterName newName)
bool ClusterList<ClusterT>::rename(std::string idToFind, std::string newName)
{
if (idToFind.empty() or newName.empty())
{
Expand All @@ -181,7 +181,7 @@ bool ClusterList<ClusterT>::rename(Data::ClusterName idToFind, Data::ClusterName
boost::to_lower(idToFind);

// The new ID
Data::ClusterName newID = Antares::transformNameIntoID(newName);
std::string newID = Antares::transformNameIntoID(newName);

// Looking for the renewable clusters in the list
auto* cluster_ptr = this->findInAll(idToFind);
Expand Down Expand Up @@ -238,7 +238,7 @@ void ClusterList<ClusterT>::markAsModified() const
}

template<class ClusterT>
bool ClusterList<ClusterT>::remove(const Data::ClusterName& id)
bool ClusterList<ClusterT>::remove(const std::string& id)
{
auto nbDeletion = std::erase_if(allClusters_,
[&id](const SharedPtr& c) { return c->id() == id; });
Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/study/scenario-builder/rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ bool Rules::readThermalCluster(const AreaName::Vector& splitKey, String value, b
{
const AreaName& areaname = splitKey[1];
const uint year = splitKey[2].to<uint>();
const ClusterName& clustername = splitKey[3];
const std::string& clustername = splitKey[3];

if (clustername.empty())
{
Expand Down Expand Up @@ -163,7 +163,7 @@ bool Rules::readRenewableCluster(const AreaName::Vector& splitKey, String value,
{
const AreaName& areaname = splitKey[1];
const uint year = splitKey[2].to<uint>();
const ClusterName& clustername = splitKey[3];
const std::string& clustername = splitKey[3];

if (!study_.parameters.renewableGeneration.isClusters())
{
Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/study/study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ bool Study::areaRename(Area* area, AreaName newName)
}

// TODO VP: delete with GUI
bool Study::clusterRename(Cluster* cluster, ClusterName newName)
bool Study::clusterRename(Cluster* cluster, std::string newName)
{
// A name must not be empty
if (!cluster or newName.empty())
Expand All @@ -875,7 +875,7 @@ bool Study::clusterRename(Cluster* cluster, ClusterName newName)
newName = beautifyname.c_str();

// Preparing the new area ID
ClusterName newID = transformNameIntoID(newName);
std::string newID = transformNameIntoID(newName);
if (newID.empty())
{
logs.error() << "invalid id transformation";
Expand Down
2 changes: 1 addition & 1 deletion src/ui/action/handler/antares-study/area/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void Create::createActionsForAStandardAreaCopy(Context& ctx, bool copyPosition)
}

IAction* Create::StandardActionsToCopyThermalCluster(const Data::AreaName& area,
const Data::ClusterName& name)
const std::string& name)
{
using NodePlant = Antares::Action::AntaresStudy::ThermalCluster::Create;
using NodePlantCommonData = Antares::Action::AntaresStudy::ThermalCluster::CommonData;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/action/handler/antares-study/area/timeseries.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DataTimeseries : public IAction
private:
Data::TimeSeriesType pType;
Data::AreaName pOriginalAreaName;
Data::ClusterName pOriginalPlantName;
std::string pOriginalPlantName;

}; // class IAction

Expand Down
2 changes: 1 addition & 1 deletion src/ui/action/handler/antares-study/area/ts-generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DataTSGenerator : public IAction
private:
Data::TimeSeriesType pType;
Data::AreaName pOriginalAreaName;
Data::ClusterName pOriginalPlantName;
std::string pOriginalPlantName;

}; // class DataTSGenerator

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool Create::prepareWL(Context& ctx)
}

// Computing the futur ID of the area
Data::ClusterName id;
std::string id;
const Data::ThermalCluster* clusterFound = nullptr;

// finding the final area
Expand Down Expand Up @@ -154,7 +154,7 @@ bool Create::performWL(Context& ctx)
ctx.cluster = nullptr;
if (ctx.area)
{
Data::ClusterName id;
std::string id;

// source cluster
Data::Area* source = ctx.extStudy->areas.findFromName(pOriginalAreaName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Create : public IAction

public:
static IAction* StandardActionsToCopyThermalCluster(const Data::AreaName& area,
const Data::ClusterName& name);
const std::string& name);

public:
//! \name Constructor & Destructor
Expand Down
2 changes: 1 addition & 1 deletion src/ui/simulator/toolbox/input/thermal-cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void ThermalCluster::renameAggregate(Antares::Data::ThermalCluster* cluster,
WIP::Locker wip;
if (cluster && pArea && CurrentStudyIsValid())
{
ClusterName newPlantName;
std::string newPlantName;
wxStringToString(newName, newPlantName);

GetCurrentStudy()->clusterRename(cluster, newPlantName);
Expand Down

0 comments on commit e4b34b3

Please sign in to comment.