Fesapi  2.0.0.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
DataObjectReference.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 "../proxies/gsoap_resqml2_0_1H.h"
22 #include "../proxies/gsoap_eml2_1H.h"
23 #include "../proxies/gsoap_eml2_2H.h"
24 #include "../proxies/gsoap_eml2_3H.h"
25 
26 #include "../nsDefinitions.h"
27 
28 #if defined(_WIN32) && !defined(FESAPI_STATIC)
29 #if defined(FesapiCpp_EXPORTS) || defined(FesapiCppUnderDev_EXPORTS)
30 #define DLL_IMPORT_OR_EXPORT __declspec(dllexport)
31 #else
32 #define DLL_IMPORT_OR_EXPORT __declspec(dllimport)
33 #endif
34 #else
35 #define DLL_IMPORT_OR_EXPORT
36 #endif
37 
38 namespace COMMON_NS
39 {
40  class AbstractObject;
43  {
44  public:
45 
47  DataObjectReference(): dor20(nullptr), dor21(nullptr), dor22(nullptr), dor23(nullptr) {}
48 
54  DataObjectReference(gsoap_resqml2_0_1::eml20__DataObjectReference * dor): dor20(dor), dor21(nullptr), dor22(nullptr), dor23(nullptr) {}
55 
61  DataObjectReference(gsoap_eml2_1::eml21__DataObjectReference * dor) : dor20(nullptr), dor21(dor), dor22(nullptr), dor23(nullptr) {}
62 
68  DataObjectReference(gsoap_eml2_2::eml22__DataObjectReference * dor) : dor20(nullptr), dor21(nullptr), dor22(dor), dor23(nullptr) {}
69 
75  DataObjectReference(gsoap_eml2_3::eml23__DataObjectReference * dor) : dor20(nullptr), dor21(nullptr), dor22(nullptr), dor23(dor) {}
76 
83 
85  ~DataObjectReference() = default;
86 
92  DLL_IMPORT_OR_EXPORT bool isEmpty() const {
93  return dor20 == nullptr && dor21 == nullptr && dor22 == nullptr && dor23 == nullptr;
94  }
95 
101  DLL_IMPORT_OR_EXPORT std::string getUuid() const {
102  if (dor20 != nullptr) {
103  return dor20->UUID;
104  }
105  else if (dor21 != nullptr) {
106  return dor21->Uuid;
107  }
108  else if (dor22 != nullptr) {
109  return dor22->Uuid;
110  }
111  else if (dor23 != nullptr) {
112  return dor23->Uuid;
113  }
114  else {
115  return "";
116  }
117  }
118 
124  DLL_IMPORT_OR_EXPORT std::string getTitle() const {
125  if (dor20 != nullptr) {
126  return dor20->Title;
127  }
128  else if (dor21 != nullptr) {
129  return dor21->Title;
130  }
131  else if (dor22 != nullptr) {
132  return dor22->Title;
133  }
134  else if (dor23 != nullptr) {
135  return dor23->Title;
136  }
137  else {
138  return "";
139  }
140  }
141 
147  DLL_IMPORT_OR_EXPORT std::string getVersion() const {
148  if (dor20 != nullptr) {
149  return dor20->VersionString != nullptr ? *dor20->VersionString : "";
150  }
151  else if (dor21 != nullptr) {
152  return dor21->VersionString != nullptr ? *dor21->VersionString : "";
153  }
154  else if (dor22 != nullptr) {
155  return dor22->ObjectVersion != nullptr ? *dor22->ObjectVersion : "";
156  }
157  else if (dor23 != nullptr) {
158  return dor23->ObjectVersion != nullptr ? *dor23->ObjectVersion : "";
159  }
160  else {
161  return "";
162  }
163  }
164 
170  DLL_IMPORT_OR_EXPORT std::string getContentType() const {
171  if (dor20 != nullptr) {
172  return dor20->ContentType;
173  }
174  else if (dor21 != nullptr) {
175  return dor21->ContentType;
176  }
177  else if (dor22 != nullptr) {
178  return dor22->ContentType;
179  }
180  else if (dor23 != nullptr) {
181  return dor23->ContentType;
182  }
183  else {
184  return "";
185  }
186  }
187 
194  gsoap_resqml2_0_1::eml20__DataObjectReference* toDor20() const {
195  if (dor20 != nullptr) {
196  return dor20;
197  }
198 
199  gsoap_resqml2_0_1::eml20__DataObjectReference* result = nullptr;
200  if (dor21 != nullptr) {
201  result = gsoap_resqml2_0_1::soap_new_eml20__DataObjectReference(dor21->soap);
202  }
203  else if (dor22 != nullptr) {
204  result = gsoap_resqml2_0_1::soap_new_eml20__DataObjectReference(dor22->soap);
205  }
206  else if (dor23 != nullptr) {
207  result = gsoap_resqml2_0_1::soap_new_eml20__DataObjectReference(dor23->soap);
208  }
209  else {
210  throw std::logic_error("The instance is in an inconsistent state.");
211  }
212 
213  result->ContentType = getContentType();
214  result->Title = getTitle();
215  result->UUID = getUuid();
216  const std::string version = getVersion();
217  if (!version.empty()) {
218  result->VersionString = gsoap_resqml2_0_1::soap_new_std__string(result->soap);
219  result->VersionString->assign(version);
220  }
221 
222  return result;
223  }
224 
225  private :
226  gsoap_resqml2_0_1::eml20__DataObjectReference* dor20;
227  gsoap_eml2_1::eml21__DataObjectReference* dor21;
228  gsoap_eml2_2::eml22__DataObjectReference* dor22;
229  gsoap_eml2_3::eml23__DataObjectReference* dor23;
230  };
231 
240  inline bool operator==(const DataObjectReference& ldor, const DataObjectReference& rdor)
241  {
242  return ldor.getUuid() == rdor.getUuid() &&
243  ldor.getContentType() == rdor.getContentType() &&
244  ldor.getVersion() == rdor.getVersion();
245  }
246 }
An abstract data object.
Definition: AbstractObject.h:31
This class wraps an Energistics Data Object Reference whatever its version is.
Definition: DataObjectReference.h:43
DataObjectReference(gsoap_resqml2_0_1::eml20__DataObjectReference *dor)
Definition: DataObjectReference.h:54
bool isEmpty() const
Definition: DataObjectReference.h:92
std::string getUuid() const
Definition: DataObjectReference.h:101
DataObjectReference(gsoap_eml2_2::eml22__DataObjectReference *dor)
Definition: DataObjectReference.h:68
std::string getContentType() const
Definition: DataObjectReference.h:170
DataObjectReference(gsoap_eml2_3::eml23__DataObjectReference *dor)
Definition: DataObjectReference.h:75
DataObjectReference(AbstractObject const *dataObj)
DataObjectReference()
Definition: DataObjectReference.h:47
gsoap_resqml2_0_1::eml20__DataObjectReference * toDor20() const
Definition: DataObjectReference.h:194
DataObjectReference(gsoap_eml2_1::eml21__DataObjectReference *dor)
Definition: DataObjectReference.h:61
std::string getTitle() const
Definition: DataObjectReference.h:124
std::string getVersion() const
Definition: DataObjectReference.h:147
bool operator==(const DataObjectReference &ldor, const DataObjectReference &rdor)
Title is not part of the real identifier of a dataobject. This is just a hint.
Definition: DataObjectReference.h:240