diff --git a/.clang-tidy b/.clang-tidy index 99f071bac..ee78c1b6c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -30,3 +30,6 @@ HeaderFilterRegex: 'include/powsybl/.*|src/.*|extensions/.*|test/.*' CheckOptions: - { key: readability-function-cognitive-complexity.IgnoreMacros, value: true } + +ExtraArgsBefore: + - '-Wno-unknown-warning-option' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d3f7a66b..d883b9800 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 1266fe9f8..b979af9d3 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -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: | diff --git a/CMakeLists.txt b/CMakeLists.txt index a01822dc0..9653ccc67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/README.md b/README.md index 3ecb57eb8..99db40a5e 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/src/iidm/AbstractComponentsManager.cpp b/src/iidm/AbstractComponentsManager.cpp index e5646725d..7f81899a8 100644 --- a/src/iidm/AbstractComponentsManager.cpp +++ b/src/iidm/AbstractComponentsManager.cpp @@ -18,6 +18,8 @@ #include #include +#include + namespace powsybl { namespace iidm { diff --git a/src/iidm/Bus.cpp b/src/iidm/Bus.cpp index 9007b8ba8..a04b2abc7 100644 --- a/src/iidm/Bus.cpp +++ b/src/iidm/Bus.cpp @@ -106,7 +106,8 @@ double Bus::getP() const { } double p = 0; for (const Terminal& terminal : getConnectedTerminals()) { - const Connectable& connectable = terminal.getConnectable(); + stdcxx::CReference refConnectable = terminal.getConnectable(); + const Connectable& connectable = refConnectable.get(); switch (connectable.getType()) { case ConnectableType::BUSBAR_SECTION: case ConnectableType::SHUNT_COMPENSATOR: @@ -138,7 +139,8 @@ double Bus::getQ() const { } double q = 0; for (const Terminal& terminal : getConnectedTerminals()) { - const Connectable& connectable = terminal.getConnectable(); + stdcxx::CReference refConnectable = terminal.getConnectable(); + const Connectable& connectable = refConnectable.get(); switch (connectable.getType()) { case ConnectableType::BUSBAR_SECTION: case ConnectableType::LINE: diff --git a/src/iidm/BusBreakerVoltageLevelTopology.cpp b/src/iidm/BusBreakerVoltageLevelTopology.cpp index debc17e07..32aa3dd51 100644 --- a/src/iidm/BusBreakerVoltageLevelTopology.cpp +++ b/src/iidm/BusBreakerVoltageLevelTopology.cpp @@ -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 refConnectable = terminal.getConnectable(); + const auto& connectable = refConnectable.get(); switch (connectable.getType()) { case ConnectableType::LINE: case ConnectableType::TWO_WINDINGS_TRANSFORMER: diff --git a/src/iidm/NodeBreakerVoltageLevelTopology.cpp b/src/iidm/NodeBreakerVoltageLevelTopology.cpp index abfc9b196..59cceb148 100644 --- a/src/iidm/NodeBreakerVoltageLevelTopology.cpp +++ b/src/iidm/NodeBreakerVoltageLevelTopology.cpp @@ -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(terminal)) { - const auto& connectable = terminal.get().getConnectable(); - const auto& connectableType = connectable.get().getType(); + stdcxx::Reference refConnectable = terminal.get().getConnectable(); + const auto& connectable = refConnectable.get(); + const auto& connectableType = connectable.getType(); switch (connectableType) { case ConnectableType::LINE: diff --git a/src/iidm/TopologyVisitor.cpp b/src/iidm/TopologyVisitor.cpp index aae5a4dd5..7499885a5 100644 --- a/src/iidm/TopologyVisitor.cpp +++ b/src/iidm/TopologyVisitor.cpp @@ -40,7 +40,8 @@ void TopologyVisitor::visitDanglingLine(const DanglingLine& /*danglingLine*/) { void TopologyVisitor::visitEquipments(const stdcxx::const_range& terminals, TopologyVisitor& visitor) { for (const Terminal& terminal : terminals) { - const Connectable& connectable = terminal.getConnectable(); + stdcxx::CReference refConnectable = terminal.getConnectable(); + const Connectable& connectable = refConnectable.get(); switch (connectable.getType()) { case ConnectableType::BUSBAR_SECTION: visitor.visitBusbarSection(dynamic_cast(connectable)); diff --git a/src/iidm/ValidationUtils.cpp b/src/iidm/ValidationUtils.cpp index e727de376..105d81738 100644 --- a/src/iidm/ValidationUtils.cpp +++ b/src/iidm/ValidationUtils.cpp @@ -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"); } } diff --git a/src/iidm/converter/xml/BusBreakerViewSwitchXml.cpp b/src/iidm/converter/xml/BusBreakerViewSwitchXml.cpp index 2b9ce2776..d080f7516 100644 --- a/src/iidm/converter/xml/BusBreakerViewSwitchXml.cpp +++ b/src/iidm/converter/xml/BusBreakerViewSwitchXml.cpp @@ -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 refBus1 = view.getBus1(sw.getId()); + stdcxx::CReference 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())); } diff --git a/src/iidm/converter/xml/IidmXmlVersion.cpp b/src/iidm/converter/xml/IidmXmlVersion.cpp index 660dc1dc0..2945180c2 100644 --- a/src/iidm/converter/xml/IidmXmlVersion.cpp +++ b/src/iidm/converter/xml/IidmXmlVersion.cpp @@ -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(); } } diff --git a/src/iidm/converter/xml/TerminalRefXml.cpp b/src/iidm/converter/xml/TerminalRefXml.cpp index dc7d34852..5835e746c 100644 --- a/src/iidm/converter/xml/TerminalRefXml.cpp +++ b/src/iidm/converter/xml/TerminalRefXml.cpp @@ -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 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 && diff --git a/src/iidm/converter/xml/VoltageLevelXml.cpp b/src/iidm/converter/xml/VoltageLevelXml.cpp index dd4524c46..f6171070c 100644 --- a/src/iidm/converter/xml/VoltageLevelXml.cpp +++ b/src/iidm/converter/xml/VoltageLevelXml.cpp @@ -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 refBus1 = voltageLevel.getBusBreakerView().getBus1(context.getAnonymizer().anonymizeString(sw.getId())); + stdcxx::CReference 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; }