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/pgm_vnf_converter/pgm_vnf_converter.hpp similarity index 97% rename from power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp rename to power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/pgm_vnf_converter/pgm_vnf_converter.hpp index ce51ec2..813c6f3 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/pgm_vnf_converter/pgm_vnf_converter.hpp @@ -3,8 +3,8 @@ // SPDX-License-Identifier: MPL-2.0 #pragma once -#ifndef POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP -#define POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP +#ifndef POWER_GRID_MODEL_IO_NATIVE_C_PGM_VNF_CONVERTER_HPP +#define POWER_GRID_MODEL_IO_NATIVE_C_PGM_VNF_CONVERTER_HPP #include #include @@ -178,4 +178,4 @@ inline std::string const& convert_input_wrapper(PgmVnfConverter* obj) { } // namespace power_grid_model_io_native -#endif // POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP +#endif // POWER_GRID_MODEL_IO_NATIVE_C_PGM_VNF_CONVERTER_HPP diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/CMakeLists.txt b/power_grid_model_io_native_c/power_grid_model_io_native_c/CMakeLists.txt index 13ea773..7cb7139 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/CMakeLists.txt +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/CMakeLists.txt @@ -5,7 +5,7 @@ # C API library add_library(power_grid_model_io_native_c SHARED "src/handle.cpp" - "src/vnf_pgm_converter.cpp" + "src/pgm_vnf_converter.cpp" ) target_include_directories(power_grid_model_io_native_c PUBLIC @@ -16,7 +16,7 @@ target_include_directories(power_grid_model_io_native_c PUBLIC set(PGM_IO_NATIVE_PUBLIC_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/power_grid_model_io_native_c/basics.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/power_grid_model_io_native_c/handle.h" - "${CMAKE_CURRENT_SOURCE_DIR}/include/power_grid_model_io_native_c/vnf_pgm_converter.h" + "${CMAKE_CURRENT_SOURCE_DIR}/include/power_grid_model_io_native_c/pgm_vnf_converter.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/power_grid_model_io_native_c.h" ) diff --git a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c.h b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c.h index 6eecc9f..bca7b34 100644 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c.h +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c.h @@ -18,6 +18,6 @@ #include "power_grid_model_io_native_c/basics.h" #include "power_grid_model_io_native_c/handle.h" -#include "power_grid_model_io_native_c/vnf_pgm_converter.h" +#include "power_grid_model_io_native_c/pgm_vnf_converter.h" #endif // POWER_GRID_MODEL_IO_NATIVE_C_H 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 d565c59..60d9292 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 @@ -65,10 +65,10 @@ typedef int32_t PGM_IO_ID; // typedef struct PGM_IO_VnfConverter PGM_IO_VnfConverter; /** - * @brief Opaque struct for the VnfConverter class. + * @brief Opaque struct for the PgmVnfConverter class. * */ -typedef struct PGM_IO_VnfPgmConverter PGM_IO_VnfPgmConverter; +typedef struct PGM_IO_PgmVnfConverter PGM_IO_PgmVnfConverter; /** * @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/pgm_vnf_converter.h b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/pgm_vnf_converter.h new file mode 100644 index 0000000..56d1c2d --- /dev/null +++ b/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/pgm_vnf_converter.h @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: Contributors to the Power Grid Model project +// +// SPDX-License-Identifier: MPL-2.0 + +#pragma once +#ifndef POWER_GRID_MODEL_IO_NATIVE_C_PGM_VNF_CONVERTER_H +#define POWER_GRID_MODEL_IO_NATIVE_C_PGM_VNF_CONVERTER_H + +#include "basics.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create the PGM_IO_PgmVnfConverter + * @param handle + * @param file_buffer A pointer to the null-terminated C string. + * @return The pointer to a PGM_IO_PgmVnfConverter instance. The instance must be freed by + * PGM_IO_destroy_vnf_converter. + */ +PGM_IO_API PGM_IO_PgmVnfConverter* PGM_IO_create_pgm_vnf_converter(PGM_IO_Handle* handle, char const* file_buffer, + PGM_IO_ExperimentalFeatures experimental_features); + +/** + * @brief Retrieve the transformed input data from .vnf format to PGM format. + * @param handle + * @param converter_ptr A pointer to a PGM_IO_PgmVnfConverter instace. + * @return The pointer to the json string instance that holds data in PGM format. + */ +PGM_IO_API char const* PGM_IO_pgm_vnf_converter_get_input_data(PGM_IO_Handle* handle, + PGM_IO_PgmVnfConverter* converter_ptr); + +/** + * @brief Destroy the PGM_IO_PgmVnfConverter and free up the memory that was dedicated to it. + * @param converter_ptr A pointer to a PGM_IO_PgmVnfConverter instance. + */ +PGM_IO_API void PGM_IO_destroy_pgm_vnf_converter(PGM_IO_PgmVnfConverter* converter_ptr); + +#ifdef __cplusplus +} +#endif + +#endif // POWER_GRID_MODEL_IO_NATIVE_C_PGM_VNF_CONVERTER_H 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 deleted file mode 100644 index cf72762..0000000 --- a/power_grid_model_io_native_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-FileCopyrightText: Contributors to the Power Grid Model project -// -// SPDX-License-Identifier: MPL-2.0 - -#pragma once -#ifndef POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_H -#define POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_H - -#include "basics.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Create the PGM_IO_VnfPgmConverter - * @param handle - * @param file_buffer A pointer to the null-terminated C string. - * @return The pointer to a PGM_IO_VnfPgmConverter instance. The instance must be freed by - * PGM_IO_destroy_vnf_converter. - */ -PGM_IO_API PGM_IO_VnfPgmConverter* PGM_IO_create_vnf_converter(PGM_IO_Handle* handle, char const* file_buffer, - PGM_IO_ExperimentalFeatures experimental_features); - -/** - * @brief Retrieve the transformed input data from .vnf format to PGM format - * @param handle - * @param converter_ptr A pointer to a PGM_IO_VnfPgmConverter instace. - * @return The pointer to the json string instance that holds data in PGM format. - */ -PGM_IO_API char const* PGM_IO_vnf_pgm_converter_get_input_data(PGM_IO_Handle* handle, - PGM_IO_VnfPgmConverter* converter_ptr); - -/** - * @brief Destroy the PGM_IO_VnfPgmConverter and free up the memory that was dedicated to it. - * @param converter_ptr A pointer to a PGM_IO_VnfPgmConverter instance. - */ -PGM_IO_API void PGM_IO_destroy_vnf_converter(PGM_IO_VnfPgmConverter* converter_ptr); - -#ifdef __cplusplus -} -#endif - -#endif // POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_H 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/pgm_vnf_converter.cpp similarity index 68% rename from power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp rename to power_grid_model_io_native_c/power_grid_model_io_native_c/src/pgm_vnf_converter.cpp index 52f3c2c..78ca0fa 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/pgm_vnf_converter.cpp @@ -5,23 +5,23 @@ #define PGM_IO_DLL_EXPORTS #include -#include +#include #include "handle.hpp" #include -#include +#include #include #include namespace pgm_io = power_grid_model_io_native; -struct PGM_IO_VnfPgmConverter : public pgm_io::PgmVnfConverter { +struct PGM_IO_PgmVnfConverter : public pgm_io::PgmVnfConverter { using PgmVnfConverter::PgmVnfConverter; }; -PGM_IO_VnfPgmConverter* PGM_IO_create_vnf_converter(PGM_IO_Handle* handle, char const* file_buffer, - PGM_IO_ExperimentalFeatures experimental_features) { +PGM_IO_PgmVnfConverter* PGM_IO_create_pgm_vnf_converter(PGM_IO_Handle* handle, char const* file_buffer, + PGM_IO_ExperimentalFeatures experimental_features) { return call_with_catch( handle, [file_buffer, experimental_features] { @@ -37,16 +37,16 @@ PGM_IO_VnfPgmConverter* PGM_IO_create_vnf_converter(PGM_IO_Handle* handle, char default: throw power_grid_model::MissingCaseForEnumError{"PGM_IO_create_vnf_converter", experimental_features}; } - auto* converter = new PGM_IO_VnfPgmConverter(file_buffer, experimental_feature); + auto* converter = new PGM_IO_PgmVnfConverter(file_buffer, experimental_feature); parse_vnf_file_wrapper(converter); return converter; }, PGM_IO_regular_error); } -char const* PGM_IO_vnf_pgm_converter_get_input_data(PGM_IO_Handle* handle, PGM_IO_VnfPgmConverter* converter_ptr) { +char const* PGM_IO_pgm_vnf_converter_get_input_data(PGM_IO_Handle* handle, PGM_IO_PgmVnfConverter* converter_ptr) { return call_with_catch( handle, [converter_ptr] { return convert_input_wrapper(converter_ptr).c_str(); }, PGM_IO_regular_error); } -void PGM_IO_destroy_vnf_converter(PGM_IO_VnfPgmConverter* converter_ptr) { delete converter_ptr; } +void PGM_IO_destroy_pgm_vnf_converter(PGM_IO_PgmVnfConverter* converter_ptr) { delete converter_ptr; } diff --git a/setup.py b/setup.py index f52707d..af6e489 100644 --- a/setup.py +++ b/setup.py @@ -178,7 +178,7 @@ def generate_build_ext(pkg_dir: Path, pkg_name: str): libraries: list[str] = [] sources = [ str(pgm_io_c / pgm_io_c / "src" / "handle.cpp"), - str(pgm_io_c / pgm_io_c / "src" / "vnf_pgm_converter.cpp"), + str(pgm_io_c / pgm_io_c / "src" / "pgm_vnf_converter.cpp"), ] # macro define_macros = [ diff --git a/src/power_grid_model_io_native/_core/vnf_converter.py b/src/power_grid_model_io_native/_core/pgm_vnf_converter.py similarity index 83% rename from src/power_grid_model_io_native/_core/vnf_converter.py rename to src/power_grid_model_io_native/_core/pgm_vnf_converter.py index 17b4337..7ca7877 100644 --- a/src/power_grid_model_io_native/_core/vnf_converter.py +++ b/src/power_grid_model_io_native/_core/pgm_vnf_converter.py @@ -23,14 +23,14 @@ def __new__( ): instance = super().__new__(cls) - instance._pgm_vnf_converter = pgmic.create_vnf_converter(string_buffer, experimental_feature) + instance._pgm_vnf_converter = pgmic.create_pgm_vnf_converter(string_buffer, experimental_feature) assert_no_error() return instance def __del__(self): if hasattr(self, "_pgm_vnf_converter"): - pgmic.destroy_vnf_converter(self._pgm_vnf_converter) + pgmic.destroy_pgm_vnf_converter(self._pgm_vnf_converter) def get_pgm_input_data(self): """A function of the PgmVnfConverter class which will convert and return the data in PGM format @@ -38,7 +38,7 @@ def get_pgm_input_data(self): Returns: str: json data in PGM format """ - pgm_data = pgmic.vnf_pgm_converter_get_input_data(self._pgm_vnf_converter) + pgm_data = pgmic.pgm_vnf_converter_get_input_data(self._pgm_vnf_converter) assert_no_error() self._serialized_data = pgm_data return self._serialized_data diff --git a/src/power_grid_model_io_native/_core/power_grid_model_io_core.py b/src/power_grid_model_io_native/_core/power_grid_model_io_core.py index 920360b..2581ff0 100644 --- a/src/power_grid_model_io_native/_core/power_grid_model_io_core.py +++ b/src/power_grid_model_io_native/_core/power_grid_model_io_core.py @@ -146,15 +146,17 @@ def error_message(self) -> str: # type: ignore[empty-body] pass # pragma: no cover @make_c_binding - def create_vnf_converter(self, data: str, experim_feature: int) -> PgmVnfConverterPtr: # type: ignore[empty-body] + def create_pgm_vnf_converter( # type: ignore[empty-body] + self, data: str, experimental_features: int + ) -> PgmVnfConverterPtr: pass # pragma: no cover @make_c_binding - def vnf_pgm_converter_get_input_data(self, pgmvnfconverter: PgmVnfConverterPtr) -> str: # type: ignore[empty-body] + def pgm_vnf_converter_get_input_data(self, pgmvnfconverter: PgmVnfConverterPtr) -> str: # type: ignore[empty-body] pass # pragma: no cover @make_c_binding - def destroy_vnf_converter(self, pgmvnfconverter: PgmVnfConverterPtr) -> None: # type: ignore[empty-body] + def destroy_pgm_vnf_converter(self, pgmvnfconverter: PgmVnfConverterPtr) -> None: # type: ignore[empty-body] pass # pragma: no cover diff --git a/tests/c_api_tests/CMakeLists.txt b/tests/c_api_tests/CMakeLists.txt index 80e418f..6b6ac08 100644 --- a/tests/c_api_tests/CMakeLists.txt +++ b/tests/c_api_tests/CMakeLists.txt @@ -5,7 +5,7 @@ set(PROJECT_SOURCES "test_c_api.cpp" "test_entry_point.cpp" - "test_c_api_vnf_converter.cpp" + "test_c_api_pgm_vnf_converter.cpp" ) add_executable(power_grid_model_io_native_c_api_tests ${PROJECT_SOURCES}) diff --git a/tests/c_api_tests/test_c_api_vnf_converter.cpp b/tests/c_api_tests/test_c_api_pgm_vnf_converter.cpp similarity index 75% rename from tests/c_api_tests/test_c_api_vnf_converter.cpp rename to tests/c_api_tests/test_c_api_pgm_vnf_converter.cpp index d7d14be..075cb42 100644 --- a/tests/c_api_tests/test_c_api_vnf_converter.cpp +++ b/tests/c_api_tests/test_c_api_pgm_vnf_converter.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include @@ -22,18 +22,18 @@ TEST_CASE("Test PGM_IO_create_vnf_converter") { SUBCASE("Test PGM_IO_create_vnf_converter without experimental feature flag") { PGM_IO_Handle* handle = PGM_IO_create_handle(); - auto converter = PGM_IO_create_vnf_converter(handle, "", experimental_feature_flag); + auto converter = PGM_IO_create_pgm_vnf_converter(handle, "", experimental_feature_flag); CHECK(PGM_IO_error_code(handle) == PGM_IO_regular_error); - PGM_IO_destroy_vnf_converter(converter); + PGM_IO_destroy_pgm_vnf_converter(converter); PGM_IO_destroy_handle(handle); } SUBCASE("Test PGM_IO_create_vnf_converter with experimental feature flag") { PGM_IO_Handle* handle = PGM_IO_create_handle(); experimental_feature_flag = PGM_IO_experimental_features_enabled; - auto converter = PGM_IO_create_vnf_converter(handle, "", experimental_feature_flag); + auto converter = PGM_IO_create_pgm_vnf_converter(handle, "", experimental_feature_flag); CHECK(converter != nullptr); - PGM_IO_destroy_vnf_converter(converter); + PGM_IO_destroy_pgm_vnf_converter(converter); PGM_IO_destroy_handle(handle); } } @@ -42,14 +42,14 @@ TEST_CASE("Test PGM_IO_get_vnf_input_data") { PGM_IO_Handle* handle = PGM_IO_create_handle(); PGM_IO_ExperimentalFeatures experimental_feature_flag = PGM_IO_experimental_features_enabled; - auto converter = PGM_IO_create_vnf_converter(handle, "", experimental_feature_flag); + auto converter = PGM_IO_create_pgm_vnf_converter(handle, "", experimental_feature_flag); CHECK(converter != nullptr); - auto json_result = PGM_IO_vnf_pgm_converter_get_input_data(handle, converter); + auto json_result = PGM_IO_pgm_vnf_converter_get_input_data(handle, converter); std::string_view json_string = R"({"version":"1.0","type":"input","is_batch":false,"attributes":{},"data":{}})"; CHECK(json_string == json_result); - PGM_IO_destroy_vnf_converter(converter); + PGM_IO_destroy_pgm_vnf_converter(converter); PGM_IO_destroy_handle(handle); } diff --git a/tests/cpp_unit_tests/test_pgm_vnf_converter.cpp b/tests/cpp_unit_tests/test_pgm_vnf_converter.cpp index 245bf50..b9994b5 100644 --- a/tests/cpp_unit_tests/test_pgm_vnf_converter.cpp +++ b/tests/cpp_unit_tests/test_pgm_vnf_converter.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MPL-2.0 #include -#include +#include #include #include diff --git a/tests/unit/test_vnf_converter.py b/tests/unit/test_vnf_converter.py index ff9fddc..b3a07fe 100644 --- a/tests/unit/test_vnf_converter.py +++ b/tests/unit/test_vnf_converter.py @@ -6,7 +6,7 @@ from power_grid_model._core.error_handling import InvalidArguments from power_grid_model_io_native._core.error_handling import assert_no_error -from power_grid_model_io_native._core.vnf_converter import PgmVnfConverter +from power_grid_model_io_native._core.pgm_vnf_converter import PgmVnfConverter def test_pgmvnfconverter_constructor_without_experimental_features():