Skip to content

Commit

Permalink
Call to boost::size to get the number of 2WT, 3WT and Connectables fr…
Browse files Browse the repository at this point in the history
…om a VL/substation

Signed-off-by: Sébastien LAIGRE <slaigre@silicom.fr>
  • Loading branch information
sebalaig committed Jul 30, 2020
1 parent 03133fd commit 9d05f88
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
5 changes: 1 addition & 4 deletions include/powsybl/iidm/VoltageLevel.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ stdcxx::Reference<T> VoltageLevel::getConnectable(const std::string& id) {

template <typename T, typename>
unsigned long VoltageLevel::getConnectableCount() const {
const auto& terminals = getTerminals();
return std::count_if(std::begin(terminals), std::end(terminals), [](const Terminal& terminal) {
return Terminal::isInstanceOf<T>(terminal);
});
return boost::size(getConnectables<T>());
}

template <typename T, typename>
Expand Down
12 changes: 2 additions & 10 deletions src/iidm/Substation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ Network& Substation::getNetwork() {
}

unsigned long Substation::getThreeWindingsTransformerCount() const {
unsigned long res = 0UL;
for (const auto& it : m_voltageLevels) {
res += it.get().getConnectableCount<ThreeWindingsTransformer>();
}
return res / 3UL;
return boost::size(getThreeWindingsTransformers());
}

stdcxx::const_range<ThreeWindingsTransformer> Substation::getThreeWindingsTransformers() const {
Expand Down Expand Up @@ -86,11 +82,7 @@ const std::string& Substation::getTso() const {
}

unsigned long Substation::getTwoWindingsTransformerCount() const {
unsigned long res = 0UL;
for (const auto& it : m_voltageLevels) {
res += it.get().getConnectableCount<TwoWindingsTransformer>();
}
return res / 2UL;
return boost::size(getTwoWindingsTransformers());
}

stdcxx::const_range<TwoWindingsTransformer> Substation::getTwoWindingsTransformers() const {
Expand Down
5 changes: 1 addition & 4 deletions src/iidm/VoltageLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ stdcxx::range<Battery> VoltageLevel::getBatteries() {
}

unsigned long VoltageLevel::getConnectableCount() const {
const auto& terminals = getTerminals();
return std::count_if(std::begin(terminals), std::end(terminals), [](const Terminal& terminal) {
return terminal.getConnectable();
});
return boost::size(getConnectables<Connectable>());
}

unsigned long VoltageLevel::getDanglingLineCount() const {
Expand Down

0 comments on commit 9d05f88

Please sign in to comment.