Skip to content

Commit 310ffe2

Browse files
Fix some gcc warnings
1 parent 5a76e06 commit 310ffe2

4 files changed

Lines changed: 88 additions & 19 deletions

File tree

src/common/DataFeeder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ namespace COMMON_NS
2929
{
3030
public:
3131

32+
virtual ~DataFeeder() = default;
33+
3234
/**
3335
* Ask this feeder to resolve a partial object to a non partial one.
3436
*

src/resqml2_2/DiscreteProperty.cpp

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ std::string DiscreteProperty::pushBackRefToExistingIntegerDataset(EML2_NS::Abstr
6464
gsoap_eml2_3::eml23__IntegerExternalArray* xmlValues = gsoap_eml2_3::soap_new_eml23__IntegerExternalArray(gsoapProxy2_3->soap);
6565
xmlValues->NullValue = nullValue;
6666
xmlValues->Values = gsoap_eml2_3::soap_new_eml23__ExternalDataArray(gsoapProxy2_3->soap);
67+
auto* stats = gsoap_eml2_3::soap_new_eml23__IntegerArrayStatistics(gsoapProxy2_3->soap);
68+
stats->MinimumValue = gsoap_eml2_3::soap_new_LONG64(gsoapProxy2_3->soap);
69+
*stats->MinimumValue = minimumValue;
70+
stats->MaximumValue = gsoap_eml2_3::soap_new_LONG64(gsoapProxy2_3->soap);
71+
*stats->MaximumValue = maximumValue;
72+
xmlValues->Statistics.push_back(stats);
6773

6874
auto* daPart = createExternalDataArrayPart(datasetName, proxy->getElementCount(datasetName), proxy);
6975
xmlValues->Values->ExternalDataArrayPart.push_back(daPart);
@@ -87,40 +93,104 @@ int64_t DiscreteProperty::getNullValue(uint64_t patchIndex) const
8793

8894
bool DiscreteProperty::hasMinimumValue(uint64_t index) const
8995
{
90-
throw logic_error("Not implemented yet");
96+
const auto valuesforPatch = static_cast<_resqml22__DiscreteProperty*>(gsoapProxy2_3)->ValuesForPatch;
97+
if (valuesforPatch.size() != 1) return false;
98+
99+
auto const* intArray = dynamic_cast<eml23__AbstractIntegerArray*>(valuesforPatch[0]);
100+
return intArray != nullptr && intArray->Statistics.size() > index && intArray->Statistics[index]->MinimumValue != nullptr;
91101
}
92102

93103
int64_t DiscreteProperty::getMinimumValue(uint64_t index) const
94104
{
95-
throw logic_error("Not implemented yet");
105+
if (!hasMinimumValue(index)) {
106+
throw std::logic_error("This property has not minimum value at index " + std::to_string(index));
107+
}
108+
109+
return *dynamic_cast<eml23__AbstractIntegerArray*>(static_cast<_resqml22__DiscreteProperty*>(gsoapProxy2_3)->ValuesForPatch[0])->Statistics[index]->MinimumValue;
96110
}
97111

98112
bool DiscreteProperty::hasMaximumValue(uint64_t index) const
99113
{
100-
throw logic_error("Not implemented yet");
114+
const auto valuesforPatch = static_cast<_resqml22__DiscreteProperty*>(gsoapProxy2_3)->ValuesForPatch;
115+
if (valuesforPatch.size() != 1) return false;
116+
117+
auto const* intArray = dynamic_cast<eml23__AbstractIntegerArray*>(valuesforPatch[0]);
118+
return intArray != nullptr && intArray->Statistics.size() > index && intArray->Statistics[index]->MaximumValue != nullptr;
101119
}
102120

103121
int64_t DiscreteProperty::getMaximumValue(uint64_t index) const
104122
{
105-
throw logic_error("Not implemented yet");
123+
if (!hasMaximumValue(index)) {
124+
throw std::logic_error("This property has not maximum value at index " + std::to_string(index));
125+
}
126+
127+
return *dynamic_cast<eml23__AbstractIntegerArray*>(static_cast<_resqml22__DiscreteProperty*>(gsoapProxy2_3)->ValuesForPatch[0])->Statistics[index]->MaximumValue;
106128
}
107129

108130
void DiscreteProperty::setMinimumValue(int64_t value, uint64_t index) const
109131
{
110-
throw logic_error("Not implemented yet");
132+
const auto valuesforPatch = static_cast<_resqml22__DiscreteProperty*>(gsoapProxy2_3)->ValuesForPatch;
133+
if (valuesforPatch.size() != 1) throw std::logic_error("Setting minimum value on a multipatched or zero patched property is not supported yet.");
134+
135+
auto const* intArray = dynamic_cast<eml23__AbstractIntegerArray*>(valuesforPatch[0]);
136+
if (intArray == nullptr) throw std::logic_error("Setting minimum value on a non integer array for a discrete property is not supported.");
137+
138+
auto* stats = intArray->Statistics.size() <= index
139+
? gsoap_eml2_3::soap_new_eml23__IntegerArrayStatistics(gsoapProxy2_3->soap)
140+
: intArray->Statistics[index];
141+
142+
auto* minValue = stats->MinimumValue == nullptr
143+
? soap_new_LONG64(gsoapProxy2_3->soap)
144+
: stats->MinimumValue;
145+
146+
*minValue = value;
111147
}
112148

113149
void DiscreteProperty::setMaximumValue(int64_t value, uint64_t index) const
114150
{
115-
throw logic_error("Not implemented yet");
151+
const auto valuesforPatch = static_cast<_resqml22__DiscreteProperty*>(gsoapProxy2_3)->ValuesForPatch;
152+
if (valuesforPatch.size() != 1) throw std::logic_error("Setting maximum value on a multipatched or zero patched property is not supported yet.");
153+
154+
auto const* intArray = dynamic_cast<eml23__AbstractIntegerArray*>(valuesforPatch[0]);
155+
if (intArray == nullptr) throw std::logic_error("Setting maximum value on a non integer array for a discrete property is not supported.");
156+
157+
auto* stats = intArray->Statistics.size() <= index
158+
? gsoap_eml2_3::soap_new_eml23__IntegerArrayStatistics(gsoapProxy2_3->soap)
159+
: intArray->Statistics[index];
160+
161+
auto* maxValue = stats->MaximumValue == nullptr
162+
? soap_new_LONG64(gsoapProxy2_3->soap)
163+
: stats->MaximumValue;
164+
165+
*maxValue = value;
116166
}
117167

118168
size_t DiscreteProperty::getMinimumValueSize() const
119169
{
120-
throw logic_error("Not implemented yet");
170+
auto valuesforPatch = static_cast<_resqml22__DiscreteProperty*>(gsoapProxy2_3)->ValuesForPatch;
171+
if (valuesforPatch.size() != 1) return 0;
172+
173+
auto const* intArray = dynamic_cast<eml23__AbstractIntegerArray*>(valuesforPatch[0]);
174+
if (intArray == nullptr) return 0;
175+
176+
size_t result = 0;
177+
for (size_t result = 0; result < intArray->Statistics.size(); ++result) {
178+
if (intArray->Statistics[result]->MinimumValue == nullptr) return result;
179+
}
180+
return result;
121181
}
122182

123183
size_t DiscreteProperty::getMaximumValueSize() const
124184
{
125-
throw logic_error("Not implemented yet");
185+
auto valuesforPatch = static_cast<_resqml22__DiscreteProperty*>(gsoapProxy2_3)->ValuesForPatch;
186+
if (valuesforPatch.size() != 1) return 0;
187+
188+
auto const* intArray = dynamic_cast<eml23__AbstractIntegerArray*>(valuesforPatch[0]);
189+
if (intArray == nullptr) return 0;
190+
191+
size_t result = 0;
192+
for (size_t result = 0; result < intArray->Statistics.size(); ++result) {
193+
if (intArray->Statistics[result]->MaximumValue == nullptr) return result;
194+
}
195+
return result;
126196
}

src/resqml2_2/Grid2dRepresentation.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,20 +397,20 @@ void Grid2dRepresentation::getJSpacing(double* const jSpacings) const
397397
}
398398
else if (!getSupportingRepresentationDor().isEmpty())
399399
{
400-
const uint64_t jIndexOrigin = getIndexOriginOnSupportingRepresentation(0);
401-
const uint64_t jIndexOffset = getIndexOffsetOnSupportingRepresentation(0);
400+
const int jIndexOrigin = getIndexOriginOnSupportingRepresentation(0);
401+
const int64_t jIndexOffset = getIndexOffsetOnSupportingRepresentation(0);
402402
std::unique_ptr<double[]> jSpacingsOnSupportingRep(new double[jSpacingCount]);
403403
getSupportingRepresentation()->getJSpacing(jSpacingsOnSupportingRep.get());
404404

405405
for (uint64_t j = 0; j < jSpacingCount; ++j) {
406406
jSpacings[j] = .0;
407407
if (jIndexOffset > 0) {
408-
for (int tmp = 0; tmp < jIndexOffset; ++tmp) {
408+
for (int64_t tmp = 0; tmp < jIndexOffset; ++tmp) {
409409
jSpacings[j] += jSpacingsOnSupportingRep[jIndexOrigin + j * jIndexOffset + tmp];
410410
}
411411
}
412412
else if (jIndexOffset < 0) {
413-
for (int tmp = 0; tmp > jIndexOffset; --tmp) {
413+
for (int64_t tmp = 0; tmp > jIndexOffset; --tmp) {
414414
jSpacings[j] += jSpacingsOnSupportingRep[jIndexOrigin - 1 + j * jIndexOffset + tmp];
415415
}
416416
}
@@ -452,20 +452,20 @@ void Grid2dRepresentation::getISpacing(double* iSpacings) const
452452
}
453453
else if (!getSupportingRepresentationDor().isEmpty())
454454
{
455-
const uint64_t iIndexOrigin = getIndexOriginOnSupportingRepresentation(1);
456-
const uint64_t iIndexOffset = getIndexOffsetOnSupportingRepresentation(1);
455+
const int iIndexOrigin = getIndexOriginOnSupportingRepresentation(1);
456+
const int64_t iIndexOffset = getIndexOffsetOnSupportingRepresentation(1);
457457
std::unique_ptr<double[]> iSpacingsOnSupportingRep(new double[iSpacingCount]);
458458
getSupportingRepresentation()->getISpacing(iSpacingsOnSupportingRep.get());
459459

460460
for (uint64_t i = 0; i < iSpacingCount; ++i) {
461461
iSpacings[i] = .0;
462462
if (iIndexOffset > 0) {
463-
for (int tmp = 0; tmp < iIndexOffset; ++tmp) {
463+
for (int64_t tmp = 0; tmp < iIndexOffset; ++tmp) {
464464
iSpacings[i] += iSpacingsOnSupportingRep[iIndexOrigin + i * iIndexOffset + tmp];
465465
}
466466
}
467467
else if (iIndexOffset < 0) {
468-
for (int tmp = 0; tmp > iIndexOffset; --tmp) {
468+
for (int64_t tmp = 0; tmp > iIndexOffset; --tmp) {
469469
iSpacings[i] += iSpacingsOnSupportingRep[iIndexOrigin - 1 + i * iIndexOffset + tmp];
470470
}
471471
}

src/resqml2_2/GridConnectionSetRepresentation.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,6 @@ uint64_t GridConnectionSetRepresentation::getCellIndexPairCountFromInterpretatio
221221
auto const* daPart = static_cast<eml23__IntegerExternalArray*>(rep->ConnectionInterpretations->InterpretationIndices->Elements)->Values->ExternalDataArrayPart[0];
222222
auto hdfProxy = getOrCreateHdfProxyFromDataArrayPart(daPart);
223223
const uint64_t faultIndexCount = getOrCreateHdfProxyFromDataArrayPart(daPart)->getElementCount(daPart->PathInExternalFile);
224-
if (faultIndexCount < 0) {
225-
throw invalid_argument("The HDF5 library could not read the element count of this dataset.");
226-
}
227224
std::unique_ptr<int64_t[]> faultIndices(new int64_t[faultIndexCount]);
228225

229226
hdfProxy->readArrayNdOfInt64Values(daPart->PathInExternalFile, faultIndices.get());

0 commit comments

Comments
 (0)