Fesapi  2.0.0.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
ChannelMetaDataObject.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 "WellboreObject.h"
22 
23 #include <stdexcept>
24 
25 #include "../eml2/PropertyKind.h"
26 
27 namespace WITSML2_0_NS
28 {
36  template <class T>
38  {
39  public:
40 
48  DLL_IMPORT_OR_EXPORT ChannelMetaDataObject(gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject) : WellboreObject(partialObject) {}
49 
51  ChannelMetaDataObject() : WITSML2_0_NS::WellboreObject() {}
52 
58  ChannelMetaDataObject(gsoap_eml2_1::eml21__AbstractObject* fromGsoap) : WITSML2_0_NS::WellboreObject(fromGsoap) {}
59 
61  virtual ~ChannelMetaDataObject() = default;
62 
68  COMMON_NS::DataObjectReference getWellboreDor() const
69  {
70  return COMMON_NS::DataObjectReference(static_cast<T*>(gsoapProxy2_1)->Wellbore);
71  }
72 
80  DLL_IMPORT_OR_EXPORT void setWellbore(Wellbore* witsmlWellbore)
81  {
82  if (witsmlWellbore == nullptr) {
83  throw std::invalid_argument("Cannot set a null witsml wellbore to a witsml trajectory");
84  }
85  if (getRepository() == nullptr) {
86  witsmlWellbore->getRepository()->addOrReplaceDataObject(this);
87  }
88 
89  static_cast<T*>(gsoapProxy2_1)->Wellbore = witsmlWellbore->newEmlReference();
90 
91  getRepository()->addRelationship(this, witsmlWellbore);
92  }
93 
97  COMMON_NS::DataObjectReference getPropertyKindDor() const
98  {
99  return COMMON_NS::DataObjectReference(static_cast<T*>(gsoapProxy2_1)->ChannelClass);
100  }
101 
107  EML2_NS::PropertyKind* getPropertyKind() const
108  {
109  return getRepository()->template getDataObjectByUuid<EML2_NS::PropertyKind>(getPropertyKindDor().getUuid());
110  }
111 
119  void setPropertyKind(EML2_NS::PropertyKind* propKind)
120  {
121  if (propKind == nullptr) {
122  throw std::invalid_argument("Cannot set a null witsml propKind to a witsml log/channelset/channel");
123  }
124  if (getRepository() == nullptr) {
125  propKind->getRepository()->addOrReplaceDataObject(this);
126  }
127 
128  static_cast<T*>(gsoapProxy2_1)->ChannelClass = propKind->newEmlReference();
129 
130  getRepository()->addRelationship(this, propKind);
131  }
132 
140 #define GETTER_AND_SETTER_GENERIC_OPTIONAL_ATTRIBUTE_TEMPLATE(attributeDatatype, attributeName, constructor)\
141  DLL_IMPORT_OR_EXPORT virtual void set##attributeName(const attributeDatatype & attributeName) = 0;\
142  std::string get##attributeName() const {\
143  if (static_cast<T*>(gsoapProxy2_1)->attributeName == nullptr) { throw std::invalid_argument("The attribute does not exist"); }\
144  return *static_cast<T*>(gsoapProxy2_1)->attributeName;\
145  }\
146  bool has##attributeName() const { return static_cast<T*>(gsoapProxy2_1)->attributeName != nullptr; }
147 
148  GETTER_AND_SETTER_GENERIC_OPTIONAL_ATTRIBUTE_TEMPLATE(std::string, TimeDepth, gsoap_eml2_1::soap_new_std__string)
149  GETTER_AND_SETTER_GENERIC_OPTIONAL_ATTRIBUTE_TEMPLATE(std::string, RunNumber, gsoap_eml2_1::soap_new_std__string)
150  GETTER_AND_SETTER_GENERIC_OPTIONAL_ATTRIBUTE_TEMPLATE(std::string, PassNumber, gsoap_eml2_1::soap_new_std__string)
151  GETTER_AND_SETTER_GENERIC_OPTIONAL_ATTRIBUTE_TEMPLATE(std::string, LoggingCompanyName, gsoap_eml2_1::soap_new_std__string)
152  GETTER_AND_SETTER_GENERIC_OPTIONAL_ATTRIBUTE_TEMPLATE(std::string, LoggingCompanyCode, gsoap_eml2_1::soap_new_std__string)
153  GETTER_AND_SETTER_GENERIC_OPTIONAL_ATTRIBUTE_TEMPLATE(std::string, ToolName, gsoap_eml2_1::soap_new_std__string)
154  GETTER_AND_SETTER_GENERIC_OPTIONAL_ATTRIBUTE_TEMPLATE(std::string, ToolClass, gsoap_eml2_1::soap_new_std__string)
155  };
156 
164  template<> inline std::string ChannelMetaDataObject<gsoap_eml2_1::witsml20__Channel>::getTimeDepth() const {
165  return static_cast<gsoap_eml2_1::witsml20__Channel*>(gsoapProxy2_1)->TimeDepth;
166  }
167 
175  template<> inline bool ChannelMetaDataObject<gsoap_eml2_1::witsml20__Channel>::hasTimeDepth() const {
176  return true;
177  }
178 
186  template<> inline std::string ChannelMetaDataObject<gsoap_eml2_1::witsml20__Channel>::getLoggingCompanyName() const {
187  return static_cast<gsoap_eml2_1::witsml20__Channel*>(gsoapProxy2_1)->LoggingCompanyName;
188  }
189 
197  template<> inline bool ChannelMetaDataObject<gsoap_eml2_1::witsml20__Channel>::hasLoggingCompanyName() const {
198  return true;
199  }
200 }
common::DataObjectRepository * getRepository() const
Definition: AbstractObject.h:878
gsoap_eml2_1::eml21__DataObjectReference * newEmlReference() const
common::AbstractObject * addOrReplaceDataObject(common::AbstractObject *proxy, bool replaceOnlyContent=false)
Definition: ChannelMetaDataObject.h:38
ChannelMetaDataObject(gsoap_resqml2_0_1::eml20__DataObjectReference *partialObject)
Definition: ChannelMetaDataObject.h:48
virtual ~ChannelMetaDataObject()=default
common::DataObjectReference getWellboreDor() const
Gets wellbore dor.
Definition: ChannelMetaDataObject.h:68
void setPropertyKind(eml2::PropertyKind *propKind)
Definition: ChannelMetaDataObject.h:119
common::DataObjectReference getPropertyKindDor() const
Definition: ChannelMetaDataObject.h:97
ChannelMetaDataObject(gsoap_eml2_1::eml21__AbstractObject *fromGsoap)
Definition: ChannelMetaDataObject.h:58
eml2::PropertyKind * getPropertyKind() const
Definition: ChannelMetaDataObject.h:107
ChannelMetaDataObject()
Definition: ChannelMetaDataObject.h:51
void setWellbore(Wellbore *witsmlWellbore)
Definition: ChannelMetaDataObject.h:80
Definition: Wellbore.h:41
Definition: WellboreObject.h:32