diff --git a/src/proc/mobject/mobject-ref.hpp b/src/proc/mobject/mobject-ref.hpp index 73c87a861..bdccf1fb6 100644 --- a/src/proc/mobject/mobject-ref.hpp +++ b/src/proc/mobject/mobject-ref.hpp @@ -312,5 +312,29 @@ namespace mobject { typedef MORef MObjectRef; + /* === convenience shortcuts === */ + + /** check if the two references actually share ownership + * on the same underlying \em MObject (as opposed to referring + * to the same \em Placement, which is tested by \c operator== ) + */ + template + inline bool + isSharedPointee (MORef const& ref1, MORef const& ref2) + { + return ref1.isValid() && ref2.isValid() + && isSharedPointee (ref1.getPlacement(), ref2.getPlacement()); + } + + /** check if the two references actually denote an equivalent placement */ + template + inline bool + isEquivalentPlacement (MORef const& ref1, MORef const& ref2) + { + return ref1.isValid() && ref2.isValid() + && isSameDef (ref1.getPlacement(), ref2.getPlacement()); + } + + } // namespace mobject #endif diff --git a/src/proc/mobject/placement.hpp b/src/proc/mobject/placement.hpp index 27ac94003..46607752d 100644 --- a/src/proc/mobject/placement.hpp +++ b/src/proc/mobject/placement.hpp @@ -161,6 +161,14 @@ namespace mobject { target = static_pointer_cast(*this); } + /** free function to detect two placements sharing a pointee */ + friend bool + isSharedPointee (Placement const& p1, Placement const& p2) + { + return static_cast (p1.get()) + == static_cast (p2.get()); + } + operator string() const ; size_t use_count() const { return _SmartPtr::use_count(); }