Skip to content

Commit d8496b8

Browse files
Enforce HDF proxy compatibility with RESQML version
In src/common/DataObjectRepository.cpp add the HdfProxy include and a runtime check in addRelationship that throws if a RESQML 2.0 data object is associated with an EML2.3 HdfProxy, instructing to use an EML2.0 HdfProxy instead. IT prevents mixing incompatible RESQML/EML versions.
1 parent 94cd33e commit d8496b8

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

example/example.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ void serializeStratigraphicModel(COMMON_NS::DataObjectRepository * repo, EML2_NS
528528
stratiColumnRank0->pushBackStratigraphicBinaryContact(stratiUnitAInterp, gsoap_eml2_3::resqml22__ContactMode::conformable, stratiUnitBInterp, gsoap_eml2_3::resqml22__ContactMode::conformable, horizon2Interp1);
529529

530530
// WellboreFeature marker frame
531-
if (wellbore1Interp1 != nullptr) {
531+
if (repo->getDefaultHdfProxy()->getXmlNamespace() == "resqml20" && wellbore1Interp1 != nullptr) {
532532
RESQML2_NS::WellboreMarkerFrameRepresentation* wmf = repo->createWellboreMarkerFrameRepresentation(wellbore1Interp1, "657d5e6b-1752-425d-b3e7-237037fa11eb", "Wellbore Marker Frame", w1i1TrajRep);
533533
double markerMdValues[2] = { 350, 550 };
534534
wmf->setMdValues(markerMdValues, 2, hdfProxy);
@@ -1196,10 +1196,12 @@ void serializeGrid(COMMON_NS::DataObjectRepository * repo, EML2_NS::AbstractHdfP
11961196
/**************
11971197
Points Properties
11981198
***************/
1199-
RESQML2_NS::PointsProperty* pointsProp = repo->createPointsProperty(twoCellsIjkGrid, "fdf3e92b-1ac2-4589-832d-69ee7c167db7", "Cell center", 1,
1200-
gsoap_eml2_3::eml23__IndexableElement::cells, local3dCrs);
1201-
double cellCenters[6] = { 185, 75, 400, 560, 75, 450 };
1202-
pointsProp->pushBackArray3dOfXyzPoints(cellCenters, 2, 1, 1, hdfProxy);
1199+
if (repo->getDefaultHdfProxy()->getXmlNamespace() == "resqml20") {
1200+
RESQML2_NS::PointsProperty* pointsProp = repo->createPointsProperty(twoCellsIjkGrid, "fdf3e92b-1ac2-4589-832d-69ee7c167db7", "Cell center", 1,
1201+
gsoap_eml2_3::eml23__IndexableElement::cells, local3dCrs);
1202+
double cellCenters[6] = { 185, 75, 400, 560, 75, 450 };
1203+
pointsProp->pushBackArray3dOfXyzPoints(cellCenters, 2, 1, 1, hdfProxy);
1204+
}
12031205

12041206
/**************
12051207
LGR
@@ -5784,7 +5786,7 @@ void appendAContinuousProp(const string& filePath)
57845786
}
57855787

57865788
// filepath is defined in a macro to better check memory leak
5787-
#define filePath u8"../../testingPackageCpp.epc"
5789+
#define filePath u8"../../testingPackageCpp22.epc"
57885790
int main()
57895791
{
57905792
try {

src/common/DataObjectRepository.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ under the License.
3838
#include "../eml2_3/ActivityTemplate.h"
3939
#include "../eml2_3/ColumnBasedTable.h"
4040
#include "../eml2_3/GraphicalInformationSet.h"
41+
#include "../eml2_3/HdfProxy.h"
4142
#include "../eml2_3/LocalEngineeringCompoundCrs.h"
4243
#include "../eml2_3/LocalEngineering2dCrs.h"
4344
#include "../eml2_3/PropertyKind.h"
@@ -394,6 +395,13 @@ void DataObjectRepository::addRelationship(COMMON_NS::AbstractObject * source, C
394395
if (source == nullptr || target == nullptr) {
395396
throw invalid_argument("Cannot set a relationship with a null pointer");
396397
}
398+
if (dynamic_cast<EML2_3_NS::HdfProxy*>(target) != nullptr) {
399+
const std::string& xmlNs = source->getXmlNamespace();
400+
if (xmlNs.substr(xmlNs.size() - 2) == "20") {
401+
throw invalid_argument("Cannot associate a 2.0 Energistics dataobject such as " +
402+
source->getXmlTag() + ' ' + source->getTitle() + '(' + source->getUuid() + ") with an EML2.3 Hdf Proxy. Please use an EML2.0 Hdf Proxy instead.");
403+
}
404+
}
397405

398406
auto sourceIt = forwardRels.find(source);
399407
if (sourceIt == forwardRels.end()) {

0 commit comments

Comments
 (0)