Skip to content

Commit

Permalink
[DEV] rebuildIndex protected
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Dec 18, 2023
1 parent a52ea67 commit 92b2896
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/libs/antares/study/parts/common/cluster_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ typename std::shared_ptr<ClusterT> ClusterList<ClusterT>::detach(iterator i)
{
SharedPtr c = *i;
clusters.erase(i);
rebuildIndex();
return c;
}

Expand Down
23 changes: 12 additions & 11 deletions src/libs/antares/study/parts/common/cluster_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class ClusterList
//! const iterator
using const_iterator = typename Vect::const_iterator;

public:
//! \name Constructor & Destructor
//@{
/*!
Expand Down Expand Up @@ -171,23 +170,14 @@ class ClusterList
*/
void markAsModified() const;

/*!
** \brief Rebuild the index of clusters
**
** As a list of clusters is a hash table, it is not
** possible to directly accees to a clusters from its index.
** However an index can be built but it must be re-built when
** the hash table is modified.
*/
void rebuildIndex();


/*!
** \brief Get the size (bytes) occupied in memory by a `ClusterList` structure
** \return A size (in bytes)
*/
uint64_t memoryUsage() const;

public:
//! All clusters
Vect clusters;

Expand Down Expand Up @@ -230,6 +220,17 @@ class ClusterList
*/
uint removeDisabledClusters();

protected:
/*!
** \brief Rebuild the index of clusters
**
** As a list of clusters is a hash table, it is not
** possible to directly accees to a clusters from its index.
** However an index can be built but it must be re-built when
** the hash table is modified.
*/
void rebuildIndex();

//@}
}; // class ClusterList
} // namespace Data
Expand Down
7 changes: 0 additions & 7 deletions src/libs/antares/study/parts/thermal/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,6 @@ uint PartThermal::prepareClustersInMustRunMode()
}
} while (mustContinue);

// if some thermal cluster has been moved, we must rebuild all the indexes
if (count)
{
list.rebuildIndex();
mustrunList.rebuildIndex();
}

return count;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ bool Create::performWL(Context& ctx)
ctx.cluster->setName(pFuturPlantName);
ctx.cluster->reset();
(ctx.area)->thermal.list.add(std::shared_ptr<Data::ThermalCluster>(ctx.cluster));
(ctx.area)->thermal.list.rebuildIndex();
(ctx.area)->thermal.prepareAreaWideIndexes();
}
else
Expand Down
1 change: 0 additions & 1 deletion src/ui/simulator/toolbox/input/renewable-cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ void RenewableCluster::internalDeletePlant(void*)
Refresh();
MarkTheStudyAsModified();
updateInnerValues();
pArea->renewable.list.rebuildIndex();
pArea->renewable.prepareAreaWideIndexes();
study->uiinfo->reload();
}
Expand Down
3 changes: 0 additions & 3 deletions src/ui/simulator/toolbox/input/thermal-cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ void ThermalCluster::internalDeletePlant(void*)
Refresh();
MarkTheStudyAsModified();
updateInnerValues();
pArea->thermal.list.rebuildIndex();
pArea->thermal.prepareAreaWideIndexes();
study->uiinfo->reload();

Expand Down Expand Up @@ -448,7 +447,6 @@ void ThermalCluster::internalAddPlant(void*)
cluster->setName(sFl);
cluster->reset();
pArea->thermal.list.add(cluster);
pArea->thermal.list.rebuildIndex();
pArea->thermal.prepareAreaWideIndexes();

// Update the list
Expand Down Expand Up @@ -527,7 +525,6 @@ void ThermalCluster::internalClonePlant(void*)
cluster->copyFrom(selectedPlant);

pArea->thermal.list.add(cluster);
pArea->thermal.list.rebuildIndex();
pArea->thermal.prepareAreaWideIndexes();

// Update the list
Expand Down

0 comments on commit 92b2896

Please sign in to comment.