Fesapi 2.14.0.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
Loading...
Searching...
No Matches
DiscreteProperty.h
1/*-----------------------------------------------------------------------
2Licensed to the Apache Software Foundation (ASF) under one
3or more contributor license agreements. See the NOTICE file
4distributed with this work for additional information
5regarding copyright ownership. The ASF licenses this file
6to you under the Apache License, Version 2.0 (the
7"License"; you may not use this file except in compliance
8with the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12Unless required by applicable law or agreed to in writing,
13software distributed under the License is distributed on an
14"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15KIND, either express or implied. See the License for the
16specific language governing permissions and limitations
17under the License.
18-----------------------------------------------------------------------*/
19#pragma once
20
21#include "../resqml2/DiscreteProperty.h"
22
23namespace RESQML2_0_1_NS
24{
30 class DiscreteProperty final : public RESQML2_NS::DiscreteProperty
31 {
32 public:
33
39 DLL_IMPORT_OR_EXPORT DiscreteProperty(gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject) : RESQML2_NS::DiscreteProperty(partialObject) {}
40
60 DiscreteProperty(RESQML2_NS::AbstractRepresentation* rep, const std::string& guid, const std::string& title,
61 unsigned int dimension, gsoap_eml2_3::eml23__IndexableElement attachmentKind, gsoap_resqml2_0_1::resqml20__ResqmlPropertyKind energisticsPropertyKind);
62
81 DiscreteProperty(RESQML2_NS::AbstractRepresentation* rep, const std::string& guid, const std::string& title,
82 unsigned int dimension, gsoap_eml2_3::eml23__IndexableElement attachmentKind, EML2_NS::PropertyKind* localPropKind);
83
89 DiscreteProperty(gsoap_resqml2_0_1::_resqml20__DiscreteProperty* fromGsoap): RESQML2_NS::DiscreteProperty(fromGsoap) {}
90
92 ~DiscreteProperty() = default;
93
94 DLL_IMPORT_OR_EXPORT std::string pushBackRefToExistingIntegerDataset(EML2_NS::AbstractHdfProxy* proxy, const std::string & datasetName, int64_t nullValue, int64_t minimumValue, int64_t maximumValue) final;
95 using AbstractValuesProperty::pushBackRefToExistingIntegerDataset;
96
97 bool validatePropertyKindAssociation(EML2_NS::PropertyKind* pk) final;
98
99 bool validatePropertyKindAssociation(gsoap_resqml2_0_1::resqml20__ResqmlPropertyKind pk) final;
100
101 DLL_IMPORT_OR_EXPORT int64_t getNullValue(uint64_t patchIndex = (std::numeric_limits<uint64_t>::max)()) const final;
102
103 DLL_IMPORT_OR_EXPORT bool hasMinimumValue(uint64_t index = 0) const final;
104
105 DLL_IMPORT_OR_EXPORT int64_t getMinimumValue(uint64_t index = 0) const final;
106
107 DLL_IMPORT_OR_EXPORT bool hasMaximumValue(uint64_t index = 0) const final;
108
109 DLL_IMPORT_OR_EXPORT int64_t getMaximumValue(uint64_t index = 0) const final;
110
111 DLL_IMPORT_OR_EXPORT void setMinimumValue(int64_t value, uint64_t index = 0) const final;
112
113 DLL_IMPORT_OR_EXPORT void setMaximumValue(int64_t value, uint64_t index = 0) const;
114
123 DLL_IMPORT_OR_EXPORT gsoap_resqml2_0_1::resqml20__ResqmlPropertyKind getEnergisticsPropertyKind() const;
124
125 DLL_IMPORT_OR_EXPORT COMMON_NS::NumberArrayStatistics<int8_t> getInt8Statistics(uint64_t patchIndex) const final { return getStats(static_cast<int8_t>(getNullValueOfPatch(patchIndex))); }
126 DLL_IMPORT_OR_EXPORT COMMON_NS::NumberArrayStatistics<uint8_t> getUInt8Statistics(uint64_t patchIndex) const final { return getStats(static_cast<uint8_t>(getNullValueOfPatch(patchIndex))); }
127 DLL_IMPORT_OR_EXPORT COMMON_NS::NumberArrayStatistics<int16_t> getInt16Statistics(uint64_t patchIndex) const final { return getStats(static_cast<int16_t>(getNullValueOfPatch(patchIndex))); }
128 DLL_IMPORT_OR_EXPORT COMMON_NS::NumberArrayStatistics<uint16_t> getUInt16Statistics(uint64_t patchIndex) const final { return getStats(static_cast<uint16_t>(getNullValueOfPatch(patchIndex))); }
129 DLL_IMPORT_OR_EXPORT COMMON_NS::NumberArrayStatistics<int32_t> getInt32Statistics(uint64_t patchIndex) const final { return getStats(static_cast<int32_t>(getNullValueOfPatch(patchIndex))); }
130 DLL_IMPORT_OR_EXPORT COMMON_NS::NumberArrayStatistics<uint32_t> getUInt32Statistics(uint64_t patchIndex) const final { return getStats(static_cast<uint32_t>(getNullValueOfPatch(patchIndex))); }
131 DLL_IMPORT_OR_EXPORT COMMON_NS::NumberArrayStatistics<int64_t> getInt64Statistics(uint64_t patchIndex) const final { return getStats(getNullValueOfPatch(patchIndex)); }
132 DLL_IMPORT_OR_EXPORT COMMON_NS::NumberArrayStatistics<uint64_t> getUInt64Statistics(uint64_t patchIndex) const final { return getStats(static_cast<uint64_t>(getNullValueOfPatch(patchIndex))); }
133
137 DLL_IMPORT_OR_EXPORT static const char* XML_NS;
138
142 DLL_IMPORT_OR_EXPORT std::string getXmlNamespace() const final{ return XML_NS; }
143
144 private:
145
146 size_t getMinimumValueSize() const;
147 size_t getMaximumValueSize() const;
148
149 template<typename T>
150 COMMON_NS::NumberArrayStatistics<T> getStats(T nullValue) const {
151 COMMON_NS::NumberArrayStatistics<T> result;
152 result.setNullValue(nullValue);
153
154 const auto minimumValueSize = getMinimumValueSize();
155 for (size_t i = 0; i < minimumValueSize; ++i) {
156 if (hasMinimumValue(i)) {
157 int64_t minVal = getMinimumValue(i);
158 if constexpr (std::is_signed_v<T>) {
159 if (minVal > (std::numeric_limits<T>::min)() &&
160 minVal < (std::numeric_limits<T>::max)()) {
161 result.setMinimum(static_cast<T>(minVal), i);
162 }
163 }
164 else {
165 if (minVal > 0 &&
166 static_cast<uint64_t>(minVal) < (std::numeric_limits<T>::max)()) {
167 result.setMinimum(static_cast<T>(minVal), i);
168 }
169 }
170 }
171 }
172 const auto maximumValueSize = getMaximumValueSize();
173 for (size_t i = 0; i < maximumValueSize; ++i) {
174 if (hasMaximumValue(i)) {
175 int64_t maxVal = getMaximumValue(i);
176 if constexpr (std::is_signed_v<T>) {
177 if (maxVal > (std::numeric_limits<T>::min)() &&
178 maxVal < (std::numeric_limits<T>::max)()) {
179 result.setMaximum(static_cast<T>(maxVal), i);
180 }
181 }
182 else {
183 if (maxVal > 0 &&
184 static_cast<uint64_t>(maxVal) < (std::numeric_limits<T>::max)()) {
185 result.setMaximum(static_cast<T>(maxVal), i);
186 }
187 }
188 }
189 }
190
191 return result;
192 }
193 };
194}
int64_t getNullValueOfPatch(uint64_t patchIndex) const
DiscreteProperty(gsoap_resqml2_0_1::_resqml20__DiscreteProperty *fromGsoap)
Definition DiscreteProperty.h:89
DiscreteProperty(resqml2::AbstractRepresentation *rep, const std::string &guid, const std::string &title, unsigned int dimension, gsoap_eml2_3::eml23__IndexableElement attachmentKind, gsoap_resqml2_0_1::resqml20__ResqmlPropertyKind energisticsPropertyKind)
int64_t getNullValue(uint64_t patchIndex=(std::numeric_limits< uint64_t >::max)()) const final
Gets the null value in this discrete property.
int64_t getMaximumValue(uint64_t index=0) const final
Gets the maximum value of a non vector property or the maximum value of one given value of a vector p...
static const char * XML_NS
Definition DiscreteProperty.h:137
DiscreteProperty(gsoap_resqml2_0_1::eml20__DataObjectReference *partialObject)
Definition DiscreteProperty.h:39
bool validatePropertyKindAssociation(gsoap_resqml2_0_1::resqml20__ResqmlPropertyKind pk) final
std::string pushBackRefToExistingIntegerDataset(eml2::AbstractHdfProxy *proxy, const std::string &datasetName, int64_t nullValue, int64_t minimumValue, int64_t maximumValue) final
DiscreteProperty(resqml2::AbstractRepresentation *rep, const std::string &guid, const std::string &title, unsigned int dimension, gsoap_eml2_3::eml23__IndexableElement attachmentKind, eml2::PropertyKind *localPropKind)
void setMaximumValue(int64_t value, uint64_t index=0) const
Sets the maximum value of a non vector property or the maximum value of one given value of a vector p...
int64_t getMinimumValue(uint64_t index=0) const final
Gets the minimum value of a non vector property or the minimum value of one given value of a vector p...
bool hasMaximumValue(uint64_t index=0) const final
Checks if a non vector property or a given value of a vector property has got a maximum value already...
void setMinimumValue(int64_t value, uint64_t index=0) const final
Sets the minimum value of a non vector property or the minimum value of one given value of a vector p...
bool validatePropertyKindAssociation(eml2::PropertyKind *pk) final
gsoap_resqml2_0_1::resqml20__ResqmlPropertyKind getEnergisticsPropertyKind() const
bool hasMinimumValue(uint64_t index=0) const final
Checks if a non vector property or a given value of a vector property has got a minimum value already...
std::string getXmlNamespace() const final
Definition DiscreteProperty.h:142