@@ -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
8894bool 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
93103int64_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
98112bool 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
103121int64_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
108130void 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
113149void 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
118168size_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
123183size_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}
0 commit comments