placement and pointee equivalence tests
This commit is contained in:
parent
11c5d55b73
commit
baff536731
2 changed files with 32 additions and 0 deletions
|
|
@ -312,5 +312,29 @@ namespace mobject {
|
|||
typedef MORef<MObject> 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<class MOX, class MOY>
|
||||
inline bool
|
||||
isSharedPointee (MORef<MOX> const& ref1, MORef<MOY> const& ref2)
|
||||
{
|
||||
return ref1.isValid() && ref2.isValid()
|
||||
&& isSharedPointee (ref1.getPlacement(), ref2.getPlacement());
|
||||
}
|
||||
|
||||
/** check if the two references actually denote an equivalent placement */
|
||||
template<class MOX, class MOY>
|
||||
inline bool
|
||||
isEquivalentPlacement (MORef<MOX> const& ref1, MORef<MOY> const& ref2)
|
||||
{
|
||||
return ref1.isValid() && ref2.isValid()
|
||||
&& isSameDef (ref1.getPlacement(), ref2.getPlacement());
|
||||
}
|
||||
|
||||
|
||||
} // namespace mobject
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -161,6 +161,14 @@ namespace mobject {
|
|||
target = static_pointer_cast<Y>(*this);
|
||||
}
|
||||
|
||||
/** free function to detect two placements sharing a pointee */
|
||||
friend bool
|
||||
isSharedPointee (Placement const& p1, Placement const& p2)
|
||||
{
|
||||
return static_cast<const void*> (p1.get())
|
||||
== static_cast<const void*> (p2.get());
|
||||
}
|
||||
|
||||
|
||||
operator string() const ;
|
||||
size_t use_count() const { return _SmartPtr::use_count(); }
|
||||
|
|
|
|||
Loading…
Reference in a new issue