power-grid-model 1.11.48__py3-none-win_amd64.whl → 1.12.72__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of power-grid-model might be problematic. Click here for more details.
- power_grid_model/__init__.py +54 -54
- power_grid_model/_core/__init__.py +3 -3
- power_grid_model/_core/buffer_handling.py +493 -487
- power_grid_model/_core/data_handling.py +195 -141
- power_grid_model/_core/data_types.py +143 -132
- power_grid_model/_core/dataset_definitions.py +109 -109
- power_grid_model/_core/enum.py +226 -226
- power_grid_model/_core/error_handling.py +206 -206
- power_grid_model/_core/errors.py +130 -130
- power_grid_model/_core/index_integer.py +17 -17
- power_grid_model/_core/options.py +71 -71
- power_grid_model/_core/power_grid_core.py +563 -563
- power_grid_model/_core/power_grid_dataset.py +535 -535
- power_grid_model/_core/power_grid_meta.py +257 -243
- power_grid_model/_core/power_grid_model.py +969 -686
- power_grid_model/_core/power_grid_model_c/__init__.py +3 -3
- power_grid_model/_core/power_grid_model_c/bin/power_grid_model_c.dll +0 -0
- power_grid_model/_core/power_grid_model_c/get_pgm_dll_path.py +63 -63
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/basics.h +255 -255
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/buffer.h +108 -108
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset.h +316 -316
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset_definitions.h +1052 -1052
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/handle.h +99 -99
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/meta_data.h +189 -189
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/model.h +125 -125
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/options.h +142 -142
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/serialization.h +118 -118
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c.h +36 -36
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/basics.hpp +65 -65
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/buffer.hpp +61 -61
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/dataset.hpp +220 -220
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/handle.hpp +108 -108
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/meta_data.hpp +84 -84
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/model.hpp +63 -63
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/options.hpp +52 -52
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/serialization.hpp +124 -124
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/utils.hpp +81 -81
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp.hpp +19 -19
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelConfigVersion.cmake +3 -3
- power_grid_model/_core/power_grid_model_c/lib/power_grid_model_c.lib +0 -0
- power_grid_model/_core/serialization.py +317 -317
- power_grid_model/_core/typing.py +20 -20
- power_grid_model/_core/utils.py +798 -793
- power_grid_model/data_types.py +321 -321
- power_grid_model/enum.py +27 -27
- power_grid_model/errors.py +37 -37
- power_grid_model/typing.py +43 -43
- power_grid_model/utils.py +473 -469
- power_grid_model/validation/__init__.py +25 -25
- power_grid_model/validation/_rules.py +1171 -1176
- power_grid_model/validation/_validation.py +1172 -1172
- power_grid_model/validation/assertions.py +93 -93
- power_grid_model/validation/errors.py +602 -602
- power_grid_model/validation/utils.py +313 -314
- {power_grid_model-1.11.48.dist-info → power_grid_model-1.12.72.dist-info}/METADATA +4 -2
- power_grid_model-1.12.72.dist-info/RECORD +65 -0
- {power_grid_model-1.11.48.dist-info → power_grid_model-1.12.72.dist-info}/WHEEL +1 -1
- power_grid_model-1.11.48.dist-info/RECORD +0 -65
- {power_grid_model-1.11.48.dist-info → power_grid_model-1.12.72.dist-info}/entry_points.txt +0 -0
- {power_grid_model-1.11.48.dist-info → power_grid_model-1.12.72.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @brief header file which includes serialization functions
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
#pragma once
|
|
11
|
-
#ifndef POWER_GRID_MODEL_C_SERIALIZATION_H
|
|
12
|
-
#define POWER_GRID_MODEL_C_SERIALIZATION_H
|
|
13
|
-
|
|
14
|
-
#include "basics.h"
|
|
15
|
-
|
|
16
|
-
#ifdef __cplusplus
|
|
17
|
-
extern "C" {
|
|
18
|
-
#endif
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @brief Create a deserializer from binary buffer/byte stream.
|
|
22
|
-
* @param handle
|
|
23
|
-
* @param data The pointer to the byte stream.
|
|
24
|
-
* @param size The size of the byte stream.
|
|
25
|
-
* @param serialization_format The desired data format of the serialization. See #PGM_SerializationFormat .
|
|
26
|
-
* @return A pointer to the deserializer instance. Should be freed by PGM_destroy_deserializer().
|
|
27
|
-
* Returns NULL if errors occured (check the handle for error information).
|
|
28
|
-
*/
|
|
29
|
-
PGM_API PGM_Deserializer* PGM_create_deserializer_from_binary_buffer(PGM_Handle* handle, char const* data, PGM_Idx size,
|
|
30
|
-
PGM_Idx serialization_format);
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @brief Create a deserializer from a null terminated C string.
|
|
34
|
-
* @param handle
|
|
35
|
-
* @param data_string The pointer to the null-terminated C string.
|
|
36
|
-
* @param serialization_format The desired data format of the serialization. See #PGM_SerializationFormat .
|
|
37
|
-
* @return A pointer to the deserializer instance. Should be freed by PGM_destroy_deserializer().
|
|
38
|
-
* Returns NULL if errors occured (check the handle for error information).
|
|
39
|
-
*/
|
|
40
|
-
PGM_API PGM_Deserializer* PGM_create_deserializer_from_null_terminated_string(PGM_Handle* handle,
|
|
41
|
-
char const* data_string,
|
|
42
|
-
PGM_Idx serialization_format);
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @brief Get the PGM_WritableDataset object from the deserializer.
|
|
46
|
-
* @param handle
|
|
47
|
-
* @param deserializer The pointer to the deserializer.
|
|
48
|
-
* @return A pointer the instance of PGM_WritableDataset.
|
|
49
|
-
* The pointer has the same lifetime as the deserializer.
|
|
50
|
-
* Use PGM_writable_dataset_get_info() to get the information of the dataset.
|
|
51
|
-
* Use PGM_writable_dataset_set_buffer() to set buffer.
|
|
52
|
-
*/
|
|
53
|
-
PGM_API PGM_WritableDataset* PGM_deserializer_get_dataset(PGM_Handle* handle, PGM_Deserializer* deserializer);
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @brief Parse the dataset and write to the user-provided buffers.
|
|
57
|
-
* The buffers must be set through PGM_writable_dataset_set_buffer().
|
|
58
|
-
* @param handle
|
|
59
|
-
* @param deserializer The pointer to the deserializer
|
|
60
|
-
* @return No return value; check handle for error.
|
|
61
|
-
*/
|
|
62
|
-
PGM_API void PGM_deserializer_parse_to_buffer(PGM_Handle* handle, PGM_Deserializer* deserializer);
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @brief Destory deserializer
|
|
66
|
-
* @param deserializer pointer to deserializer
|
|
67
|
-
* @return
|
|
68
|
-
*/
|
|
69
|
-
PGM_API void PGM_destroy_deserializer(PGM_Deserializer* deserializer);
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @brief Create a serializer object based on input dataset, the buffers must be set in advance.
|
|
73
|
-
* @param handle
|
|
74
|
-
* @param dataset A pointer to an instance of PGM_ConstDataset
|
|
75
|
-
* @param serialization_format The desired data format of the serialization. See #PGM_SerializationFormat .
|
|
76
|
-
* @return A pointer to the new serializer object. Should be freed by PGM_destroy_serializer()
|
|
77
|
-
* Returns NULL if errors occured (check the handle for error information).
|
|
78
|
-
*/
|
|
79
|
-
PGM_API PGM_Serializer* PGM_create_serializer(PGM_Handle* handle, PGM_ConstDataset const* dataset,
|
|
80
|
-
PGM_Idx serialization_format);
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @brief Serialize the dataset into a binary buffer format.
|
|
84
|
-
* @param handle
|
|
85
|
-
* @param serializer A pointer to an existing serializer.
|
|
86
|
-
* @param use_compact_list 1 for use compact list per element of serialization; 0 for use dictionary per element.
|
|
87
|
-
* @param data Output argument: the data pointer of the packed buffer will be written to *data.
|
|
88
|
-
* @param size Output argument: the length of the packed buffer will be written to *size.
|
|
89
|
-
* @return No return value; check handle for error.
|
|
90
|
-
*/
|
|
91
|
-
PGM_API void PGM_serializer_get_to_binary_buffer(PGM_Handle* handle, PGM_Serializer* serializer,
|
|
92
|
-
PGM_Idx use_compact_list, char const** data, PGM_Idx* size);
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @brief Serialize the dataset into a zero terminated C string.
|
|
96
|
-
* Only supported for uncompressed data formats.
|
|
97
|
-
* @param handle
|
|
98
|
-
* @param serializer A pointer to an existing serializer.
|
|
99
|
-
* @param use_compact_list 1 for use compact list per element of serialization; 0 for use dictionary per element.
|
|
100
|
-
* @param indent The indentation of the JSON, use -1 for no indent and no new line (compact format).
|
|
101
|
-
* @return A NULL-terminated json string.
|
|
102
|
-
* Returns NULL if errors occured (check the handle for error information).
|
|
103
|
-
*/
|
|
104
|
-
PGM_API char const* PGM_serializer_get_to_zero_terminated_string(PGM_Handle* handle, PGM_Serializer* serializer,
|
|
105
|
-
PGM_Idx use_compact_list, PGM_Idx indent);
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* @brief Destroy serializer.
|
|
109
|
-
* @param serializer The pointer to the serializer.
|
|
110
|
-
* @return
|
|
111
|
-
*/
|
|
112
|
-
PGM_API void PGM_destroy_serializer(PGM_Serializer* serializer);
|
|
113
|
-
|
|
114
|
-
#ifdef __cplusplus
|
|
115
|
-
}
|
|
116
|
-
#endif
|
|
117
|
-
|
|
118
|
-
#endif
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @brief header file which includes serialization functions
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
#ifndef POWER_GRID_MODEL_C_SERIALIZATION_H
|
|
12
|
+
#define POWER_GRID_MODEL_C_SERIALIZATION_H
|
|
13
|
+
|
|
14
|
+
#include "basics.h"
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
extern "C" {
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @brief Create a deserializer from binary buffer/byte stream.
|
|
22
|
+
* @param handle
|
|
23
|
+
* @param data The pointer to the byte stream.
|
|
24
|
+
* @param size The size of the byte stream.
|
|
25
|
+
* @param serialization_format The desired data format of the serialization. See #PGM_SerializationFormat .
|
|
26
|
+
* @return A pointer to the deserializer instance. Should be freed by PGM_destroy_deserializer().
|
|
27
|
+
* Returns NULL if errors occured (check the handle for error information).
|
|
28
|
+
*/
|
|
29
|
+
PGM_API PGM_Deserializer* PGM_create_deserializer_from_binary_buffer(PGM_Handle* handle, char const* data, PGM_Idx size,
|
|
30
|
+
PGM_Idx serialization_format);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @brief Create a deserializer from a null terminated C string.
|
|
34
|
+
* @param handle
|
|
35
|
+
* @param data_string The pointer to the null-terminated C string.
|
|
36
|
+
* @param serialization_format The desired data format of the serialization. See #PGM_SerializationFormat .
|
|
37
|
+
* @return A pointer to the deserializer instance. Should be freed by PGM_destroy_deserializer().
|
|
38
|
+
* Returns NULL if errors occured (check the handle for error information).
|
|
39
|
+
*/
|
|
40
|
+
PGM_API PGM_Deserializer* PGM_create_deserializer_from_null_terminated_string(PGM_Handle* handle,
|
|
41
|
+
char const* data_string,
|
|
42
|
+
PGM_Idx serialization_format);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @brief Get the PGM_WritableDataset object from the deserializer.
|
|
46
|
+
* @param handle
|
|
47
|
+
* @param deserializer The pointer to the deserializer.
|
|
48
|
+
* @return A pointer the instance of PGM_WritableDataset.
|
|
49
|
+
* The pointer has the same lifetime as the deserializer.
|
|
50
|
+
* Use PGM_writable_dataset_get_info() to get the information of the dataset.
|
|
51
|
+
* Use PGM_writable_dataset_set_buffer() to set buffer.
|
|
52
|
+
*/
|
|
53
|
+
PGM_API PGM_WritableDataset* PGM_deserializer_get_dataset(PGM_Handle* handle, PGM_Deserializer* deserializer);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @brief Parse the dataset and write to the user-provided buffers.
|
|
57
|
+
* The buffers must be set through PGM_writable_dataset_set_buffer().
|
|
58
|
+
* @param handle
|
|
59
|
+
* @param deserializer The pointer to the deserializer
|
|
60
|
+
* @return No return value; check handle for error.
|
|
61
|
+
*/
|
|
62
|
+
PGM_API void PGM_deserializer_parse_to_buffer(PGM_Handle* handle, PGM_Deserializer* deserializer);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @brief Destory deserializer
|
|
66
|
+
* @param deserializer pointer to deserializer
|
|
67
|
+
* @return
|
|
68
|
+
*/
|
|
69
|
+
PGM_API void PGM_destroy_deserializer(PGM_Deserializer* deserializer);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @brief Create a serializer object based on input dataset, the buffers must be set in advance.
|
|
73
|
+
* @param handle
|
|
74
|
+
* @param dataset A pointer to an instance of PGM_ConstDataset
|
|
75
|
+
* @param serialization_format The desired data format of the serialization. See #PGM_SerializationFormat .
|
|
76
|
+
* @return A pointer to the new serializer object. Should be freed by PGM_destroy_serializer()
|
|
77
|
+
* Returns NULL if errors occured (check the handle for error information).
|
|
78
|
+
*/
|
|
79
|
+
PGM_API PGM_Serializer* PGM_create_serializer(PGM_Handle* handle, PGM_ConstDataset const* dataset,
|
|
80
|
+
PGM_Idx serialization_format);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @brief Serialize the dataset into a binary buffer format.
|
|
84
|
+
* @param handle
|
|
85
|
+
* @param serializer A pointer to an existing serializer.
|
|
86
|
+
* @param use_compact_list 1 for use compact list per element of serialization; 0 for use dictionary per element.
|
|
87
|
+
* @param data Output argument: the data pointer of the packed buffer will be written to *data.
|
|
88
|
+
* @param size Output argument: the length of the packed buffer will be written to *size.
|
|
89
|
+
* @return No return value; check handle for error.
|
|
90
|
+
*/
|
|
91
|
+
PGM_API void PGM_serializer_get_to_binary_buffer(PGM_Handle* handle, PGM_Serializer* serializer,
|
|
92
|
+
PGM_Idx use_compact_list, char const** data, PGM_Idx* size);
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @brief Serialize the dataset into a zero terminated C string.
|
|
96
|
+
* Only supported for uncompressed data formats.
|
|
97
|
+
* @param handle
|
|
98
|
+
* @param serializer A pointer to an existing serializer.
|
|
99
|
+
* @param use_compact_list 1 for use compact list per element of serialization; 0 for use dictionary per element.
|
|
100
|
+
* @param indent The indentation of the JSON, use -1 for no indent and no new line (compact format).
|
|
101
|
+
* @return A NULL-terminated json string.
|
|
102
|
+
* Returns NULL if errors occured (check the handle for error information).
|
|
103
|
+
*/
|
|
104
|
+
PGM_API char const* PGM_serializer_get_to_zero_terminated_string(PGM_Handle* handle, PGM_Serializer* serializer,
|
|
105
|
+
PGM_Idx use_compact_list, PGM_Idx indent);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @brief Destroy serializer.
|
|
109
|
+
* @param serializer The pointer to the serializer.
|
|
110
|
+
* @return
|
|
111
|
+
*/
|
|
112
|
+
PGM_API void PGM_destroy_serializer(PGM_Serializer* serializer);
|
|
113
|
+
|
|
114
|
+
#ifdef __cplusplus
|
|
115
|
+
}
|
|
116
|
+
#endif
|
|
117
|
+
|
|
118
|
+
#endif
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @mainpage Power Grid Model C API Documentation
|
|
7
|
-
* This gives an overview of C API.
|
|
8
|
-
* All the exported functions are included in power_grid_model_c.h, except the dataset definitions
|
|
9
|
-
*
|
|
10
|
-
* Users can also include individual headers for a subset of the functionality
|
|
11
|
-
* - power_grid_model_c/basics.h: type and enum definition
|
|
12
|
-
* - power_grid_model_c/buffer.h: functions with buffer creation, release, set and get value
|
|
13
|
-
* - power_grid_model_c/handle.h: functions with error handling
|
|
14
|
-
* - power_grid_model_c/meta_data.h: functions with meta data
|
|
15
|
-
* - power_grid_model_c/model.h: functions with create, release, run calculation of model
|
|
16
|
-
* - power_grid_model_c/options.h: functions with setting the calculation options
|
|
17
|
-
* - power_grid_model_c/serialization.h: functions with serialization functions
|
|
18
|
-
* - power_grid_model_c/dataset.h: functions with dataset handling functions
|
|
19
|
-
* - power_grid_model_c/dataset_definitions.h: external pointer variables to all datasets, components, and
|
|
20
|
-
* attributes. You have to include this header separately. It is not included by power_grid_model_c.h.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
#pragma once
|
|
24
|
-
#ifndef POWER_GRID_MODEL_C_H
|
|
25
|
-
#define POWER_GRID_MODEL_C_H
|
|
26
|
-
|
|
27
|
-
#include "power_grid_model_c/basics.h"
|
|
28
|
-
#include "power_grid_model_c/buffer.h"
|
|
29
|
-
#include "power_grid_model_c/dataset.h"
|
|
30
|
-
#include "power_grid_model_c/handle.h"
|
|
31
|
-
#include "power_grid_model_c/meta_data.h"
|
|
32
|
-
#include "power_grid_model_c/model.h"
|
|
33
|
-
#include "power_grid_model_c/options.h"
|
|
34
|
-
#include "power_grid_model_c/serialization.h"
|
|
35
|
-
|
|
36
|
-
#endif // POWER_GRID_MODEL_C_H
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @mainpage Power Grid Model C API Documentation
|
|
7
|
+
* This gives an overview of C API.
|
|
8
|
+
* All the exported functions are included in power_grid_model_c.h, except the dataset definitions
|
|
9
|
+
*
|
|
10
|
+
* Users can also include individual headers for a subset of the functionality
|
|
11
|
+
* - power_grid_model_c/basics.h: type and enum definition
|
|
12
|
+
* - power_grid_model_c/buffer.h: functions with buffer creation, release, set and get value
|
|
13
|
+
* - power_grid_model_c/handle.h: functions with error handling
|
|
14
|
+
* - power_grid_model_c/meta_data.h: functions with meta data
|
|
15
|
+
* - power_grid_model_c/model.h: functions with create, release, run calculation of model
|
|
16
|
+
* - power_grid_model_c/options.h: functions with setting the calculation options
|
|
17
|
+
* - power_grid_model_c/serialization.h: functions with serialization functions
|
|
18
|
+
* - power_grid_model_c/dataset.h: functions with dataset handling functions
|
|
19
|
+
* - power_grid_model_c/dataset_definitions.h: external pointer variables to all datasets, components, and
|
|
20
|
+
* attributes. You have to include this header separately. It is not included by power_grid_model_c.h.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
#pragma once
|
|
24
|
+
#ifndef POWER_GRID_MODEL_C_H
|
|
25
|
+
#define POWER_GRID_MODEL_C_H
|
|
26
|
+
|
|
27
|
+
#include "power_grid_model_c/basics.h"
|
|
28
|
+
#include "power_grid_model_c/buffer.h"
|
|
29
|
+
#include "power_grid_model_c/dataset.h"
|
|
30
|
+
#include "power_grid_model_c/handle.h"
|
|
31
|
+
#include "power_grid_model_c/meta_data.h"
|
|
32
|
+
#include "power_grid_model_c/model.h"
|
|
33
|
+
#include "power_grid_model_c/options.h"
|
|
34
|
+
#include "power_grid_model_c/serialization.h"
|
|
35
|
+
|
|
36
|
+
#endif // POWER_GRID_MODEL_C_H
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
|
|
5
|
-
#pragma once
|
|
6
|
-
#ifndef POWER_GRID_MODEL_CPP_BASICS_HPP
|
|
7
|
-
#define POWER_GRID_MODEL_CPP_BASICS_HPP
|
|
8
|
-
|
|
9
|
-
#ifdef PGM_DLL_EXPORTS
|
|
10
|
-
#error \
|
|
11
|
-
"Cannot export out-of-line PGM C API symbols from the inline header-only PGM C++ API. Please disable PGM_DLL_EXPORT."
|
|
12
|
-
#endif
|
|
13
|
-
|
|
14
|
-
#ifndef PGM_ENABLE_EXPERIMENTAL
|
|
15
|
-
#error "This is an experimental feature. Please #define PGM_ENABLE_EXPERIMENTAL to use this."
|
|
16
|
-
#endif
|
|
17
|
-
|
|
18
|
-
#include "power_grid_model_c/basics.h"
|
|
19
|
-
|
|
20
|
-
#include <cassert>
|
|
21
|
-
#include <exception>
|
|
22
|
-
#include <memory>
|
|
23
|
-
#include <string>
|
|
24
|
-
#include <vector>
|
|
25
|
-
|
|
26
|
-
namespace power_grid_model_cpp {
|
|
27
|
-
|
|
28
|
-
using Idx = PGM_Idx;
|
|
29
|
-
using ID = PGM_ID;
|
|
30
|
-
using IntS = int8_t;
|
|
31
|
-
|
|
32
|
-
using PowerGridModel = PGM_PowerGridModel;
|
|
33
|
-
using MetaDataset = PGM_MetaDataset;
|
|
34
|
-
using MetaComponent = PGM_MetaComponent;
|
|
35
|
-
using MetaAttribute = PGM_MetaAttribute;
|
|
36
|
-
using RawHandle = PGM_Handle;
|
|
37
|
-
using RawDataPtr = void*; // raw mutable data ptr
|
|
38
|
-
using RawDataConstPtr = void const*; // raw read-only data ptr
|
|
39
|
-
using RawConstDataset = PGM_ConstDataset;
|
|
40
|
-
using RawMutableDataset = PGM_MutableDataset;
|
|
41
|
-
using RawWritableDataset = PGM_WritableDataset;
|
|
42
|
-
using RawDatasetInfo = PGM_DatasetInfo;
|
|
43
|
-
using RawOptions = PGM_Options;
|
|
44
|
-
using RawDeserializer = PGM_Deserializer;
|
|
45
|
-
using RawSerializer = PGM_Serializer;
|
|
46
|
-
|
|
47
|
-
namespace detail {
|
|
48
|
-
// custom deleter
|
|
49
|
-
template <auto func> struct DeleterFunctor {
|
|
50
|
-
template <typename T> void operator()(T* arg) const { func(arg); }
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// unique pointer definition
|
|
54
|
-
template <typename T, auto func> class UniquePtr : public std::unique_ptr<T, DeleterFunctor<func>> {
|
|
55
|
-
public:
|
|
56
|
-
using std::unique_ptr<T, DeleterFunctor<func>>::unique_ptr;
|
|
57
|
-
using std::unique_ptr<T, DeleterFunctor<func>>::operator=;
|
|
58
|
-
T* get() { return static_cast<std::unique_ptr<T, DeleterFunctor<func>>&>(*this).get(); }
|
|
59
|
-
T const* get() const { return static_cast<std::unique_ptr<T, DeleterFunctor<func>> const&>(*this).get(); }
|
|
60
|
-
};
|
|
61
|
-
} // namespace detail
|
|
62
|
-
|
|
63
|
-
} // namespace power_grid_model_cpp
|
|
64
|
-
|
|
65
|
-
#endif // POWER_GRID_MODEL_CPP_BASICS_HPP
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
#ifndef POWER_GRID_MODEL_CPP_BASICS_HPP
|
|
7
|
+
#define POWER_GRID_MODEL_CPP_BASICS_HPP
|
|
8
|
+
|
|
9
|
+
#ifdef PGM_DLL_EXPORTS
|
|
10
|
+
#error \
|
|
11
|
+
"Cannot export out-of-line PGM C API symbols from the inline header-only PGM C++ API. Please disable PGM_DLL_EXPORT."
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
#ifndef PGM_ENABLE_EXPERIMENTAL
|
|
15
|
+
#error "This is an experimental feature. Please #define PGM_ENABLE_EXPERIMENTAL to use this."
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
#include "power_grid_model_c/basics.h"
|
|
19
|
+
|
|
20
|
+
#include <cassert>
|
|
21
|
+
#include <exception>
|
|
22
|
+
#include <memory>
|
|
23
|
+
#include <string>
|
|
24
|
+
#include <vector>
|
|
25
|
+
|
|
26
|
+
namespace power_grid_model_cpp {
|
|
27
|
+
|
|
28
|
+
using Idx = PGM_Idx;
|
|
29
|
+
using ID = PGM_ID;
|
|
30
|
+
using IntS = int8_t;
|
|
31
|
+
|
|
32
|
+
using PowerGridModel = PGM_PowerGridModel;
|
|
33
|
+
using MetaDataset = PGM_MetaDataset;
|
|
34
|
+
using MetaComponent = PGM_MetaComponent;
|
|
35
|
+
using MetaAttribute = PGM_MetaAttribute;
|
|
36
|
+
using RawHandle = PGM_Handle;
|
|
37
|
+
using RawDataPtr = void*; // raw mutable data ptr
|
|
38
|
+
using RawDataConstPtr = void const*; // raw read-only data ptr
|
|
39
|
+
using RawConstDataset = PGM_ConstDataset;
|
|
40
|
+
using RawMutableDataset = PGM_MutableDataset;
|
|
41
|
+
using RawWritableDataset = PGM_WritableDataset;
|
|
42
|
+
using RawDatasetInfo = PGM_DatasetInfo;
|
|
43
|
+
using RawOptions = PGM_Options;
|
|
44
|
+
using RawDeserializer = PGM_Deserializer;
|
|
45
|
+
using RawSerializer = PGM_Serializer;
|
|
46
|
+
|
|
47
|
+
namespace detail {
|
|
48
|
+
// custom deleter
|
|
49
|
+
template <auto func> struct DeleterFunctor {
|
|
50
|
+
template <typename T> void operator()(T* arg) const { func(arg); }
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// unique pointer definition
|
|
54
|
+
template <typename T, auto func> class UniquePtr : public std::unique_ptr<T, DeleterFunctor<func>> {
|
|
55
|
+
public:
|
|
56
|
+
using std::unique_ptr<T, DeleterFunctor<func>>::unique_ptr;
|
|
57
|
+
using std::unique_ptr<T, DeleterFunctor<func>>::operator=;
|
|
58
|
+
T* get() { return static_cast<std::unique_ptr<T, DeleterFunctor<func>>&>(*this).get(); }
|
|
59
|
+
T const* get() const { return static_cast<std::unique_ptr<T, DeleterFunctor<func>> const&>(*this).get(); }
|
|
60
|
+
};
|
|
61
|
+
} // namespace detail
|
|
62
|
+
|
|
63
|
+
} // namespace power_grid_model_cpp
|
|
64
|
+
|
|
65
|
+
#endif // POWER_GRID_MODEL_CPP_BASICS_HPP
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
|
|
5
|
-
#pragma once
|
|
6
|
-
#ifndef POWER_GRID_MODEL_CPP_BUFFER_HPP
|
|
7
|
-
#define POWER_GRID_MODEL_CPP_BUFFER_HPP
|
|
8
|
-
|
|
9
|
-
#include "basics.hpp"
|
|
10
|
-
#include "handle.hpp"
|
|
11
|
-
|
|
12
|
-
#include "power_grid_model_c/buffer.h"
|
|
13
|
-
|
|
14
|
-
namespace power_grid_model_cpp {
|
|
15
|
-
class Buffer {
|
|
16
|
-
public:
|
|
17
|
-
Buffer(MetaComponent const* component, Idx size)
|
|
18
|
-
: component_{component}, size_{size}, buffer_{handle_.call_with(PGM_create_buffer, component, size)} {};
|
|
19
|
-
|
|
20
|
-
RawDataConstPtr get() const { return buffer_.get(); }
|
|
21
|
-
RawDataPtr get() { return buffer_.get(); }
|
|
22
|
-
|
|
23
|
-
Idx size() const { return size_; }
|
|
24
|
-
|
|
25
|
-
void set_nan() { set_nan(0, size_); }
|
|
26
|
-
void set_nan(Idx buffer_offset) { set_nan(buffer_offset, 1); }
|
|
27
|
-
void set_nan(Idx buffer_offset, Idx size) {
|
|
28
|
-
handle_.call_with(PGM_buffer_set_nan, component_, get(), buffer_offset, size);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
void set_value(MetaAttribute const* attribute, RawDataConstPtr src_ptr, Idx src_stride) {
|
|
32
|
-
set_value(attribute, src_ptr, 0, size_, src_stride);
|
|
33
|
-
}
|
|
34
|
-
void set_value(MetaAttribute const* attribute, RawDataConstPtr src_ptr, Idx buffer_offset, Idx src_stride) {
|
|
35
|
-
set_value(attribute, src_ptr, buffer_offset, 1, src_stride);
|
|
36
|
-
}
|
|
37
|
-
void set_value(MetaAttribute const* attribute, RawDataConstPtr src_ptr, Idx buffer_offset, Idx size,
|
|
38
|
-
Idx src_stride) {
|
|
39
|
-
handle_.call_with(PGM_buffer_set_value, attribute, get(), src_ptr, buffer_offset, size, src_stride);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
void get_value(MetaAttribute const* attribute, RawDataPtr dest_ptr, Idx dest_stride) const {
|
|
43
|
-
get_value(attribute, dest_ptr, 0, size_, dest_stride);
|
|
44
|
-
}
|
|
45
|
-
void get_value(MetaAttribute const* attribute, RawDataPtr dest_ptr, Idx buffer_offset, Idx dest_stride) const {
|
|
46
|
-
get_value(attribute, dest_ptr, buffer_offset, 1, dest_stride);
|
|
47
|
-
}
|
|
48
|
-
void get_value(MetaAttribute const* attribute, RawDataPtr dest_ptr, Idx buffer_offset, Idx size,
|
|
49
|
-
Idx dest_stride) const {
|
|
50
|
-
handle_.call_with(PGM_buffer_get_value, attribute, get(), dest_ptr, buffer_offset, size, dest_stride);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private:
|
|
54
|
-
Handle handle_{};
|
|
55
|
-
MetaComponent const* component_;
|
|
56
|
-
Idx size_;
|
|
57
|
-
detail::UniquePtr<void, &PGM_destroy_buffer> buffer_;
|
|
58
|
-
};
|
|
59
|
-
} // namespace power_grid_model_cpp
|
|
60
|
-
|
|
61
|
-
#endif // POWER_GRID_MODEL_CPP_BUFFER_HPP
|
|
1
|
+
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
#ifndef POWER_GRID_MODEL_CPP_BUFFER_HPP
|
|
7
|
+
#define POWER_GRID_MODEL_CPP_BUFFER_HPP
|
|
8
|
+
|
|
9
|
+
#include "basics.hpp"
|
|
10
|
+
#include "handle.hpp"
|
|
11
|
+
|
|
12
|
+
#include "power_grid_model_c/buffer.h"
|
|
13
|
+
|
|
14
|
+
namespace power_grid_model_cpp {
|
|
15
|
+
class Buffer {
|
|
16
|
+
public:
|
|
17
|
+
Buffer(MetaComponent const* component, Idx size)
|
|
18
|
+
: component_{component}, size_{size}, buffer_{handle_.call_with(PGM_create_buffer, component, size)} {};
|
|
19
|
+
|
|
20
|
+
RawDataConstPtr get() const { return buffer_.get(); }
|
|
21
|
+
RawDataPtr get() { return buffer_.get(); }
|
|
22
|
+
|
|
23
|
+
Idx size() const { return size_; }
|
|
24
|
+
|
|
25
|
+
void set_nan() { set_nan(0, size_); }
|
|
26
|
+
void set_nan(Idx buffer_offset) { set_nan(buffer_offset, 1); }
|
|
27
|
+
void set_nan(Idx buffer_offset, Idx size) {
|
|
28
|
+
handle_.call_with(PGM_buffer_set_nan, component_, get(), buffer_offset, size);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
void set_value(MetaAttribute const* attribute, RawDataConstPtr src_ptr, Idx src_stride) {
|
|
32
|
+
set_value(attribute, src_ptr, 0, size_, src_stride);
|
|
33
|
+
}
|
|
34
|
+
void set_value(MetaAttribute const* attribute, RawDataConstPtr src_ptr, Idx buffer_offset, Idx src_stride) {
|
|
35
|
+
set_value(attribute, src_ptr, buffer_offset, 1, src_stride);
|
|
36
|
+
}
|
|
37
|
+
void set_value(MetaAttribute const* attribute, RawDataConstPtr src_ptr, Idx buffer_offset, Idx size,
|
|
38
|
+
Idx src_stride) {
|
|
39
|
+
handle_.call_with(PGM_buffer_set_value, attribute, get(), src_ptr, buffer_offset, size, src_stride);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void get_value(MetaAttribute const* attribute, RawDataPtr dest_ptr, Idx dest_stride) const {
|
|
43
|
+
get_value(attribute, dest_ptr, 0, size_, dest_stride);
|
|
44
|
+
}
|
|
45
|
+
void get_value(MetaAttribute const* attribute, RawDataPtr dest_ptr, Idx buffer_offset, Idx dest_stride) const {
|
|
46
|
+
get_value(attribute, dest_ptr, buffer_offset, 1, dest_stride);
|
|
47
|
+
}
|
|
48
|
+
void get_value(MetaAttribute const* attribute, RawDataPtr dest_ptr, Idx buffer_offset, Idx size,
|
|
49
|
+
Idx dest_stride) const {
|
|
50
|
+
handle_.call_with(PGM_buffer_get_value, attribute, get(), dest_ptr, buffer_offset, size, dest_stride);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private:
|
|
54
|
+
Handle handle_{};
|
|
55
|
+
MetaComponent const* component_;
|
|
56
|
+
Idx size_;
|
|
57
|
+
detail::UniquePtr<void, &PGM_destroy_buffer> buffer_;
|
|
58
|
+
};
|
|
59
|
+
} // namespace power_grid_model_cpp
|
|
60
|
+
|
|
61
|
+
#endif // POWER_GRID_MODEL_CPP_BUFFER_HPP
|