Skip to content

Commit 4775af0

Browse files
Major Refactoring of property array methods
[C++] Replaces type-specific property array methods with generic pushBackArray* and getArrayOfValuesOfPatch template methods in example.cpp. Can now get/set and compute statistics when reading/writing these arrays (RESQML2.0.1 only support min and max statistics). [SWIG] Rename pushBack*Hdf5ArrayOfValues by pushBack*ArrayOfValues (i.e remove Hdf5)
1 parent 36dacc3 commit 4775af0

51 files changed

Lines changed: 1932 additions & 1415 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmake/FesapiJavaExample.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ private static void serializeBoundaries(DataObjectRepository repo, AbstractHdfPr
477477
fesapi.DoubleArray_setitem(prop1Values, 14, 351);
478478
fesapi.DoubleArray_setitem(prop1Values, 15, 352);
479479

480-
contProp1.pushBackDoubleHdf5Array2dOfValues(prop1Values, 2, 8, hdfProxy);
480+
contProp1.pushBackDoubleArray2dOfValues(prop1Values, 2, 8, hdfProxy);
481481
}
482482
finally {
483483
fesapi.delete_DoubleArray(prop1Values);
@@ -497,7 +497,7 @@ private static void serializeIjkGrid(DataObjectRepository repo, AbstractHdfProxy
497497
try {
498498
fesapi.UInt16Array_setitem(propValues, 0, 0);
499499
fesapi.UInt16Array_setitem(propValues, 1, 1);
500-
discreteProp1.pushBackUInt16Hdf5Array3dOfValues(propValues, 2, 1, 1, hdfProxy, 1111);
500+
discreteProp1.pushBackUInt16Array3dOfValues(propValues, 2, 1, 1, hdfProxy, 1111);
501501
}
502502
finally {
503503
fesapi.delete_UInt16Array(propValues);
@@ -510,7 +510,7 @@ private static void serializeIjkGrid(DataObjectRepository repo, AbstractHdfProxy
510510
try {
511511
fesapi.UInt16Array_setitem(propValues, 0, 10);
512512
fesapi.UInt16Array_setitem(propValues, 1, 11);
513-
discreteProp2.pushBackUInt16Hdf5Array3dOfValues(propValues, 2, 1, 1, hdfProxy, 1111);
513+
discreteProp2.pushBackUInt16Array3dOfValues(propValues, 2, 1, 1, hdfProxy, 1111);
514514
}
515515
finally {
516516
fesapi.delete_UInt16Array(propValues);
@@ -588,7 +588,7 @@ private static void serializeGraphicalInformationSet(DataObjectRepository repo,
588588
try {
589589
fesapi.UInt16Array_setitem(propValues, 0, 10);
590590
fesapi.UInt16Array_setitem(propValues, 1, 11);
591-
discreteProp2.pushBackUInt16Hdf5Array3dOfValues(propValues, 2, 1, 1, hdfProxy, 1111);
591+
discreteProp2.pushBackUInt16Array3dOfValues(propValues, 2, 1, 1, hdfProxy, 1111);
592592
}
593593
finally {
594594
fesapi.delete_UInt16Array(propValues);
@@ -625,7 +625,7 @@ private static void serializeGraphicalInformationSet(DataObjectRepository repo,
625625
finally {
626626
fesapi.delete_DoubleArray(values);
627627
}
628-
contColMapContProp.pushBackDoubleHdf5Array2dOfValues(values, numPointInFastestDirection, numPointsInSlowestDirection, hdfProxy);
628+
contColMapContProp.pushBackDoubleArray2dOfValues(values, numPointInFastestDirection, numPointsInSlowestDirection, hdfProxy);
629629

630630
ContinuousColorMap contColMap = repo.createContinuousColorMap("a207faa2-963e-48d6-b3ad-53f6c1fc4dd4", "Continuous color map", resqml22__InterpolationDomain.rgb, resqml22__InterpolationMethod.linear);
631631
SWIGTYPE_p_unsigned_char contColMapRgbColors = fesapi.new_UInt8Array(6);

example/example.cpp

Lines changed: 89 additions & 43 deletions
Large diffs are not rendered by default.

python/example/example.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ def serialize_grid(repo: fesapi.DataObjectRepository):
3030
resqml_values = fesapi.FloatArray(3)
3131
for i, value in enumerate(prop_values):
3232
resqml_values.setitem(i, value)
33-
continuous_prop.pushBackFloatHdf5Array3dOfValues(resqml_values, 1, 1, 3, 1.1, 3.3)
33+
stats = fesapi.FloatArrayStatistics()
34+
stats.setMaximum(3.3)
35+
stats.setMinimum(1.1)
36+
continuous_prop.pushBackFloatArray3dOfValuesPlusStatistics(resqml_values, 1, 1, 3, stats)
3437

3538
def serialize(file_name: str):
3639
"""

src/common/AbstractObject.cpp

Lines changed: 146 additions & 312 deletions
Large diffs are not rendered by default.

src/common/AbstractObject.h

Lines changed: 29 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ namespace COMMON_NS
775775
const std::string & description, time_t lastUpdate, const std::string & descriptiveKeywords);
776776

777777
/** Throw an exception if the instance if partial. */
778-
void cannotBePartial() const;
778+
DLL_IMPORT_OR_EXPORT void cannotBePartial() const;
779779

780780
/**
781781
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
@@ -784,7 +784,7 @@ namespace COMMON_NS
784784
* @param [in] arrayInput If non-null, the array input.
785785
* @param [out] arrayOutput If non-null, the array output.
786786
*/
787-
void readArrayNdOfFloatValues(gsoap_resqml2_0_1::resqml20__AbstractDoubleArray const* arrayInput, float* arrayOutput) const;
787+
DLL_IMPORT_OR_EXPORT void readArrayNdOfFloatValues(gsoap_resqml2_0_1::resqml20__AbstractDoubleArray const* arrayInput, float* arrayOutput) const;
788788

789789
/**
790790
* Read an input array which come from EML 2.3 (and potentially HDF5) and store it into a
@@ -793,7 +793,7 @@ namespace COMMON_NS
793793
* @param [in] arrayInput If non-null, the array input.
794794
* @param [out] arrayOutput If non-null, the array output.
795795
*/
796-
void readArrayNdOfFloatValues(gsoap_eml2_3::eml23__AbstractFloatingPointArray const* arrayInput, float* arrayOutput) const;
796+
DLL_IMPORT_OR_EXPORT void readArrayNdOfFloatValues(gsoap_eml2_3::eml23__AbstractFloatingPointArray const* arrayInput, float* arrayOutput) const;
797797

798798
/**
799799
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
@@ -802,7 +802,7 @@ namespace COMMON_NS
802802
* @param [in] arrayInput If non-null, the array input.
803803
* @param [out] arrayOutput If non-null, the array output.
804804
*/
805-
void readArrayNdOfDoubleValues(gsoap_resqml2_0_1::resqml20__AbstractDoubleArray const* arrayInput, double * arrayOutput) const;
805+
DLL_IMPORT_OR_EXPORT void readArrayNdOfDoubleValues(gsoap_resqml2_0_1::resqml20__AbstractDoubleArray const* arrayInput, double * arrayOutput) const;
806806

807807
/**
808808
* Read an input array which come from EML 2.3 (and potentially HDF5) and store it into a
@@ -811,7 +811,7 @@ namespace COMMON_NS
811811
* @param [in] arrayInput If non-null, the array input.
812812
* @param [out] arrayOutput If non-null, the array output.
813813
*/
814-
void readArrayNdOfDoubleValues(gsoap_eml2_3::eml23__AbstractFloatingPointArray const* arrayInput, double * arrayOutput) const;
814+
DLL_IMPORT_OR_EXPORT void readArrayNdOfDoubleValues(gsoap_eml2_3::eml23__AbstractFloatingPointArray const* arrayInput, double * arrayOutput) const;
815815

816816
template <class T>
817817
T readArrayNdOfNonHdf5IntegerValues(gsoap_resqml2_0_1::resqml20__AbstractValueArray const * arrayInput, T * arrayOutput) const {
@@ -925,53 +925,10 @@ namespace COMMON_NS
925925
* @param [in] arrayInput If non-null, the array input.
926926
* @param [out] arrayOutput If non-null, the array output.
927927
*
928-
* @returns The null value of this array. Default returned value is uint8_t::max
928+
* @returns The null value of this array. Default returned value is the max numeric limits of T.
929929
*/
930-
uint8_t readArrayNdOfUInt8Values(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, uint8_t * arrayOutput) const;
931-
932-
/**
933-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
934-
* preallocated output array in memory. It does not allocate or deallocate memory.
935-
*
936-
* @param [in] arrayInput If non-null, the array input.
937-
* @param [out] arrayOutput If non-null, the array output.
938-
*
939-
* @returns The null value of this array. Default returned value is uint16_t::max
940-
*/
941-
uint8_t readArrayNdOfUInt8Values(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, uint8_t * arrayOutput) const;
942-
943-
/**
944-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
945-
* preallocated output array in memory. It does not allocate or deallocate memory.
946-
*
947-
* @param [in] arrayInput If non-null, the array input.
948-
* @param [out] arrayOutput If non-null, the array output.
949-
*
950-
* @returns The null value of this array. Default returned value is uint16_t::max
951-
*/
952-
uint16_t readArrayNdOfUInt16Values(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, uint16_t * arrayOutput) const;
953-
954-
/**
955-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
956-
* preallocated output array in memory. It does not allocate or deallocate memory.
957-
*
958-
* @param [in] arrayInput If non-null, the array input.
959-
* @param [out] arrayOutput If non-null, the array output.
960-
*
961-
* @returns The null value of this array. Default returned value is uint8_t::max
962-
*/
963-
uint16_t readArrayNdOfUInt16Values(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, uint16_t * arrayOutput) const;
964-
965-
/**
966-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
967-
* preallocated output array in memory. It does not allocate or deallocate memory.
968-
*
969-
* @param [in] arrayInput If non-null, the array input.
970-
* @param [out] arrayOutput If non-null, the array output.
971-
*
972-
* @returns The null value of this array. Default returned value is uint32_t::max
973-
*/
974-
uint32_t readArrayNdOfUInt32Values(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, uint32_t * arrayOutput) const;
930+
template<typename T>
931+
T readArrayNdOfIntegerValues(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, T* arrayOutput) const;
975932

976933
/**
977934
* Read an input array which come from EML 2.3 (and potentially HDF5) and store it into a
@@ -980,119 +937,10 @@ namespace COMMON_NS
980937
* @param [in] arrayInput If non-null, the array input.
981938
* @param [out] arrayOutput If non-null, the array output.
982939
*
983-
* @returns The null value of this array. Default returned value is uint32_t::max
984-
*/
985-
uint32_t readArrayNdOfUInt32Values(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, uint32_t * arrayOutput) const;
986-
987-
/**
988-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
989-
* preallocated output array in memory. It does not allocate or deallocate memory.
990-
*
991-
* @param [in] arrayInput If non-null, the array input.
992-
* @param [out] arrayOutput If non-null, the array output.
993-
*
994-
* @returns The null value of this array. Default returned value is uint64_t::max
995-
*/
996-
uint64_t readArrayNdOfUInt64Values(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, uint64_t * arrayOutput) const;
997-
998-
/**
999-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
1000-
* preallocated output array in memory. It does not allocate or deallocate memory.
1001-
*
1002-
* @param [in] arrayInput If non-null, the array input.
1003-
* @param [out] arrayOutput If non-null, the array output.
1004-
*
1005-
* @returns The null value of this array. Default returned value is uint64_t::max
1006-
*/
1007-
uint64_t readArrayNdOfUInt64Values(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, uint64_t * arrayOutput) const;
1008-
1009-
/**
1010-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
1011-
* preallocated output array in memory. It does not allocate or deallocate memory.
1012-
*
1013-
* @param [in] arrayInput If non-null, the array input.
1014-
* @param [out] arrayOutput If non-null, the array output.
1015-
*
1016-
* @returns The null value of this array. Default returned value is uint8_t::max
1017-
*/
1018-
int8_t readArrayNdOfInt8Values(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, int8_t * arrayOutput) const;
1019-
1020-
/**
1021-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
1022-
* preallocated output array in memory. It does not allocate or deallocate memory.
1023-
*
1024-
* @param [in] arrayInput If non-null, the array input.
1025-
* @param [out] arrayOutput If non-null, the array output.
1026-
*
1027-
* @returns The null value of this array. Default returned value is uint16_t::max
1028-
*/
1029-
int8_t readArrayNdOfInt8Values(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, int8_t * arrayOutput) const;
1030-
1031-
/**
1032-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
1033-
* preallocated output array in memory. It does not allocate or deallocate memory.
1034-
*
1035-
* @param [in] arrayInput If non-null, the array input.
1036-
* @param [out] arrayOutput If non-null, the array output.
1037-
*
1038-
* @returns The null value of this array. Default returned value is uint8_t::max
1039-
*/
1040-
int16_t readArrayNdOfInt16Values(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, int16_t * arrayOutput) const;
1041-
1042-
/**
1043-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
1044-
* preallocated output array in memory. It does not allocate or deallocate memory.
1045-
*
1046-
* @param [in] arrayInput If non-null, the array input.
1047-
* @param [out] arrayOutput If non-null, the array output.
1048-
*
1049-
* @returns The null value of this array. Default returned value is uint16_t::max
1050-
*/
1051-
int16_t readArrayNdOfInt16Values(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, int16_t * arrayOutput) const;
1052-
1053-
/**
1054-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
1055-
* preallocated output array in memory. It does not allocate or deallocate memory.
1056-
*
1057-
* @param [in] arrayInput If non-null, the array input.
1058-
* @param [out] arrayOutput If non-null, the array output.
1059-
*
1060-
* @returns The null value of this array. Default returned value is uint8_t::max
940+
* @returns The null value of this array. Default returned value is the max numeric limits of T.
1061941
*/
1062-
int32_t readArrayNdOfInt32Values(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, int32_t * arrayOutput) const;
1063-
1064-
/**
1065-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
1066-
* preallocated output array in memory. It does not allocate or deallocate memory.
1067-
*
1068-
* @param [in] arrayInput If non-null, the array input.
1069-
* @param [out] arrayOutput If non-null, the array output.
1070-
*
1071-
* @returns The null value of this array. Default returned value is uint16_t::max
1072-
*/
1073-
int32_t readArrayNdOfInt32Values(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, int32_t * arrayOutput) const;
1074-
1075-
/**
1076-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
1077-
* preallocated output array in memory. It does not allocate or deallocate memory.
1078-
*
1079-
* @param [in] arrayInput If non-null, the array input.
1080-
* @param [out] arrayOutput If non-null, the array output.
1081-
*
1082-
* @returns The null value of this array. Default returned value is uint64_t::max
1083-
*/
1084-
int64_t readArrayNdOfInt64Values(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, int64_t * arrayOutput) const;
1085-
1086-
/**
1087-
* Read an input array which come from EML 2.0 (and potentially HDF5) and store it into a
1088-
* preallocated output array in memory. It does not allocate or deallocate memory.
1089-
*
1090-
* @param [in] arrayInput If non-null, the array input.
1091-
* @param [out] arrayOutput If non-null, the array output.
1092-
*
1093-
* @returns The null value of this array. Default returned value is uint64_t::max
1094-
*/
1095-
int64_t readArrayNdOfInt64Values(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, int64_t * arrayOutput) const;
942+
template<typename T>
943+
T readArrayNdOfIntegerValues(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, T* arrayOutput) const;
1096944

1097945
/**
1098946
* Get the count of item in an array of integer
@@ -1200,4 +1048,22 @@ namespace COMMON_NS
12001048
*/
12011049
void setUuid(const std::string & uuid);
12021050
};
1051+
1052+
template<> DLL_IMPORT_OR_EXPORT int8_t AbstractObject::readArrayNdOfIntegerValues(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, int8_t* arrayOutput) const;
1053+
template<> DLL_IMPORT_OR_EXPORT uint8_t AbstractObject::readArrayNdOfIntegerValues(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, uint8_t* arrayOutput) const;
1054+
template<> DLL_IMPORT_OR_EXPORT int16_t AbstractObject::readArrayNdOfIntegerValues(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, int16_t* arrayOutput) const;
1055+
template<> DLL_IMPORT_OR_EXPORT uint16_t AbstractObject::readArrayNdOfIntegerValues(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, uint16_t* arrayOutput) const;
1056+
template<> DLL_IMPORT_OR_EXPORT int32_t AbstractObject::readArrayNdOfIntegerValues(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, int32_t* arrayOutput) const;
1057+
template<> DLL_IMPORT_OR_EXPORT uint32_t AbstractObject::readArrayNdOfIntegerValues(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, uint32_t* arrayOutput) const;
1058+
template<> DLL_IMPORT_OR_EXPORT int64_t AbstractObject::readArrayNdOfIntegerValues(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, int64_t* arrayOutput) const;
1059+
template<> DLL_IMPORT_OR_EXPORT uint64_t AbstractObject::readArrayNdOfIntegerValues(gsoap_resqml2_0_1::resqml20__AbstractValueArray const* arrayInput, uint64_t* arrayOutput) const;
1060+
1061+
template<> DLL_IMPORT_OR_EXPORT int8_t AbstractObject::readArrayNdOfIntegerValues(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, int8_t* arrayOutput) const;
1062+
template<> DLL_IMPORT_OR_EXPORT uint8_t AbstractObject::readArrayNdOfIntegerValues(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, uint8_t* arrayOutput) const;
1063+
template<> DLL_IMPORT_OR_EXPORT int16_t AbstractObject::readArrayNdOfIntegerValues(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, int16_t* arrayOutput) const;
1064+
template<> DLL_IMPORT_OR_EXPORT uint16_t AbstractObject::readArrayNdOfIntegerValues(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, uint16_t* arrayOutput) const;
1065+
template<> DLL_IMPORT_OR_EXPORT int32_t AbstractObject::readArrayNdOfIntegerValues(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, int32_t* arrayOutput) const;
1066+
template<> DLL_IMPORT_OR_EXPORT uint32_t AbstractObject::readArrayNdOfIntegerValues(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, uint32_t* arrayOutput) const;
1067+
template<> DLL_IMPORT_OR_EXPORT int64_t AbstractObject::readArrayNdOfIntegerValues(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, int64_t* arrayOutput) const;
1068+
template<> DLL_IMPORT_OR_EXPORT uint64_t AbstractObject::readArrayNdOfIntegerValues(gsoap_eml2_3::eml23__AbstractValueArray const* arrayInput, uint64_t* arrayOutput) const;
12031069
}

src/common/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set(FESAPI_COMMON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/common/AbstractObject.cpp
33
${CMAKE_CURRENT_SOURCE_DIR}/common/DataObjectRepository.cpp
44
${CMAKE_CURRENT_SOURCE_DIR}/common/EnumStringMapper.cpp
55
${CMAKE_CURRENT_SOURCE_DIR}/common/EpcDocument.cpp
6-
${CMAKE_CURRENT_SOURCE_DIR}/common/HdfProxyFactory.cpp )
6+
${CMAKE_CURRENT_SOURCE_DIR}/common/HdfProxyFactory.cpp)
77
set(FESAPI_COMMON_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/common/AbstractObject.h
88
${CMAKE_CURRENT_SOURCE_DIR}/common/DataFeeder.h
99
${CMAKE_CURRENT_SOURCE_DIR}/common/DataObjectReference.h
@@ -12,7 +12,8 @@ set(FESAPI_COMMON_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/common/AbstractObject.h
1212
${CMAKE_CURRENT_SOURCE_DIR}/common/EpcDocument.h
1313
${CMAKE_CURRENT_SOURCE_DIR}/common/HdfProxyFactory.h
1414
${CMAKE_CURRENT_SOURCE_DIR}/common/HdfProxyROS3Factory.h
15-
${CMAKE_CURRENT_SOURCE_DIR}/common/HidtType.h )
15+
${CMAKE_CURRENT_SOURCE_DIR}/common/HidtType.h
16+
${CMAKE_CURRENT_SOURCE_DIR}/common/NumberArrayStatistics.h)
1617
if (HDF5_PREFER_PARALLEL)
1718
list(APPEND FESAPI_COMMON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/common/HdfProxyMPIFactory.cpp )
1819
list(APPEND FESAPI_COMMON_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/common/HdfProxyMPIFactory.h )

0 commit comments

Comments
 (0)