ArcGIS Procedural Runtime  3.2.10650
List of all members | Public Member Functions
prtx::ComparableContent Class Referenceabstract

#include <Content.h>

Inheritance diagram for prtx::ComparableContent:
[legend]

Public Member Functions

virtual bool compare (const ComparableContent &rhs) const =0
 
virtual bool operator!= (const ComparableContent &rhs) const =0
 
virtual bool operator< (const ComparableContent &rhs) const =0
 
virtual bool operator== (const ComparableContent &rhs) const =0
 
- Public Member Functions inherited from prtx::Content
 Content (const Content &)=delete
 
Contentoperator= (const Content &)=delete
 

Detailed Description

Interface for comparable content classes.

A word of caution: To compare content objects, do not directly compare pointer values (or shared pointers)! Content objects are typically implemented as thin wrappers to internal storage classes and do not guarantee pointer equality. Operate on the objects instead:

MaterialBuilder mb;
MaterialPtr m1 = mb.createShared();
MaterialPtr m2 = mb.createShared();
assert(m1 == m2); // WRONG!
assert(*m1 == *m2); // CORRECT!
assert(m1->compare(*m2)); // CORRECT!

To use shared pointers to content objects with STL containers like std::set or std::map, we recommend to use a de-referencing comparator like this:

template<typename T>
struct DeRefLess<std::shared_ptr<T>> {
bool operator()(const std::shared_ptr<T>& a, const std::shared_ptr<T>& b) const {
const T* pa = a.get();
const T* pb = b.get();
if (pa == nullptr)
return (pb != nullptr);
if (pb == nullptr)
return false;
return (*pa < *pb);
}
};

The documentation for this class was generated from the following file: