[MOAB-dev] Equality of `Interface`s

Grindeanu, Iulian R. iulian at mcs.anl.gov
Fri Feb 28 16:15:49 CST 2020


Hello,
Sorry, I missed your message.
What are you trying to do ?
Why would you need to compare different moab instances?

You are right, moab::Range object is related to a specific instance;
It is just a set of long integers, that point to a specific moab instance.
(also moab::EntityHandle; moab::Range is just a container for moab::EntityHandle's)

In general, we do not use references for class members in our code style.

We rarely have the need for 2 moab instances. In general, we can use one moab instance and separate meshes by file sets

Or maybe you need to compare 2 meshes ?

Iulian



________________________________________
From: moab-dev <moab-dev-bounces at mcs.anl.gov> on behalf of Whitney, Ben <whitneybe at ornl.gov>
Sent: Wednesday, January 22, 2020 12:21 PM
To: moab-dev at mcs.anl.gov
Subject: [MOAB-dev] Equality of `Interface`s

I have a class with a data member of type `moab::Interface &`. I would like to compare instances of this class for equality, and to do this I would like to compare the `Interface`s for equality. The following is a simplification of the situation.

```
#include "moab/Core.hpp"
#include "moab/Range.hpp"

struct A {
  A(const moab::Interface &impl, const moab::Range handles):
    impl(impl),
    handles(handles)
  {}

  const moab::Interface &impl;
  const moab::Range handles;
};

bool operator==(const A &a, const A &b) {
  return a.impl == b.impl && a.handles == b.handles;
}

int main() {
  const moab::Core core_a;
  const moab::Core core_b;
  const moab::Range handles;

  const A a(core_a, handles);
  const A b(core_b, handles);
  a == b;

  return 0;
}
```

This code doesn't compile, because `operator==` isn't defined for `Interface`. Is there a way I can compare two `Interface`s to make sure that they're the same? Otherwise the `Range`s could contain the same `EntityHandle`s (interpreted as raw integers), but (it is my understanding) those handles could correspond to completely different objects because they're 'owned' by different `Interface`s.

I installed MOAB from source (commit `59e20f46c25975d78cd91b9b1ac153312977144e`) and am running this on Ubuntu 18.04. I see in `Interface.hpp` that `Interface` can inherit from either `nsISupports` or `UnknownInterface`. In my installation, it inherits from `UnknownInterface` (`nsISupports.h` is nowhere to be found).

Thank you,
--
Ben Whitney
Postdoctoral Research Associate
Computational and Applied Mathematics Group
Scientific Data Group
Oak Ridge National Laboratory


More information about the moab-dev mailing list