Skip to content

Commit 48f1cea

Browse files
gsoap generate eml23__PositiveLongand eml23__NonNegativeLong as uint64_t
Also fix some conversion warnings Support for multirealization indices of RESQML2.2 property
1 parent f68f216 commit 48f1cea

39 files changed

Lines changed: 1713 additions & 1636 deletions

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ set (FESAPI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
1212

1313
# version mechanism
1414
set (Fesapi_VERSION_MAJOR 2)
15-
set (Fesapi_VERSION_MINOR 14)
16-
set (Fesapi_VERSION_PATCH 1)
15+
set (Fesapi_VERSION_MINOR 15)
16+
set (Fesapi_VERSION_PATCH 0)
1717
set (Fesapi_VERSION_TWEAK 0)
1818

1919
set (Fesapi_VERSION ${Fesapi_VERSION_MAJOR}.${Fesapi_VERSION_MINOR}.${Fesapi_VERSION_PATCH}.${Fesapi_VERSION_TWEAK})

src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ list(APPEND ALL_SOURCES_AND_HEADERS
191191
)
192192

193193
target_sources(${CPP_LIBRARY_NAME} PRIVATE ${ALL_SOURCES_AND_HEADERS})
194+
# Disable warnings on gsoap which we do not control
195+
if (WIN32)
196+
set_source_files_properties(${FESAPI_PROXIES_SOURCES} PROPERTIES COMPILE_OPTIONS "/W0")
197+
else()
198+
set_source_files_properties(${FESAPI_PROXIES_SOURCES} PROPERTIES COMPILE_OPTIONS "-w")
199+
endif()
194200

195201
target_include_directories(${CPP_LIBRARY_NAME} SYSTEM PRIVATE ${MINIZIP_INCLUDE_DIR})
196202

src/common/AbstractObject.cpp

Lines changed: 45 additions & 36 deletions
Large diffs are not rendered by default.

src/common/AbstractObject.h

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ namespace COMMON_NS
411411
*
412412
* @returns The gSOAP type.
413413
*/
414-
int getGsoapType() const;
414+
long getGsoapType() const;
415415

416416
/**
417417
* Creates an returns an EML2.0 data object reference which targets this data object
@@ -831,11 +831,13 @@ namespace COMMON_NS
831831
throw std::underflow_error("Cannot deal with negative values when using unsigned integer");
832832
}
833833
}
834-
if (rangeArray->Value + rangeArray->Count > static_cast<uint64_t>((std::numeric_limits<T>::max)())) {
835-
throw std::overflow_error("The range integer values are superior to maximum value of read datatype.");
834+
if (rangeArray->Count > static_cast<uint64_t>((std::numeric_limits<T>::max)())) {
835+
throw std::overflow_error("Please use a larger integer type");
836836
}
837-
for (T i = 0; i < static_cast<T>(rangeArray->Count); ++i) {
838-
arrayOutput[i] = i + static_cast<T>(rangeArray->Value);
837+
const T initialValue = static_cast<T>(rangeArray->Value);
838+
const T count = static_cast<T>(rangeArray->Count);
839+
for (T i = 0; i < count; ++i) {
840+
arrayOutput[i] = i + initialValue;
839841
}
840842
return (std::numeric_limits<T>::max)();
841843
}
@@ -871,22 +873,27 @@ namespace COMMON_NS
871873
if (latticeArray->StartValue < (std::numeric_limits<T>::min)() || latticeArray->Offset[0]->Value < (std::numeric_limits<T>::min)()) {
872874
throw std::underflow_error("Too low integers in XML for the C++ chosen datatype");
873875
}
874-
if (latticeArray->StartValue > (std::numeric_limits<T>::max)() ||
875-
latticeArray->Offset[0]->Value > (std::numeric_limits<T>::max)()) {
876+
if (latticeArray->StartValue > static_cast<int64_t>((std::numeric_limits<T>::max)()) ||
877+
latticeArray->Offset[0]->Value > static_cast<int64_t>((std::numeric_limits<T>::max)()) ||
878+
latticeArray->Offset[0]->Count > static_cast<uint64_t>((std::numeric_limits<T>::max)())) {
876879
throw std::overflow_error("Too big integers in XML for the C++ chosen datatype");
877880
}
878881
}
879882
else {
880883
if (latticeArray->StartValue < 0 || latticeArray->Offset[0]->Value < 0) {
881884
throw std::underflow_error("Cannot deal with negative values when using unsigned integer");
882885
}
883-
if (static_cast<uint64_t>(latticeArray->StartValue) > (std::numeric_limits<T>::max)() ||
884-
static_cast<uint64_t>(latticeArray->Offset[0]->Value) > (std::numeric_limits<T>::max)()) {
886+
if (static_cast<uint64_t>(latticeArray->StartValue) > static_cast<uint64_t>((std::numeric_limits<T>::max)()) ||
887+
static_cast<uint64_t>(latticeArray->Offset[0]->Value) > static_cast<uint64_t>((std::numeric_limits<T>::max)()) ||
888+
latticeArray->Offset[0]->Count > static_cast<uint64_t>((std::numeric_limits<T>::max)())) {
885889
throw std::overflow_error("Too big integers in XML for the C++ chosen datatype");
886890
}
887891
}
888-
for (uint64_t i = 0; i <= latticeArray->Offset[0]->Count; ++i) {
889-
arrayOutput[i] = static_cast<T>(latticeArray->StartValue) + (i * static_cast<T>(latticeArray->Offset[0]->Value));
892+
const T start = static_cast<T>(latticeArray->StartValue);
893+
const T step = static_cast<T>(latticeArray->Offset[0]->Value);
894+
const T count = static_cast<T>(latticeArray->Offset[0]->Count);
895+
for (T i = 0; i <= count; ++i) {
896+
arrayOutput[i] = static_cast<T>(start + i * step);
890897
}
891898
return (std::numeric_limits<T>::max)();
892899
}
@@ -932,12 +939,12 @@ namespace COMMON_NS
932939
if (latticeArray->Offset.empty() || latticeArray->Offset.size() > 1) {
933940
throw std::invalid_argument("The integer lattice array of UUID " + getUuid() + " contains zero or more than one offset.");
934941
}
935-
if (latticeArray->Offset[0]->Count < 0) {
936-
throw std::invalid_argument("The count of the integer lattice array of UUID " + getUuid() + " is negative which is not valid.");
937-
}
938942

939-
for (size_t i = 0; i <= static_cast<size_t>(latticeArray->Offset[0]->Count); ++i) {
940-
arrayOutput[i] = latticeArray->StartValue + (i * latticeArray->Offset[0]->Value);
943+
const T start = static_cast<T>(latticeArray->StartValue);
944+
const T step = static_cast<T>(latticeArray->Offset[0]->Value);
945+
const T count = static_cast<T>(latticeArray->Offset[0]->Count);
946+
for (T i = 0; i <= count; ++i) {
947+
arrayOutput[i] = static_cast<T>(start + i * step);
941948
}
942949
return (std::numeric_limits<T>::max)();
943950
}
@@ -949,7 +956,7 @@ namespace COMMON_NS
949956
std::sregex_token_iterator endToken;
950957
size_t index = 0;
951958
while (it != endToken) {
952-
arrayOutput[index++] = std::stoll(*it++);
959+
arrayOutput[index++] = static_cast<T>(std::stoll(*it++));
953960
}
954961
return (std::numeric_limits<T>::max)();
955962
}
@@ -1076,7 +1083,7 @@ namespace COMMON_NS
10761083
/**
10771084
* Create an external data array part pointing to a named dataset in an HDF proxy
10781085
*/
1079-
gsoap_eml2_3::eml23__ExternalDataArrayPart* createExternalDataArrayPart(const std::string& datasetName, LONG64 count, EML2_NS::AbstractHdfProxy* proxy = nullptr) const;
1086+
gsoap_eml2_3::eml23__ExternalDataArrayPart* createExternalDataArrayPart(const std::string& datasetName, uint64_t count, EML2_NS::AbstractHdfProxy* proxy = nullptr) const;
10801087

10811088
gsoap_resqml2_0_1::resqml20__IndexableElements mapIndexableElement(gsoap_eml2_3::eml23__IndexableElement toMap) const;
10821089

src/common/DataObjectRepository.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ RESQML2_NS::SeismicLatticeFeature* DataObjectRepository::createSeismicLattice(co
14761476
}
14771477

14781478
RESQML2_0_1_NS::SeismicLineFeature* DataObjectRepository::createSeismicLine(const std::string & guid, const std::string & title,
1479-
int traceIndexIncrement, unsigned int firstTraceIndex, unsigned int traceCount)
1479+
int traceIndexIncrement, int firstTraceIndex, unsigned int traceCount)
14801480
{
14811481
return new RESQML2_0_1_NS::SeismicLineFeature(this, guid, title, traceIndexIncrement, firstTraceIndex, traceCount);
14821482
}

src/common/DataObjectRepository.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,14 +1246,17 @@ namespace COMMON_NS
12461246
* will be generated.
12471247
* @param title The title to set to the seismic line. If empty then \"unknown\"
12481248
* title will be set.
1249-
* @param traceIndexIncrement The constant index increment between two consecutive traces.
1250-
* @param firstTraceIndex The index of the first trace of the seismic line.
1251-
* @param traceCount Number of traces.
1249+
* @param traceIndexIncrement The trace index increment. The trace index increment will
1250+
* be the difference in the trace number from abscissa i=0
1251+
* and abscissa i=1. The increment can be a positive or
1252+
* negative integer, but not zero.
1253+
* @param firstTraceIndex The index of the first trace beginning at abscissa i=0.
1254+
* @param traceCount The count of traces in this seismic line.
12521255
*
12531256
* @returns A pointer to the new seismic line.
12541257
*/
12551258
DLL_IMPORT_OR_EXPORT RESQML2_0_1_NS::SeismicLineFeature* createSeismicLine(const std::string & guid, const std::string & title,
1256-
int traceIndexIncrement, unsigned int firstTraceIndex, unsigned int traceCount);
1259+
int traceIndexIncrement, int firstTraceIndex, unsigned int traceCount);
12571260

12581261
/**
12591262
* @brief Creates a CMP line into this repository

src/common/NumberArrayStatistics.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,20 @@ namespace COMMON_NS
129129
}
130130

131131
//mean
132-
valuesMean[j] += (pair.second * pair.first) / validValueCount[j];
132+
valuesMean[j] += (static_cast<double>(pair.second) * static_cast<double>(pair.first)) / static_cast<double>(validValueCount[j]);
133+
133134
}
134-
valuesMedian[j] = (validValueCount[j] % 2 == 0) ? (median1 + median2) / 2.0 : median2;
135-
modePercentage[j] = static_cast<double>(maxCount) / validValueCount[j];
135+
valuesMedian[j] = (validValueCount[j] % 2 == 0) ? (static_cast<double>(median1) + static_cast<double>(median2)) / 2.0 : static_cast<double>(median2);
136+
modePercentage[j] = static_cast<double>(maxCount) / static_cast<double>(validValueCount[j]);
136137

137138

138139
// Standard Deviation
139140
double variance = 0.0;
140141
for (const auto& pair : mapView) {
141142
double diff = static_cast<double>(pair.first) - valuesMean[j];
142-
variance += pair.second * diff * diff;
143+
variance += static_cast<double>(pair.second) * diff * diff;
143144
}
144-
valuesStandardDeviation[j] = std::sqrt(variance / validValueCount[j]);
145+
valuesStandardDeviation[j] = std::sqrt(variance / static_cast<double>(validValueCount[j]));
145146
}
146147
}
147148

src/eml2/AbstractHdfProxy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ void AbstractHdfProxy::initGsoapProxy(COMMON_NS::DataObjectRepository * repo, co
3838
uint64_t AbstractHdfProxy::getElementCount(const std::string & datasetName)
3939
{
4040
auto elementCountPerDim = getElementCountPerDimension(datasetName);
41-
return std::accumulate(elementCountPerDim.begin(), elementCountPerDim.end(), 1, std::multiplies<decltype(elementCountPerDim)::value_type>());
41+
return std::accumulate(elementCountPerDim.begin(), elementCountPerDim.end(), 1u, std::multiplies<decltype(elementCountPerDim)::value_type>());
4242
}

src/eml2/AbstractHdfProxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ namespace EML2_NS
151151
/**
152152
* Get the number of elements in each dimension of an HDF5 dataset.
153153
* uint32_t is returned instead of uint64_t cause of some SWIG usage. I cannot SWIG port std::vector<uint64_t>
154+
* EDIT : now std::vector<uint64_t> is ported by means of SWIG but such a change woudl have impact on FETPAPI as well...
154155
* @param datasetName The absolute name of the dataset which we want to get the number of elements from.
155156
*/
156157
DLL_IMPORT_OR_EXPORT virtual std::vector<uint32_t> getElementCountPerDimension(const std::string & datasetName) = 0;

src/eml2/HdfProxy.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -448,37 +448,45 @@ void HdfProxy::readArrayNdOfValues(
448448
if (!isOpened()) {
449449
open();
450450
}
451+
std::string datasetName;
451452

452453
hsize_t hdfSlabSize = slabSize;
453454
hid_t memspace = H5Screate_simple(1, &hdfSlabSize, nullptr);
454455
if (memspace < 0) {
455456
ssize_t size = 1 + H5Iget_name(dataset, NULL, 0);
456-
char * name = (char *)malloc(size);
457-
size = H5Iget_name(dataset, name, size);
458-
std::string datasetName(name);
457+
if (size < 0) {
458+
H5Sclose(filespace);
459+
H5Dclose(dataset);
460+
throw invalid_argument("The name of the dataset cannot be found since its length is negative.");
461+
}
462+
char * name = (char *)malloc(static_cast<size_t>(size));
463+
size = H5Iget_name(dataset, name, static_cast<size_t>(size));
464+
datasetName = std::string(name);
459465
free(name);
460466
H5Sclose(filespace);
461467
H5Dclose(dataset);
462468
throw invalid_argument("The memory space for the slabbing of HDF5 dataset " + datasetName + " could not be created.");
463469
}
464470

465471
hid_t readingError = H5Dread(dataset, datatype, memspace, filespace, H5P_DEFAULT, values);
466-
std::string datasetName;
472+
H5Sclose(memspace);
473+
H5Sclose(filespace);
474+
467475
if (readingError < 0) {
468476
ssize_t size = 1 + H5Iget_name(dataset, NULL, 0);
469-
char * name = (char *)malloc(size);
470-
size = H5Iget_name(dataset, name, size);
477+
if (size < 0) {
478+
H5Dclose(dataset);
479+
throw invalid_argument("The name of the dataset cannot be found since its length is negative.");
480+
}
481+
char * name = (char *)malloc(static_cast<size_t>(size));
482+
size = H5Iget_name(dataset, name, static_cast<size_t>(size));
471483
datasetName = std::string(name);
472484
free(name);
485+
H5Dclose(dataset);
486+
throw invalid_argument("The HDF5 dataset " + datasetName + " could not be read.");
473487
}
474488

475-
H5Sclose(memspace);
476-
H5Sclose(filespace);
477489
H5Dclose(dataset);
478-
479-
if (readingError < 0) {
480-
throw invalid_argument("The HDF5 dataset " + datasetName + " could not be read.");
481-
}
482490
}
483491

484492
COMMON_NS::AbstractObject::numericalDatatypeEnum HdfProxy::getNumericalDatatype(const std::string & datasetName)

0 commit comments

Comments
 (0)