Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ HeaderFilterRegex: 'include/powsybl/.*|src/.*|extensions/.*|test/.*'

CheckOptions:
- { key: readability-function-cognitive-complexity.IgnoreMacros, value: true }

ExtraArgsBefore:
- '-Wno-unknown-warning-option'
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install Boost
run: |
sudo apt-get update -y
sudo apt-get install -y libboost-all-dev
sudo apt-get install -y libboost1.74-all-dev

- name: Checkout sources
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 #v4.1.6
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
- name: Install Boost
run: |
sudo apt-get update -y
sudo apt-get install -y libboost-all-dev
sudo apt-get install -y libboost1.74-all-dev

- name: Checkout sources
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 #v4.1.6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install Boost
run: |
sudo apt-get update -y
sudo apt-get install -y libboost-all-dev
sudo apt-get install -y libboost1.74-all-dev

- name: Install clang-tidy
run: |
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -pedantic -Wswitch-enum")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 13)
message(STATUS "Use of GCC version greater than 13: activate specific flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=dangling-reference")
endif()
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
# set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -D_GLIBCXX_DEBUG")
elseif (MSVC)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ To build powsybl-iidm4cpp, you need:

### Ubuntu 20.04
```
$> apt install -y cmake g++ git libboost-all-dev libxml2-dev make
$> apt install -y cmake g++ git libboost1.74-all-dev libxml2-dev make
```

### Ubuntu 18.04
```
$> apt install -y g++ git libboost-all-dev libxml2-dev make wget
$> apt install -y g++ git libboost1.74-all-dev libxml2-dev make wget
```

**Note:** Under Ubuntu 18.04, the default CMake package is too old (3.10), so you have to install it manually:
Expand Down
2 changes: 2 additions & 0 deletions src/iidm/AbstractComponentsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <powsybl/math/GraphUtil.hpp>
#include <powsybl/stdcxx/format.hpp>

#include <chrono>

namespace powsybl {

namespace iidm {
Expand Down
6 changes: 4 additions & 2 deletions src/iidm/Bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ double Bus::getP() const {
}
double p = 0;
for (const Terminal& terminal : getConnectedTerminals()) {
const Connectable& connectable = terminal.getConnectable();
stdcxx::CReference<Connectable> refConnectable = terminal.getConnectable();
const Connectable& connectable = refConnectable.get();
switch (connectable.getType()) {
case ConnectableType::BUSBAR_SECTION:
case ConnectableType::SHUNT_COMPENSATOR:
Expand Down Expand Up @@ -138,7 +139,8 @@ double Bus::getQ() const {
}
double q = 0;
for (const Terminal& terminal : getConnectedTerminals()) {
const Connectable& connectable = terminal.getConnectable();
stdcxx::CReference<Connectable> refConnectable = terminal.getConnectable();
const Connectable& connectable = refConnectable.get();
switch (connectable.getType()) {
case ConnectableType::BUSBAR_SECTION:
case ConnectableType::LINE:
Expand Down
3 changes: 2 additions & 1 deletion src/iidm/BusBreakerVoltageLevelTopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ bool CalculatedBusTopology::isBusValid(const MergedBus::BusSet& buses) const {

for (const auto& bus : buses) {
for (const auto& terminal : bus.get().getConnectedTerminals()) {
const auto& connectable = terminal.getConnectable().get();
stdcxx::CReference<Connectable> refConnectable = terminal.getConnectable();
const auto& connectable = refConnectable.get();
switch (connectable.getType()) {
case ConnectableType::LINE:
case ConnectableType::TWO_WINDINGS_TRANSFORMER:
Expand Down
5 changes: 3 additions & 2 deletions src/iidm/NodeBreakerVoltageLevelTopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ bool CalculatedBusTopology::isBusValid(const node_breaker_voltage_level::Graph&
for (unsigned long vertex : vertices) {
const auto& terminal = graph.getVertexObject(vertex);
if (static_cast<bool>(terminal)) {
const auto& connectable = terminal.get().getConnectable();
const auto& connectableType = connectable.get().getType();
stdcxx::Reference<Connectable> refConnectable = terminal.get().getConnectable();
const auto& connectable = refConnectable.get();
const auto& connectableType = connectable.getType();

switch (connectableType) {
case ConnectableType::LINE:
Expand Down
3 changes: 2 additions & 1 deletion src/iidm/TopologyVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ void TopologyVisitor::visitDanglingLine(const DanglingLine& /*danglingLine*/) {

void TopologyVisitor::visitEquipments(const stdcxx::const_range<Terminal>& terminals, TopologyVisitor& visitor) {
for (const Terminal& terminal : terminals) {
const Connectable& connectable = terminal.getConnectable();
stdcxx::CReference<Connectable> refConnectable = terminal.getConnectable();
const Connectable& connectable = refConnectable.get();
switch (connectable.getType()) {
case ConnectableType::BUSBAR_SECTION:
visitor.visitBusbarSection(dynamic_cast<const BusbarSection&>(connectable));
Expand Down
2 changes: 1 addition & 1 deletion src/iidm/ValidationUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void checkRatioTapChangerRegulation(const Validable& validable, bool regulating,
if (!regulationTerminal) {
throwExceptionOrWarningForRtc(validable, loadTapChangingCapabilities, "a regulation terminal has to be set for a regulating ratio tap changer");
}
if (!stdcxx::areSame(regulationTerminal.get().getVoltageLevel().getNetwork(), network)) {
if (regulationTerminal && !stdcxx::areSame(regulationTerminal.get().getVoltageLevel().getNetwork(), network)) {
throwExceptionOrWarningForRtc(validable, loadTapChangingCapabilities, "regulation terminal is not part of the network");
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/iidm/converter/xml/BusBreakerViewSwitchXml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ Switch& BusBreakerViewSwitchXml::readRootElementAttributes(VoltageLevel::BusBrea
void BusBreakerViewSwitchXml::writeRootElementAttributes(const Switch& sw, const VoltageLevel& voltageLevel, NetworkXmlWriterContext& context) const {
AbstractSwitchXml::writeRootElementAttributes(sw, voltageLevel, context);
const VoltageLevel::BusBreakerView& view = voltageLevel.getBusBreakerView();
const Bus& bus1 = view.getBus1(sw.getId());
const Bus& bus2 = view.getBus2(sw.getId());
stdcxx::CReference<powsybl::iidm::Bus> refBus1 = view.getBus1(sw.getId());
stdcxx::CReference<powsybl::iidm::Bus> refBus2 = view.getBus2(sw.getId());
const Bus& bus1 = refBus1.get();
const Bus& bus2 = refBus2.get();
context.getWriter().writeAttribute(BUS1, context.getAnonymizer().anonymizeString(bus1.getId()));
context.getWriter().writeAttribute(BUS2, context.getAnonymizer().anonymizeString(bus2.getId()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/iidm/converter/xml/IidmXmlVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ std::string IidmXmlVersion::getXsd() const {
const IidmXmlVersion& IidmXmlVersion::of(const std::string& version, const std::string& separator) {
for (const auto& v : all()) {
if (v.get().toString(separator) == version) {
return v;
return v.get();
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/iidm/converter/xml/TerminalRefXml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ void TerminalRefXml::writeTerminalRef(const Terminal& terminal, NetworkXmlWriter
}

void TerminalRefXml::writeTerminalRef(const Terminal& terminal, NetworkXmlWriterContext& context, const std::string& nsPrefix, const std::string& elementName, powsybl::xml::XmlStreamWriter& writer) {
const auto& c = terminal.getConnectable();
stdcxx::CReference<Connectable> refConnectable = terminal.getConnectable();
const auto& c = refConnectable.get();
if (!context.getFilter().test(c)) {
throw PowsyblException(stdcxx::format("Oups, terminal ref point to a filtered equipment %1%", c.get().getId()));
throw PowsyblException(stdcxx::format("Oups, terminal ref point to a filtered equipment %1%", c.getId()));
}
if (terminal.getVoltageLevel().getTopologyKind() == TopologyKind::NODE_BREAKER &&
context.getOptions().getTopologyLevel() != TopologyLevel::NODE_BREAKER &&
Expand Down
6 changes: 4 additions & 2 deletions src/iidm/converter/xml/VoltageLevelXml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ void VoltageLevelXml::writeBusBreakerTopology(const VoltageLevel& voltageLevel,
BusXml::getInstance().write(bus, voltageLevel, context);
}
for (const Switch& sw : voltageLevel.getBusBreakerView().getSwitches()) {
const Bus& b1 = voltageLevel.getBusBreakerView().getBus1(context.getAnonymizer().anonymizeString(sw.getId()));
const Bus& b2 = voltageLevel.getBusBreakerView().getBus2(context.getAnonymizer().anonymizeString(sw.getId()));
stdcxx::CReference<powsybl::iidm::Bus> refBus1 = voltageLevel.getBusBreakerView().getBus1(context.getAnonymizer().anonymizeString(sw.getId()));
stdcxx::CReference<powsybl::iidm::Bus> refBus2 = voltageLevel.getBusBreakerView().getBus2(context.getAnonymizer().anonymizeString(sw.getId()));
const Bus& b1 = refBus1.get();
const Bus& b2 = refBus2.get();
if (!context.getFilter().test(b1) || !context.getFilter().test(b2)) {
continue;
}
Expand Down
Loading