[MOAB-dev] Equality of `Interface`s

Whitney, Ben whitneybe at ornl.gov
Wed Jan 22 12:21:10 CST 2020


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