Fesapi  2.0.0.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
ChannelIndexDataObject.h
1 /*-----------------------------------------------------------------------
2 Licensed to the Apache Software Foundation (ASF) under one
3 or more contributor license agreements. See the NOTICE file
4 distributed with this work for additional information
5 regarding copyright ownership. The ASF licenses this file
6 to you under the Apache License, Version 2.0 (the
7 "License"; you may not use this file except in compliance
8 with the License. You may obtain a copy of the License at
9 
10 http://www.apache.org/licenses/LICENSE-2.0
11 
12 Unless required by applicable law or agreed to in writing,
13 software distributed under the License is distributed on an
14 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 KIND, either express or implied. See the License for the
16 specific language governing permissions and limitations
17 under the License.
18 -----------------------------------------------------------------------*/
19 #pragma once
20 
21 #include "ChannelMetaDataObject.h"
22 
23 #include <limits>
24 
25 namespace WITSML2_0_NS
26 {
34  template <class T>
36  {
37  public:
38 
46  DLL_IMPORT_OR_EXPORT ChannelIndexDataObject(gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject) : ChannelMetaDataObject<T>(partialObject) {}
47 
50 
56  ChannelIndexDataObject(gsoap_eml2_1::eml21__AbstractObject* fromGsoap) : ChannelMetaDataObject<T>(fromGsoap) {}
57 
59  virtual ~ChannelIndexDataObject() = default;
60 
70  DLL_IMPORT_OR_EXPORT virtual void pushBackChannelIndex(gsoap_eml2_1::witsml20__ChannelIndexType indexType, gsoap_eml2_1::eml21__UnitOfMeasure uom, const std::string & mnemonic, bool isIncreasing = true, const std::string & datum = "") = 0;
71 
77  unsigned int getChannelIndexCount() const {
78  const size_t result = static_cast<T*>(this->gsoapProxy2_1)->Index.size();
79  if (result > (std::numeric_limits<unsigned int>::max)()) {
80  throw std::range_error("There are too much channel index.");
81  }
82 
83  return static_cast<unsigned int>(result);
84  }
85 
95  gsoap_eml2_1::witsml20__ChannelIndexType getChannelIndexType(unsigned int index) {
96  if (index >= getChannelIndexCount()) {
97  throw std::out_of_range("The channel index is out of range");
98  }
99  return static_cast<T*>(this->gsoapProxy2_1)->Index[index]->IndexType;
100  }
101 
111  std::string getChannelIndexUom(unsigned int index) {
112  if (index >= getChannelIndexCount()) {
113  throw std::out_of_range("The channel index is out of range");
114  }
115  return static_cast<T*>(this->gsoapProxy2_1)->Index[index]->Uom;
116  }
117 
127  bool getChannelIndexIsIncreasing(unsigned int index) {
128  if (index >= getChannelIndexCount()) {
129  throw std::out_of_range("The channel index is out of range");
130  }
131  return static_cast<T*>(this->gsoapProxy2_1)->Index[index]->Direction == gsoap_eml2_1::witsml20__IndexDirection__increasing;
132  }
133 
143  std::string getChannelIndexMnemonic(unsigned int index) {
144  if (index >= getChannelIndexCount()) {
145  throw std::out_of_range("The channel index is out of range");
146  }
147  return static_cast<T*>(this->gsoapProxy2_1)->Index[index]->Mnemonic;
148  }
149 
159  std::string getChannelIndexDatum(unsigned int index) {
160  if (index >= getChannelIndexCount()) {
161  throw std::out_of_range("The channel index is out of range");
162  }
163  return static_cast<T*>(this->gsoapProxy2_1)->Index[index]->DatumReference == nullptr ? "" : *static_cast<T*>(this->gsoapProxy2_1)->Index[index]->DatumReference;
164  }
165  };
166 }
Definition: ChannelIndexDataObject.h:36
unsigned int getChannelIndexCount() const
Definition: ChannelIndexDataObject.h:77
virtual void pushBackChannelIndex(gsoap_eml2_1::witsml20__ChannelIndexType indexType, gsoap_eml2_1::eml21__UnitOfMeasure uom, const std::string &mnemonic, bool isIncreasing=true, const std::string &datum="")=0
ChannelIndexDataObject(gsoap_resqml2_0_1::eml20__DataObjectReference *partialObject)
Definition: ChannelIndexDataObject.h:46
ChannelIndexDataObject(gsoap_eml2_1::eml21__AbstractObject *fromGsoap)
Definition: ChannelIndexDataObject.h:56
bool getChannelIndexIsIncreasing(unsigned int index)
Definition: ChannelIndexDataObject.h:127
virtual ~ChannelIndexDataObject()=default
gsoap_eml2_1::witsml20__ChannelIndexType getChannelIndexType(unsigned int index)
Definition: ChannelIndexDataObject.h:95
std::string getChannelIndexMnemonic(unsigned int index)
Definition: ChannelIndexDataObject.h:143
ChannelIndexDataObject()
Definition: ChannelIndexDataObject.h:49
std::string getChannelIndexDatum(unsigned int index)
Definition: ChannelIndexDataObject.h:159
std::string getChannelIndexUom(unsigned int index)
Definition: ChannelIndexDataObject.h:111
Definition: ChannelMetaDataObject.h:38