From b74f75cdca3123a317fe3dc397f6270ee35ee45e Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 25 Sep 2024 11:01:57 +0200 Subject: [PATCH 01/36] add worfklow Signed-off-by: Laurynas Jagutis --- .github/workflows/build.yml | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4e7b825 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,38 @@ +name: Build + +on: + push: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Initialize and update submodules + run: | + git submodule update --init --recursive + + - name: Install C++ dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + libeigen3-dev \ + libboost-all-dev \ + nlohmann-json3-dev \ + libmsgpack-dev + + # - name: Create build directory + # run: mkdir -p build + + - name: Configure with CMake + run: cmake -S . -B build + + - name: Build with CMake + run: cmake --build build --config Release + + - name: Run tests + run: ctest --test-dir build -V From 26810ee03d04619b95be876654169a8ad942e962 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 25 Sep 2024 11:03:41 +0200 Subject: [PATCH 02/36] adjust workflow Signed-off-by: Laurynas Jagutis --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e7b825..2f5f8aa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,9 +12,9 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Initialize and update submodules - run: | - git submodule update --init --recursive + # - name: Initialize and update submodules + # run: | + # git submodule update --init --recursive - name: Install C++ dependencies run: | From 3a6389fabb530f84e9669aa63074926ae773e18e Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 25 Sep 2024 11:16:22 +0200 Subject: [PATCH 03/36] change ssh to http for testing purposes Signed-off-by: Laurynas Jagutis --- .github/workflows/build.yml | 6 +++--- .gitmodules | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f5f8aa..4e7b825 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,9 +12,9 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - # - name: Initialize and update submodules - # run: | - # git submodule update --init --recursive + - name: Initialize and update submodules + run: | + git submodule update --init --recursive - name: Install C++ dependencies run: | diff --git a/.gitmodules b/.gitmodules index cfe160c..bd10cd9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,7 +2,12 @@ # # SPDX-License-Identifier: MPL-2.0 +# [submodule "deps/power-grid-model"] +# path = deps/power-grid-model +# url = git@github.com:PowerGridModel/power-grid-model.git +# branch = main + [submodule "deps/power-grid-model"] path = deps/power-grid-model - url = git@github.com:PowerGridModel/power-grid-model.git + url = https://github.com/PowerGridModel/power-grid-model.git branch = main From 1b8ce2788c23a90352d69c1574f36fa7bd76e026 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 25 Sep 2024 11:26:03 +0200 Subject: [PATCH 04/36] adjust workflow Signed-off-by: Laurynas Jagutis --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e7b825..26f644f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,6 @@ jobs: libeigen3-dev \ libboost-all-dev \ nlohmann-json3-dev \ - libmsgpack-dev # - name: Create build directory # run: mkdir -p build From 800fdd37ac1950329fe4ffdde3c1fda5f99d100c Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 25 Sep 2024 13:33:00 +0200 Subject: [PATCH 05/36] try out brew Signed-off-by: Laurynas Jagutis --- .github/workflows/build.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 26f644f..6fcbb68 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,16 +16,24 @@ jobs: run: | git submodule update --init --recursive + # - name: Install C++ dependencies + # run: | + # sudo apt-get update + # sudo apt-get install -y \ + # libeigen3-dev \ + # libboost-all-dev \ + # nlohmann-json3-dev \ + + # # - name: Create build directory + # # run: mkdir -p build + + - name: Enable brew + run: | + echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH + - name: Install C++ dependencies run: | - sudo apt-get update - sudo apt-get install -y \ - libeigen3-dev \ - libboost-all-dev \ - nlohmann-json3-dev \ - - # - name: Create build directory - # run: mkdir -p build + brew install boost eigen nlohmann-json msgpack-cxx doctest - name: Configure with CMake run: cmake -S . -B build From 427a39729720ec7129cff45a9ee5c31c322ff342 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 25 Sep 2024 14:18:22 +0200 Subject: [PATCH 06/36] enable dev build for testing Signed-off-by: Laurynas Jagutis --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6fcbb68..6b2f600 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: brew install boost eigen nlohmann-json msgpack-cxx doctest - name: Configure with CMake - run: cmake -S . -B build + run: cmake -S . -B build -DPGM_IO_ENABLE_DEV_BUILD=ON - name: Build with CMake run: cmake --build build --config Release From 89694c8e11dfee5de84eb5c8b27197a2bf73aa1b Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 30 Sep 2024 09:03:15 +0200 Subject: [PATCH 07/36] remove comments Signed-off-by: Laurynas Jagutis --- .github/workflows/build.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6b2f600..8860490 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,17 +16,6 @@ jobs: run: | git submodule update --init --recursive - # - name: Install C++ dependencies - # run: | - # sudo apt-get update - # sudo apt-get install -y \ - # libeigen3-dev \ - # libboost-all-dev \ - # nlohmann-json3-dev \ - - # # - name: Create build directory - # # run: mkdir -p build - - name: Enable brew run: | echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH From b813f03dee3d5f6eeb55cc00393627f068753261 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 30 Sep 2024 14:10:55 +0200 Subject: [PATCH 08/36] add new workflow Signed-off-by: Laurynas Jagutis --- .github/workflows/new-build.yml | 145 ++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 .github/workflows/new-build.yml diff --git a/.github/workflows/new-build.yml b/.github/workflows/new-build.yml new file mode 100644 index 0000000..ae579fa --- /dev/null +++ b/.github/workflows/new-build.yml @@ -0,0 +1,145 @@ +# SPDX-FileCopyrightText: Contributors to the Power Grid Model project +# +# SPDX-License-Identifier: MPL-2.0 + +name: Build and Test C++ + +# Controls when the workflow will run +on: + # run pipeline on push event of main branch + push: + branches: + - main + # run pipeline on pull request + pull_request: + # run pipeline on merge queue + merge_group: + # run this workflow manually from the Actions tab + workflow_dispatch: + inputs: + create_release: + type: boolean + description: Create a (pre-)release when CI passes + default: true + required: true + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + + +jobs: + + build-cpp-test-linux: + runs-on: ubuntu-latest + strategy: + matrix: + build-option: [ debug, release ] + compiler: [gcc, clang] + include: + - compiler: gcc + - compiler: clang + + env: + CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew + PRESET: ci-${{ matrix.compiler }}-${{ matrix.build-option }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: 'true' + - name: Initialize and update submodules + run: | + git submodule update --init --recursive + - name: Install packages + run: | + sudo apt-get update + sudo apt-get install -y ninja-build gcc-12 g++-12 clang-15 + sudo ln -s /usr/bin/clang-15 /usr/local/bin/clang + sudo ln -s /usr/bin/clang++-15 /usr/local/bin/clang++ + sudo ln -s /usr/bin/gcc-12 /usr/local/bin/gcc + sudo ln -s /usr/bin/g++-12 /usr/local/bin/g++ + + - name: Enable brew + run: | + echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH + - name: Install C++ dependencies + run: | + brew install boost eigen nlohmann-json msgpack-cxx doctest + - name: Build and test + run: ./build.sh -p ${{ env.PRESET }} -i + + build-cpp-test-windows: + runs-on: windows-latest + strategy: + matrix: + build-option: [ debug, release ] + compiler: [msvc, clang-cl] + + env: + PRESET: ${{ matrix.compiler }}-${{ matrix.build-option }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: 'true' + + - name: Activate conda + uses: conda-incubator/setup-miniconda@v3 # install miniforge instead + with: + miniforge-version: latest + + - name: List conda + run: | + conda info + conda list + + - name: Install conda environment + run: | + conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge libboost-headers eigen nlohmann_json msgpack-cxx doctest + + - name: Build and test + run: | + $vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath + Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll') + Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64' + + # Resolve dirty PATH environment + # TODO(mgovers): Remove after https://github.com/actions/runner-images/issues/10001 is resolved + $env:PATH = ($env:PATH -split ';' | Where-Object { $_ -ne 'C:\Program Files\LLVM\bin' }) -join ';' + + # generate cmake cache + cmake --preset ${{ env.PRESET }} -DCMAKE_PREFIX_PATH=C:\conda_envs\cpp_pkgs\Library; if(!$?) { Exit $LASTEXITCODE } + # build + cmake --build --preset ${{ env.PRESET }} --verbose -j 1; if(!$?) { Exit $LASTEXITCODE } + # test + ctest --preset ${{ env.PRESET }} --output-on-failure; if(!$?) { Exit $LASTEXITCODE } + # install + cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install; if(!$?) { Exit $LASTEXITCODE } + + build-cpp-test-macos: + runs-on: macos-14 + strategy: + matrix: + build-option: [ debug, release ] + env: + CMAKE_PREFIX_PATH: /usr/local + PRESET: ci-clang-${{ matrix.build-option }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: 'true' + + - name: Set up XCode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - name: Install cpp dependencies + run: | + brew install ninja boost eigen nlohmann-json msgpack-cxx doctest + + - name: Build and test + run: ./build.sh -p ${{ env.PRESET }} -i + \ No newline at end of file From e0ccb1c664caa8bffa6beba3f444fc198f463ed7 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 30 Sep 2024 14:14:29 +0200 Subject: [PATCH 09/36] delete workflow Signed-off-by: Laurynas Jagutis --- .github/workflows/new-build.yml | 145 -------------------------------- 1 file changed, 145 deletions(-) delete mode 100644 .github/workflows/new-build.yml diff --git a/.github/workflows/new-build.yml b/.github/workflows/new-build.yml deleted file mode 100644 index ae579fa..0000000 --- a/.github/workflows/new-build.yml +++ /dev/null @@ -1,145 +0,0 @@ -# SPDX-FileCopyrightText: Contributors to the Power Grid Model project -# -# SPDX-License-Identifier: MPL-2.0 - -name: Build and Test C++ - -# Controls when the workflow will run -on: - # run pipeline on push event of main branch - push: - branches: - - main - # run pipeline on pull request - pull_request: - # run pipeline on merge queue - merge_group: - # run this workflow manually from the Actions tab - workflow_dispatch: - inputs: - create_release: - type: boolean - description: Create a (pre-)release when CI passes - default: true - required: true - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - - -jobs: - - build-cpp-test-linux: - runs-on: ubuntu-latest - strategy: - matrix: - build-option: [ debug, release ] - compiler: [gcc, clang] - include: - - compiler: gcc - - compiler: clang - - env: - CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew - PRESET: ci-${{ matrix.compiler }}-${{ matrix.build-option }} - - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - name: Initialize and update submodules - run: | - git submodule update --init --recursive - - name: Install packages - run: | - sudo apt-get update - sudo apt-get install -y ninja-build gcc-12 g++-12 clang-15 - sudo ln -s /usr/bin/clang-15 /usr/local/bin/clang - sudo ln -s /usr/bin/clang++-15 /usr/local/bin/clang++ - sudo ln -s /usr/bin/gcc-12 /usr/local/bin/gcc - sudo ln -s /usr/bin/g++-12 /usr/local/bin/g++ - - - name: Enable brew - run: | - echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH - - name: Install C++ dependencies - run: | - brew install boost eigen nlohmann-json msgpack-cxx doctest - - name: Build and test - run: ./build.sh -p ${{ env.PRESET }} -i - - build-cpp-test-windows: - runs-on: windows-latest - strategy: - matrix: - build-option: [ debug, release ] - compiler: [msvc, clang-cl] - - env: - PRESET: ${{ matrix.compiler }}-${{ matrix.build-option }} - - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - - name: Activate conda - uses: conda-incubator/setup-miniconda@v3 # install miniforge instead - with: - miniforge-version: latest - - - name: List conda - run: | - conda info - conda list - - - name: Install conda environment - run: | - conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge libboost-headers eigen nlohmann_json msgpack-cxx doctest - - - name: Build and test - run: | - $vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath - Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll') - Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64' - - # Resolve dirty PATH environment - # TODO(mgovers): Remove after https://github.com/actions/runner-images/issues/10001 is resolved - $env:PATH = ($env:PATH -split ';' | Where-Object { $_ -ne 'C:\Program Files\LLVM\bin' }) -join ';' - - # generate cmake cache - cmake --preset ${{ env.PRESET }} -DCMAKE_PREFIX_PATH=C:\conda_envs\cpp_pkgs\Library; if(!$?) { Exit $LASTEXITCODE } - # build - cmake --build --preset ${{ env.PRESET }} --verbose -j 1; if(!$?) { Exit $LASTEXITCODE } - # test - ctest --preset ${{ env.PRESET }} --output-on-failure; if(!$?) { Exit $LASTEXITCODE } - # install - cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install; if(!$?) { Exit $LASTEXITCODE } - - build-cpp-test-macos: - runs-on: macos-14 - strategy: - matrix: - build-option: [ debug, release ] - env: - CMAKE_PREFIX_PATH: /usr/local - PRESET: ci-clang-${{ matrix.build-option }} - - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - - name: Set up XCode - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - - name: Install cpp dependencies - run: | - brew install ninja boost eigen nlohmann-json msgpack-cxx doctest - - - name: Build and test - run: ./build.sh -p ${{ env.PRESET }} -i - \ No newline at end of file From 4e71951c8dd20d23312692fdd156c7fd58fd139a Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 2 Oct 2024 12:15:15 +0200 Subject: [PATCH 10/36] update c api Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 65 ++++++++++++++----- .../power_grid_model_io_native_c/basics.h | 6 -- .../vnf_pgm_converter.h | 3 +- .../src/vnf_pgm_converter.cpp | 8 +-- 4 files changed, 54 insertions(+), 28 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 4c104ca..1e65aaa 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -6,18 +6,33 @@ #ifndef POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP #define POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP +#include #include +#include +#include #include #include +inline power_grid_model::ConstDataset create_const_dataset_from_container(const power_grid_model::Container& container, power_grid_model::meta_data::MetaData const& meta_data) { + std::string_view dataset_name = "empty_dataset"; + power_grid_model::ConstDataset const_dataset{false, 1, dataset_name, meta_data}; + return const_dataset; +} + +inline std::string get_serialized_data(power_grid_model::ConstDataset& const_dataset) { + power_grid_model::meta_data::Serializer serializer(const_dataset, power_grid_model::SerializationFormat::json); + std::string serialized_pgm_data = serializer.get_string(false, -1); + return serialized_pgm_data; +} + class PgmVnfConverter { public: PgmVnfConverter(char* buffer = nullptr, power_grid_model::WritableDataset* data = nullptr); // Public member functions void parse_vnf_file(); - power_grid_model::ConstDataset const* convert_input(power_grid_model::ConstDataset const* dataset); + std::string convert_input(); private: // Private attributes @@ -35,7 +50,7 @@ class PgmVnfConverter { power_grid_model::WritableDataset* get_deserialized_data(); // Private member functions - void convert_node_input(); + std::vector convert_node_input(); void convert_line_input(); void convert_sources_input(); void convert_sym_loads_input(); @@ -58,9 +73,8 @@ inline void PgmVnfConverter::parse_vnf_file() { // will be implemented later } -inline power_grid_model::ConstDataset const* -PgmVnfConverter::convert_input(power_grid_model::ConstDataset const* /*dataset*/) { - convert_node_input(); +inline std::string PgmVnfConverter::convert_input() { + std::vector nodes = convert_node_input(); convert_line_input(); convert_sources_input(); convert_sym_loads_input(); @@ -69,11 +83,23 @@ PgmVnfConverter::convert_input(power_grid_model::ConstDataset const* /*dataset*/ convert_sym_gens_input(); convert_links_input(); - // then return the buffer - // return pgm_input_data; - // for now. - power_grid_model::ConstDataset* fake_data = nullptr; - return fake_data; + power_grid_model::Container container; + + for (const auto& node : nodes) { + container.emplace(node.id(), node); + } + + power_grid_model::meta_data::MetaData meta_data; + + power_grid_model::ConstDataset const_dataset = create_const_dataset_from_container(container, meta_data); + + std::string serialized_pgm_data = get_serialized_data(const_dataset); + + // 1. our vnf importer it directly understands the vnf format + // 2. convert vnf like dataset to internal types (take raw data and convert it to pgm component container) + // 3. another function which 1. makes const dataset view from pgm component container 2. const dataset to serializer + + return serialized_pgm_data; } inline void PgmVnfConverter::set_file_buffer(char* file_buffer) { this->f_file_buffer = file_buffer; } @@ -86,8 +112,18 @@ inline char* PgmVnfConverter::get_file_buffer() { return this->f_file_buffer; } inline power_grid_model::WritableDataset* PgmVnfConverter::get_deserialized_data() { return this->deserialized_data; } -inline void PgmVnfConverter::convert_node_input() { - // Implementation +inline std::vector PgmVnfConverter::convert_node_input() { + std::vector node_inputs = { + {1, 110.0} + }; + + std::vector nodes; + + for (const auto& node_input : node_inputs) { + nodes.emplace_back(node_input); + } + + return nodes; } inline void PgmVnfConverter::convert_line_input() { @@ -120,9 +156,8 @@ inline void PgmVnfConverter::convert_links_input() { inline void parse_vnf_file_wrapper(PgmVnfConverter* obj) { obj->parse_vnf_file(); } -inline power_grid_model::ConstDataset const* convert_input_wrapper(PgmVnfConverter* obj, - power_grid_model::ConstDataset const* dataset) { - return obj->convert_input(dataset); +inline std::string convert_input_wrapper(PgmVnfConverter* obj) { + return obj->convert_input(); } #endif // POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/basics.h b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/basics.h index ca1b243..209b899 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/basics.h +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/basics.h @@ -70,12 +70,6 @@ typedef int32_t PGM_IO_ID; */ typedef struct PGM_IO_VnfConverter PGM_IO_VnfConverter; -/** - * @brief Opaque struct for the ConstDataset. - * - */ -typedef struct PGM_IO_ConstDataset PGM_IO_ConstDataset; - /** * @brief Opaque struct for the handle class. * diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h index d6fcb75..0f956c1 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h @@ -28,8 +28,7 @@ PGM_IO_API PGM_IO_VnfConverter* PGM_VNF_create_converter(PGM_IO_Handle* handle, * @param dataset A pointer to the const dataset supplied by the user. * @return The pointer to the const dataset instance supplied by the user which has been filled in. */ -PGM_IO_API PGM_IO_ConstDataset const* PGM_VNF_get_input_data(PGM_IO_Handle* handle, PGM_IO_VnfConverter* converter_ptr, - PGM_IO_ConstDataset const* dataset); +PGM_IO_API char const* PGM_VNF_get_input_data(PGM_IO_Handle* handle, PGM_IO_VnfConverter* converter_ptr); /** * @brief Destroy the converter and free up the memory that was dedicated to it. diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp index 6872acc..3dd97ba 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp @@ -21,12 +21,10 @@ PGM_IO_VnfConverter* PGM_VNF_create_converter(const PGM_IO_Handle* /*handle*/, c return reinterpret_cast(converter); } -PGM_IO_ConstDataset const* PGM_VNF_get_input_data(const PGM_IO_Handle* /*handle*/, PGM_IO_VnfConverter* converter_ptr, - PGM_IO_ConstDataset const* dataset) { +char const* PGM_VNF_get_input_data(const PGM_IO_Handle* /*handle*/, PGM_IO_VnfConverter* converter_ptr) { auto* converter = reinterpret_cast(converter_ptr); - auto const* data = reinterpret_cast(dataset); - convert_input_wrapper(converter, data); - return reinterpret_cast(data); + std::string json_data = convert_input_wrapper(converter); + return json_data.c_str(); } void PGM_VNF_delete_Converter(PGM_IO_VnfConverter* converter_ptr) { From bce829509480199824c3adb549689101b3702ef9 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 2 Oct 2024 12:19:27 +0200 Subject: [PATCH 11/36] format files Signed-off-by: Laurynas Jagutis --- .github/workflows/build.yml | 4 ++++ .../vnf_converter/vnf_pgm_converter.hpp | 19 +++++++++---------- .../vnf_pgm_converter.h | 2 +- .../src/vnf_pgm_converter.cpp | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8860490..50fb577 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: Contributors to the Power Grid Model project +# +# SPDX-License-Identifier: MPL-2.0 + name: Build on: diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 1e65aaa..9082c28 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -6,15 +6,17 @@ #ifndef POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP #define POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP -#include #include +#include +#include #include #include -#include #include -inline power_grid_model::ConstDataset create_const_dataset_from_container(const power_grid_model::Container& container, power_grid_model::meta_data::MetaData const& meta_data) { +inline power_grid_model::ConstDataset +create_const_dataset_from_container(const power_grid_model::Container& container, + power_grid_model::meta_data::MetaData const& meta_data) { std::string_view dataset_name = "empty_dataset"; power_grid_model::ConstDataset const_dataset{false, 1, dataset_name, meta_data}; return const_dataset; @@ -97,7 +99,8 @@ inline std::string PgmVnfConverter::convert_input() { // 1. our vnf importer it directly understands the vnf format // 2. convert vnf like dataset to internal types (take raw data and convert it to pgm component container) - // 3. another function which 1. makes const dataset view from pgm component container 2. const dataset to serializer + // 3. another function which 1. makes const dataset view from pgm component container 2. const dataset to + // serializer return serialized_pgm_data; } @@ -113,9 +116,7 @@ inline char* PgmVnfConverter::get_file_buffer() { return this->f_file_buffer; } inline power_grid_model::WritableDataset* PgmVnfConverter::get_deserialized_data() { return this->deserialized_data; } inline std::vector PgmVnfConverter::convert_node_input() { - std::vector node_inputs = { - {1, 110.0} - }; + std::vector node_inputs = {{1, 110.0}}; std::vector nodes; @@ -156,8 +157,6 @@ inline void PgmVnfConverter::convert_links_input() { inline void parse_vnf_file_wrapper(PgmVnfConverter* obj) { obj->parse_vnf_file(); } -inline std::string convert_input_wrapper(PgmVnfConverter* obj) { - return obj->convert_input(); -} +inline std::string convert_input_wrapper(PgmVnfConverter* obj) { return obj->convert_input(); } #endif // POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h index 0f956c1..6a0e56d 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h @@ -17,7 +17,7 @@ extern "C" { * @param handle * @param file_buffer A pointer to the null-terminated C string. * @return The pointer to a PGM_VNF_converter instance. The instance must be freed by - * PGM_VNF_delete_Converter + * PGM_VNF_delete_Converter. */ PGM_IO_API PGM_IO_VnfConverter* PGM_VNF_create_converter(PGM_IO_Handle* handle, char* file_buffer); diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp index 3dd97ba..c58d45a 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp @@ -14,7 +14,7 @@ using power_grid_model::ConstDataset; -// TODO(Laurynas-Jagutis) add call_with_catch for these functions +// TODO(Laurynas-Jagutis) add call_with_catch for these functions. PGM_IO_VnfConverter* PGM_VNF_create_converter(const PGM_IO_Handle* /*handle*/, char* file_buffer) { auto* converter = new PgmVnfConverter(file_buffer); parse_vnf_file_wrapper(converter); From e613118cb59658ad3a276603ef871c5e21a54eac Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 2 Oct 2024 13:47:27 +0200 Subject: [PATCH 12/36] add const Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 9082c28..7bccaa4 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -17,7 +17,7 @@ inline power_grid_model::ConstDataset create_const_dataset_from_container(const power_grid_model::Container& container, power_grid_model::meta_data::MetaData const& meta_data) { - std::string_view dataset_name = "empty_dataset"; + std::string_view const dataset_name = "empty_dataset"; power_grid_model::ConstDataset const_dataset{false, 1, dataset_name, meta_data}; return const_dataset; } @@ -76,7 +76,7 @@ inline void PgmVnfConverter::parse_vnf_file() { } inline std::string PgmVnfConverter::convert_input() { - std::vector nodes = convert_node_input(); + std::vector const nodes = convert_node_input(); convert_line_input(); convert_sources_input(); convert_sym_loads_input(); @@ -91,11 +91,11 @@ inline std::string PgmVnfConverter::convert_input() { container.emplace(node.id(), node); } - power_grid_model::meta_data::MetaData meta_data; + power_grid_model::meta_data::MetaData const meta_data; power_grid_model::ConstDataset const_dataset = create_const_dataset_from_container(container, meta_data); - std::string serialized_pgm_data = get_serialized_data(const_dataset); + std::string const serialized_pgm_data = get_serialized_data(const_dataset); // 1. our vnf importer it directly understands the vnf format // 2. convert vnf like dataset to internal types (take raw data and convert it to pgm component container) From 646863faa5231ade5b6e2f08c08e7180560dfd88 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 2 Oct 2024 14:08:59 +0200 Subject: [PATCH 13/36] fix some clang tidy issues Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 7bccaa4..be2d082 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -15,8 +15,9 @@ #include inline power_grid_model::ConstDataset -create_const_dataset_from_container(const power_grid_model::Container& container, +create_const_dataset_from_container(const power_grid_model::Container& /*container*/, power_grid_model::meta_data::MetaData const& meta_data) { + // for now leave it empty std::string_view const dataset_name = "empty_dataset"; power_grid_model::ConstDataset const_dataset{false, 1, dataset_name, meta_data}; return const_dataset; @@ -95,7 +96,7 @@ inline std::string PgmVnfConverter::convert_input() { power_grid_model::ConstDataset const_dataset = create_const_dataset_from_container(container, meta_data); - std::string const serialized_pgm_data = get_serialized_data(const_dataset); + std::string serialized_pgm_data = get_serialized_data(const_dataset); // 1. our vnf importer it directly understands the vnf format // 2. convert vnf like dataset to internal types (take raw data and convert it to pgm component container) From ac4c29fc846cb3c38fa511abf3abe597c6a1b994 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 2 Oct 2024 14:43:30 +0200 Subject: [PATCH 14/36] preallocate Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index be2d082..b4193d5 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -87,7 +87,7 @@ inline std::string PgmVnfConverter::convert_input() { convert_links_input(); power_grid_model::Container container; - + for (const auto& node : nodes) { container.emplace(node.id(), node); } @@ -121,6 +121,7 @@ inline std::vector PgmVnfConverter::convert_node_input() std::vector nodes; + nodes.reserve(node_inputs.size()); for (const auto& node_input : node_inputs) { nodes.emplace_back(node_input); } From 5d170927354c3fa53c0599b2e1343ed4b248c7c7 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 2 Oct 2024 14:56:28 +0200 Subject: [PATCH 15/36] stop some clang tidy checks Signed-off-by: Laurynas Jagutis --- .clang-tidy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.clang-tidy b/.clang-tidy index 2ff94f7..7127116 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -14,7 +14,9 @@ cppcoreguidelines-*, -cppcoreguidelines-avoid-c-arrays, -cppcoreguidelines-owning-memory, -cppcoreguidelines-avoid-magic-numbers, +-cppcoreguidelines-pro-bounds-constant-array-index, -cppcoreguidelines-pro-bounds-pointer-arithmetic, +-cppcoreguidelines-pro-type-member-init, -cppcoreguidelines-pro-type-reinterpret-cast, darwin-*, hiccp-*, @@ -24,6 +26,7 @@ google-*, -google-build-using-namespace, -google-explicit-constructor misc-*, +-misc-no-recursion, -misc-non-private-member-variables-in-classes, modernize-*, -modernize-avoid-c-arrays, From cf1a40b5f2f9c08a1ba147e0dfca84a3d7b57a32 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 2 Oct 2024 15:19:47 +0200 Subject: [PATCH 16/36] add const, format Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index b4193d5..ebcfb78 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -87,7 +87,7 @@ inline std::string PgmVnfConverter::convert_input() { convert_links_input(); power_grid_model::Container container; - + for (const auto& node : nodes) { container.emplace(node.id(), node); } @@ -117,7 +117,7 @@ inline char* PgmVnfConverter::get_file_buffer() { return this->f_file_buffer; } inline power_grid_model::WritableDataset* PgmVnfConverter::get_deserialized_data() { return this->deserialized_data; } inline std::vector PgmVnfConverter::convert_node_input() { - std::vector node_inputs = {{1, 110.0}}; + std::vector const node_inputs = {{1, 110.0}}; std::vector nodes; From 570bad9cd23236651289b7ff206014af5f4d4d7b Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 2 Oct 2024 15:45:57 +0200 Subject: [PATCH 17/36] fix clang tidy more Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 3 +++ .../power_grid_model_io_native_c/src/vnf_pgm_converter.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index ebcfb78..3953f95 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -117,6 +117,9 @@ inline char* PgmVnfConverter::get_file_buffer() { return this->f_file_buffer; } inline power_grid_model::WritableDataset* PgmVnfConverter::get_deserialized_data() { return this->deserialized_data; } inline std::vector PgmVnfConverter::convert_node_input() { + // here the deserialized data should be used + auto data = this->deserialized_data; + std::vector const node_inputs = {{1, 110.0}}; std::vector nodes; diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp index c58d45a..61521fe 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp @@ -23,7 +23,7 @@ PGM_IO_VnfConverter* PGM_VNF_create_converter(const PGM_IO_Handle* /*handle*/, c char const* PGM_VNF_get_input_data(const PGM_IO_Handle* /*handle*/, PGM_IO_VnfConverter* converter_ptr) { auto* converter = reinterpret_cast(converter_ptr); - std::string json_data = convert_input_wrapper(converter); + std::string const json_data = convert_input_wrapper(converter); return json_data.c_str(); } From 10a8517ba94d699e98001966075d95545b98e919 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Wed, 2 Oct 2024 16:20:39 +0200 Subject: [PATCH 18/36] add a nolint statement Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 3953f95..4892c15 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -116,9 +116,8 @@ inline char* PgmVnfConverter::get_file_buffer() { return this->f_file_buffer; } inline power_grid_model::WritableDataset* PgmVnfConverter::get_deserialized_data() { return this->deserialized_data; } -inline std::vector PgmVnfConverter::convert_node_input() { - // here the deserialized data should be used - auto data = this->deserialized_data; +inline std::vector +PgmVnfConverter::convert_node_input() { // NOLINT(readability-convert-member-functions-to-static) std::vector const node_inputs = {{1, 110.0}}; From f42fb55e8008924f946e19824c65aec26cfc2418 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 08:53:33 +0200 Subject: [PATCH 19/36] fix clang tidy Signed-off-by: Laurynas Jagutis --- .../power_grid_model_io_native_c/src/vnf_pgm_converter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp index 61521fe..71874c7 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp @@ -23,8 +23,7 @@ PGM_IO_VnfConverter* PGM_VNF_create_converter(const PGM_IO_Handle* /*handle*/, c char const* PGM_VNF_get_input_data(const PGM_IO_Handle* /*handle*/, PGM_IO_VnfConverter* converter_ptr) { auto* converter = reinterpret_cast(converter_ptr); - std::string const json_data = convert_input_wrapper(converter); - return json_data.c_str(); + return convert_input_wrapper(converter).c_str(); } void PGM_VNF_delete_Converter(PGM_IO_VnfConverter* converter_ptr) { From ab637afd858df0d2f8612e5bbd62c88ef7c50e32 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 10:02:19 +0200 Subject: [PATCH 20/36] add const& Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 4892c15..153be52 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -23,7 +23,7 @@ create_const_dataset_from_container(const power_grid_model::Container const nodes = convert_node_input(); convert_line_input(); convert_sources_input(); @@ -96,14 +98,14 @@ inline std::string PgmVnfConverter::convert_input() { power_grid_model::ConstDataset const_dataset = create_const_dataset_from_container(container, meta_data); - std::string serialized_pgm_data = get_serialized_data(const_dataset); + std::string serialized_pgm_data = serialize_data(const_dataset); // 1. our vnf importer it directly understands the vnf format // 2. convert vnf like dataset to internal types (take raw data and convert it to pgm component container) // 3. another function which 1. makes const dataset view from pgm component container 2. const dataset to // serializer - return serialized_pgm_data; + this->serialized_data = serialized_pgm_data; } inline void PgmVnfConverter::set_file_buffer(char* file_buffer) { this->f_file_buffer = file_buffer; } @@ -116,6 +118,8 @@ inline char* PgmVnfConverter::get_file_buffer() { return this->f_file_buffer; } inline power_grid_model::WritableDataset* PgmVnfConverter::get_deserialized_data() { return this->deserialized_data; } +inline std::string const& PgmVnfConverter::get_serialized_data() { return this->serialized_data; } + inline std::vector PgmVnfConverter::convert_node_input() { // NOLINT(readability-convert-member-functions-to-static) @@ -161,6 +165,9 @@ inline void PgmVnfConverter::convert_links_input() { inline void parse_vnf_file_wrapper(PgmVnfConverter* obj) { obj->parse_vnf_file(); } -inline std::string convert_input_wrapper(PgmVnfConverter* obj) { return obj->convert_input(); } +inline std::string const& convert_input_wrapper(PgmVnfConverter* obj) { + obj->convert_input(); + return obj->get_serialized_data(); +} #endif // POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP From 9bb6b50b4c62f14395e230b5426f286291bafc7d Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 10:06:39 +0200 Subject: [PATCH 21/36] add const Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 153be52..bff4c62 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -98,7 +98,7 @@ inline void PgmVnfConverter::convert_input() { power_grid_model::ConstDataset const_dataset = create_const_dataset_from_container(container, meta_data); - std::string serialized_pgm_data = serialize_data(const_dataset); + std::string const serialized_pgm_data = serialize_data(const_dataset); // 1. our vnf importer it directly understands the vnf format // 2. convert vnf like dataset to internal types (take raw data and convert it to pgm component container) From f8abc0de9ddca3a7cb04af0ae3eb352f41cccbff Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 10:20:18 +0200 Subject: [PATCH 22/36] adjust converter, remove build.yml Signed-off-by: Laurynas Jagutis --- .github/workflows/build.yml | 38 ------------------- .../vnf_converter/vnf_pgm_converter.hpp | 20 ++++------ 2 files changed, 7 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 50fb577..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,38 +0,0 @@ -# SPDX-FileCopyrightText: Contributors to the Power Grid Model project -# -# SPDX-License-Identifier: MPL-2.0 - -name: Build - -on: - push: - pull_request: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Initialize and update submodules - run: | - git submodule update --init --recursive - - - name: Enable brew - run: | - echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH - - - name: Install C++ dependencies - run: | - brew install boost eigen nlohmann-json msgpack-cxx doctest - - - name: Configure with CMake - run: cmake -S . -B build -DPGM_IO_ENABLE_DEV_BUILD=ON - - - name: Build with CMake - run: cmake --build build --config Release - - - name: Run tests - run: ctest --test-dir build -V diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index bff4c62..55d0f90 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -15,7 +15,7 @@ #include inline power_grid_model::ConstDataset -create_const_dataset_from_container(const power_grid_model::Container& /*container*/, +create_const_dataset_from_container(power_grid_model::Container const& /*container*/, power_grid_model::meta_data::MetaData const& meta_data) { // for now leave it empty std::string_view const dataset_name = "empty_dataset"; @@ -23,7 +23,7 @@ create_const_dataset_from_container(const power_grid_model::Container convert_node_input(); void convert_line_input(); @@ -122,9 +118,7 @@ inline std::string const& PgmVnfConverter::get_serialized_data() { return this-> inline std::vector PgmVnfConverter::convert_node_input() { // NOLINT(readability-convert-member-functions-to-static) - std::vector const node_inputs = {{1, 110.0}}; - std::vector nodes; nodes.reserve(node_inputs.size()); From 070a8cc5e26cf5ae08481462e96adf813f431b09 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 10:25:15 +0200 Subject: [PATCH 23/36] add const Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 55d0f90..6ca3312 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -14,12 +14,12 @@ #include -inline power_grid_model::ConstDataset +inline power_grid_model::ConstDataset const create_const_dataset_from_container(power_grid_model::Container const& /*container*/, power_grid_model::meta_data::MetaData const& meta_data) { // for now leave it empty std::string_view const dataset_name = "empty_dataset"; - power_grid_model::ConstDataset const_dataset{false, 1, dataset_name, meta_data}; + power_grid_model::ConstDataset const const_dataset{false, 1, dataset_name, meta_data}; return const_dataset; } @@ -92,7 +92,7 @@ inline void PgmVnfConverter::convert_input() { power_grid_model::meta_data::MetaData const meta_data; - power_grid_model::ConstDataset const_dataset = create_const_dataset_from_container(container, meta_data); + power_grid_model::ConstDataset const const_dataset = create_const_dataset_from_container(container, meta_data); std::string const serialized_pgm_data = serialize_data(const_dataset); From fe6b41f1895d7901a0704d5f3ea8fb26053f4a3f Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 10:29:49 +0200 Subject: [PATCH 24/36] adjust const Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 6ca3312..cee75fd 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -14,12 +14,12 @@ #include -inline power_grid_model::ConstDataset const +inline power_grid_model::ConstDataset create_const_dataset_from_container(power_grid_model::Container const& /*container*/, power_grid_model::meta_data::MetaData const& meta_data) { // for now leave it empty std::string_view const dataset_name = "empty_dataset"; - power_grid_model::ConstDataset const const_dataset{false, 1, dataset_name, meta_data}; + power_grid_model::ConstDataset const_dataset{false, 1, dataset_name, meta_data}; return const_dataset; } From 1ec0d0fc8fa540e2761a301c11462ad0aa5a3d2b Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 11:41:36 +0200 Subject: [PATCH 25/36] add cppcoreguidelines-pro-type-member-init check Signed-off-by: Laurynas Jagutis --- .clang-tidy | 1 - 1 file changed, 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 7127116..bd1ba17 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -16,7 +16,6 @@ cppcoreguidelines-*, -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-pro-bounds-constant-array-index, -cppcoreguidelines-pro-bounds-pointer-arithmetic, --cppcoreguidelines-pro-type-member-init, -cppcoreguidelines-pro-type-reinterpret-cast, darwin-*, hiccp-*, From ede546bb172465f1671f92499955ec55cd57c916 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 13:13:49 +0200 Subject: [PATCH 26/36] remove -misc-no-recursion from clang tidy, add -cppcoreguidelines-pro-type-member-init back to clang tidy Signed-off-by: Laurynas Jagutis --- .clang-tidy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index bd1ba17..b74cf58 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -16,6 +16,7 @@ cppcoreguidelines-*, -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-pro-bounds-constant-array-index, -cppcoreguidelines-pro-bounds-pointer-arithmetic, +-cppcoreguidelines-pro-type-member-init, -cppcoreguidelines-pro-type-reinterpret-cast, darwin-*, hiccp-*, @@ -25,7 +26,6 @@ google-*, -google-build-using-namespace, -google-explicit-constructor misc-*, --misc-no-recursion, -misc-non-private-member-variables-in-classes, modernize-*, -modernize-avoid-c-arrays, From c69d3cb065faea39a3411e7af70593996659e98a Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 13:50:26 +0200 Subject: [PATCH 27/36] reinclude checks to clang tidy file Signed-off-by: Laurynas Jagutis --- .clang-tidy | 1 + .../vnf_converter/vnf_pgm_converter.hpp | 1 + 2 files changed, 2 insertions(+) diff --git a/.clang-tidy b/.clang-tidy index b74cf58..7127116 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -26,6 +26,7 @@ google-*, -google-build-using-namespace, -google-explicit-constructor misc-*, +-misc-no-recursion, -misc-non-private-member-variables-in-classes, modernize-*, -modernize-avoid-c-arrays, diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index cee75fd..92194aa 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -7,6 +7,7 @@ #define POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP #include +#include #include #include #include From 11c4cfc418a75b25a82ee2a3e1fbce145ab0513b Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 14:25:41 +0200 Subject: [PATCH 28/36] change metadata to metadatagen Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 92194aa..7fa5ba2 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -91,8 +91,7 @@ inline void PgmVnfConverter::convert_input() { container.emplace(node.id(), node); } - power_grid_model::meta_data::MetaData const meta_data; - + constexpr auto& meta_data = power_grid_model::meta_data::meta_data_gen::meta_data; power_grid_model::ConstDataset const const_dataset = create_const_dataset_from_container(container, meta_data); std::string const serialized_pgm_data = serialize_data(const_dataset); From 96928bdb105d4867ff0c496f8df8b8519476507b Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 14:58:37 +0200 Subject: [PATCH 29/36] remove reinterpret cast Signed-off-by: Laurynas Jagutis --- .../src/vnf_pgm_converter.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp index 71874c7..203d3ed 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp @@ -14,19 +14,19 @@ using power_grid_model::ConstDataset; +struct PGM_IO_VnfConverter : public PgmVnfConverter { + using PgmVnfConverter::PgmVnfConverter; +}; + // TODO(Laurynas-Jagutis) add call_with_catch for these functions. PGM_IO_VnfConverter* PGM_VNF_create_converter(const PGM_IO_Handle* /*handle*/, char* file_buffer) { - auto* converter = new PgmVnfConverter(file_buffer); + auto* converter = new PGM_IO_VnfConverter(file_buffer); parse_vnf_file_wrapper(converter); - return reinterpret_cast(converter); + return converter; } char const* PGM_VNF_get_input_data(const PGM_IO_Handle* /*handle*/, PGM_IO_VnfConverter* converter_ptr) { - auto* converter = reinterpret_cast(converter_ptr); - return convert_input_wrapper(converter).c_str(); + return convert_input_wrapper(converter_ptr).c_str(); } -void PGM_VNF_delete_Converter(PGM_IO_VnfConverter* converter_ptr) { - auto* converter = reinterpret_cast(converter_ptr); - delete converter; -} +void PGM_VNF_delete_Converter(PGM_IO_VnfConverter* converter_ptr) { delete converter_ptr; } From 7f2763e46c151f2540e924fabde5f3782bbd6161 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 15:09:30 +0200 Subject: [PATCH 30/36] add const Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 7fa5ba2..89b5f32 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -91,7 +91,7 @@ inline void PgmVnfConverter::convert_input() { container.emplace(node.id(), node); } - constexpr auto& meta_data = power_grid_model::meta_data::meta_data_gen::meta_data; + constexpr auto& const meta_data = power_grid_model::meta_data::meta_data_gen::meta_data; power_grid_model::ConstDataset const const_dataset = create_const_dataset_from_container(container, meta_data); std::string const serialized_pgm_data = serialize_data(const_dataset); From f43114bcbb5a43e3359815ba1aaee420bb82836c Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 15:20:20 +0200 Subject: [PATCH 31/36] adjust const Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 89b5f32..ff74926 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -91,7 +91,7 @@ inline void PgmVnfConverter::convert_input() { container.emplace(node.id(), node); } - constexpr auto& const meta_data = power_grid_model::meta_data::meta_data_gen::meta_data; + constexpr const auto& meta_data = power_grid_model::meta_data::meta_data_gen::meta_data; power_grid_model::ConstDataset const const_dataset = create_const_dataset_from_container(container, meta_data); std::string const serialized_pgm_data = serialize_data(const_dataset); From 80c4a72c77486c848686648878328dfa881ef31b Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 15:34:39 +0200 Subject: [PATCH 32/36] disable two clang tidy checks since they are failing on the PGM side Signed-off-by: Laurynas Jagutis --- .clang-tidy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 7127116..911ca71 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -24,7 +24,9 @@ llvm-*, -llvm-header-guard, google-*, -google-build-using-namespace, --google-explicit-constructor +-google-default-arguments, +-google-explicit-constructor, +-google-readability-todo, misc-*, -misc-no-recursion, -misc-non-private-member-variables-in-classes, From 166ea0114f5832364b80a52dec460e80a7a4c508 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 16:01:22 +0200 Subject: [PATCH 33/36] fix a sonarcloud smell Signed-off-by: Laurynas Jagutis --- .../vnf_converter/vnf_pgm_converter.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index ff74926..35cd4f2 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -38,7 +38,7 @@ class PgmVnfConverter { void parse_vnf_file(); void convert_input(); - std::string const& get_serialized_data(); + std::string const& get_serialized_data() const; void set_file_buffer(char* file_buffer); void set_deserialized_data(power_grid_model::WritableDataset* deserialized_data); char* get_file_buffer(); @@ -114,7 +114,7 @@ inline char* PgmVnfConverter::get_file_buffer() { return this->f_file_buffer; } inline power_grid_model::WritableDataset* PgmVnfConverter::get_deserialized_data() { return this->deserialized_data; } -inline std::string const& PgmVnfConverter::get_serialized_data() { return this->serialized_data; } +inline std::string const& PgmVnfConverter::get_serialized_data() const { return this->serialized_data; } inline std::vector PgmVnfConverter::convert_node_input() { // NOLINT(readability-convert-member-functions-to-static) From 23f5c4d06ff313e20b6dbf7198c45dc3b369da59 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Mon, 7 Oct 2024 16:58:27 +0200 Subject: [PATCH 34/36] remove unused ssh format, add static, change c api to PGM_IO Signed-off-by: Laurynas Jagutis --- .gitmodules | 5 ----- .../vnf_converter/vnf_pgm_converter.hpp | 5 ++--- .../vnf_pgm_converter.h | 18 +++++++++--------- .../src/vnf_pgm_converter.cpp | 6 +++--- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/.gitmodules b/.gitmodules index bd10cd9..6808c93 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,11 +2,6 @@ # # SPDX-License-Identifier: MPL-2.0 -# [submodule "deps/power-grid-model"] -# path = deps/power-grid-model -# url = git@github.com:PowerGridModel/power-grid-model.git -# branch = main - [submodule "deps/power-grid-model"] path = deps/power-grid-model url = https://github.com/PowerGridModel/power-grid-model.git diff --git a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp index 35cd4f2..ddb2272 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp @@ -52,7 +52,7 @@ class PgmVnfConverter { std::string serialized_data; // Private member functions - std::vector convert_node_input(); + static std::vector convert_node_input(); void convert_line_input(); void convert_sources_input(); void convert_sym_loads_input(); @@ -116,8 +116,7 @@ inline power_grid_model::WritableDataset* PgmVnfConverter::get_deserialized_data inline std::string const& PgmVnfConverter::get_serialized_data() const { return this->serialized_data; } -inline std::vector -PgmVnfConverter::convert_node_input() { // NOLINT(readability-convert-member-functions-to-static) +inline std::vector PgmVnfConverter::convert_node_input() { std::vector const node_inputs = {{1, 110.0}}; std::vector nodes; diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h index 6a0e56d..f540552 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h @@ -13,28 +13,28 @@ extern "C" { #endif /** - * @brief Create the PGM_VNF_converter + * @brief Create the PGM_IO_VnfConverter * @param handle * @param file_buffer A pointer to the null-terminated C string. - * @return The pointer to a PGM_VNF_converter instance. The instance must be freed by - * PGM_VNF_delete_Converter. + * @return The pointer to a PGM_IO_VnfConverter instance. The instance must be freed by + * PGM_IO_delete_vnf_converter. */ -PGM_IO_API PGM_IO_VnfConverter* PGM_VNF_create_converter(PGM_IO_Handle* handle, char* file_buffer); +PGM_IO_API PGM_IO_VnfConverter* PGM_IO_create_vnf_converter(PGM_IO_Handle* handle, char* file_buffer); /** * @brief Retrieve the transformed input data from .vnf format to PGM format * @param handle - * @param converter_ptr A pointer to a PGM_VNF_converter instace. + * @param converter_ptr A pointer to a PGM_IO_VnfConverter instace. * @param dataset A pointer to the const dataset supplied by the user. * @return The pointer to the const dataset instance supplied by the user which has been filled in. */ -PGM_IO_API char const* PGM_VNF_get_input_data(PGM_IO_Handle* handle, PGM_IO_VnfConverter* converter_ptr); +PGM_IO_API char const* PGM_IO_get_vnf_input_data(PGM_IO_Handle* handle, PGM_IO_VnfConverter* converter_ptr); /** - * @brief Destroy the converter and free up the memory that was dedicated to it. - * @param converter_ptr A pointer to a PGM_VNF_converter instance. + * @brief Destroy the PGM_IO_VnfConverter and free up the memory that was dedicated to it. + * @param converter_ptr A pointer to a PGM_IO_VnfConverter instance. */ -PGM_IO_API void PGM_VNF_delete_Converter(PGM_IO_VnfConverter* converter_ptr); +PGM_IO_API void PGM_IO_delete_vnf_converter(PGM_IO_VnfConverter* converter_ptr); #ifdef __cplusplus } diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp index 203d3ed..c7573ee 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp @@ -19,14 +19,14 @@ struct PGM_IO_VnfConverter : public PgmVnfConverter { }; // TODO(Laurynas-Jagutis) add call_with_catch for these functions. -PGM_IO_VnfConverter* PGM_VNF_create_converter(const PGM_IO_Handle* /*handle*/, char* file_buffer) { +PGM_IO_VnfConverter* PGM_IO_create_vnf_converter(const PGM_IO_Handle* /*handle*/, char* file_buffer) { auto* converter = new PGM_IO_VnfConverter(file_buffer); parse_vnf_file_wrapper(converter); return converter; } -char const* PGM_VNF_get_input_data(const PGM_IO_Handle* /*handle*/, PGM_IO_VnfConverter* converter_ptr) { +char const* PGM_IO_get_vnf_input_data(const PGM_IO_Handle* /*handle*/, PGM_IO_VnfConverter* converter_ptr) { return convert_input_wrapper(converter_ptr).c_str(); } -void PGM_VNF_delete_Converter(PGM_IO_VnfConverter* converter_ptr) { delete converter_ptr; } +void PGM_IO_delete_vnf_converter(PGM_IO_VnfConverter* converter_ptr) { delete converter_ptr; } From f531881774cce1758ffa9f9b2bcbfb9ff17f8dca Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Thu, 17 Oct 2024 15:50:04 +0200 Subject: [PATCH 35/36] change delete to destroy Signed-off-by: Laurynas Jagutis --- .../include/power_grid_model_io_native_c/vnf_pgm_converter.h | 2 +- .../power_grid_model_io_native_c/src/vnf_pgm_converter.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h index f540552..f88d75a 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h @@ -34,7 +34,7 @@ PGM_IO_API char const* PGM_IO_get_vnf_input_data(PGM_IO_Handle* handle, PGM_IO_V * @brief Destroy the PGM_IO_VnfConverter and free up the memory that was dedicated to it. * @param converter_ptr A pointer to a PGM_IO_VnfConverter instance. */ -PGM_IO_API void PGM_IO_delete_vnf_converter(PGM_IO_VnfConverter* converter_ptr); +PGM_IO_API void PGM_IO_destroy_vnf_converter(PGM_IO_VnfConverter* converter_ptr); #ifdef __cplusplus } diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp index c7573ee..9b78b96 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp @@ -29,4 +29,4 @@ char const* PGM_IO_get_vnf_input_data(const PGM_IO_Handle* /*handle*/, PGM_IO_Vn return convert_input_wrapper(converter_ptr).c_str(); } -void PGM_IO_delete_vnf_converter(PGM_IO_VnfConverter* converter_ptr) { delete converter_ptr; } +void PGM_IO_destroy_vnf_converter(PGM_IO_VnfConverter* converter_ptr) { delete converter_ptr; } From fd4a65b3ff2dcdd15dcc7692b14981f65f190565 Mon Sep 17 00:00:00 2001 From: Laurynas Jagutis Date: Thu, 17 Oct 2024 15:52:23 +0200 Subject: [PATCH 36/36] change another delete into destroy Signed-off-by: Laurynas Jagutis --- .../include/power_grid_model_io_native_c/vnf_pgm_converter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h index f88d75a..9dbfb9c 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h @@ -17,7 +17,7 @@ extern "C" { * @param handle * @param file_buffer A pointer to the null-terminated C string. * @return The pointer to a PGM_IO_VnfConverter instance. The instance must be freed by - * PGM_IO_delete_vnf_converter. + * PGM_IO_destroy_vnf_converter. */ PGM_IO_API PGM_IO_VnfConverter* PGM_IO_create_vnf_converter(PGM_IO_Handle* handle, char* file_buffer);