33 #ifndef DART_DYNAMICS_DETAIL_BODYNODEPTR_HPP_
34 #define DART_DYNAMICS_DETAIL_BODYNODEPTR_HPP_
63 std::shared_ptr<const Skeleton>
getSkeleton()
const;
109 template <
class BodyNodeT>
128 template <
class OtherBodyNodeT>
139 template <
class OtherBodyNodeT>
155 operator BodyNodeT*()
const {
return mPtr; }
175 decrementReferenceCount();
181 incrementReferenceCount();
197 template <
class BodyNodeT>
212 template <
class OtherBodyNodeT>
215 :
mPtr(nullptr) {
set(_weakPtr); }
225 template <
class OtherBodyNodeT>
249 std::shared_ptr<const Skeleton> skeleton =
mLocker->mSkeleton.lock();
250 if(
nullptr == skeleton)
270 template <
class OtherBodyNodeT>
273 if(
nullptr == _weakPtr.
mLocker)
279 std::lock_guard<std::mutex>
lock(_weakPtr.
mLocker->mMutex);
280 std::shared_ptr<const Skeleton> skeleton =
281 _weakPtr.
mLocker->mSkeleton.lock();
282 if(
nullptr == skeleton)
307 std::shared_ptr<const Skeleton> skeleton =
mLocker->mSkeleton.lock();
308 if(
nullptr == skeleton)
320 std::shared_ptr<MutexedWeakSkeletonPtr>
mLocker;
Definition: BodyNodePtr.hpp:54
std::shared_ptr< MutexedWeakSkeletonPtr > mLockedSkeleton
Shared reference to a weak_ptr of this BodyNode's Skeleton, along with a mutex to ensure thread safet...
Definition: BodyNodePtr.hpp:101
std::shared_ptr< Skeleton > getSkeleton()
Return the Skeleton this BodyNode belongs to.
Definition: BodyNode.cpp:149
std::atomic< int > mReferenceCount
Reference count for the number of BodyNodePtrs that are referring to this BodyNode.
Definition: BodyNodePtr.hpp:89
SkeletonRefCountingBase()
Default Constructor.
Definition: BodyNode.cpp:125
std::weak_ptr< Skeleton > mSkeleton
Weak pointer to the Skeleton this BodyNode belongs to.
Definition: BodyNodePtr.hpp:85
std::shared_ptr< Skeleton > mReferenceSkeleton
If mReferenceCount is zero, then mReferenceSkeleton will hold a nullptr.
Definition: BodyNodePtr.hpp:96
void incrementReferenceCount() const
Atomically increment the reference count for this BodyNode.
Definition: BodyNode.cpp:133
void decrementReferenceCount() const
Atomically decrement the reference count for this BodyNode.
Definition: BodyNode.cpp:141
TemplateBodyNodePtr is a templated class that enables users to create a reference-counting BodyNodePt...
Definition: BodyNodePtr.hpp:111
BodyNodeT * mPtr
Raw pointer for the BodyNode that this BodyNodePtr references.
Definition: BodyNodePtr.hpp:189
TemplateBodyNodePtr(const TemplateBodyNodePtr< OtherBodyNodeT > &_bnp)
Templated constructor for copying other BodyNodePtrs.
Definition: BodyNodePtr.hpp:129
BodyNodeT & operator*() const
Dereferencing operator.
Definition: BodyNodePtr.hpp:158
TemplateBodyNodePtr()
Default constructor.
Definition: BodyNodePtr.hpp:114
void set(BodyNodeT *_ptr)
Set the BodyNode for this BodyNodePtr.
Definition: BodyNodePtr.hpp:167
TemplateBodyNodePtr(BodyNodeT *_ptr)
Typical constructor.
Definition: BodyNodePtr.hpp:118
BodyNodeT * get() const
Get the raw BodyNode pointer.
Definition: BodyNodePtr.hpp:164
TemplateBodyNodePtr(const TemplateBodyNodePtr &_bnp)
User defined copy-constructor.
Definition: BodyNodePtr.hpp:121
~TemplateBodyNodePtr()
Destructor. Releases the BodyNode reference before being destroyed.
Definition: BodyNodePtr.hpp:136
BodyNodeT * operator->() const
Dereferencing operation.
Definition: BodyNodePtr.hpp:161
TemplateBodyNodePtr & operator=(const TemplateBodyNodePtr< OtherBodyNodeT > &_bnp)
Change the BodyNode that this BodyNodePtr references.
Definition: BodyNodePtr.hpp:140
TemplateWeakBodyNodePtr is a templated class that enables users to create a non-reference-holding Wea...
Definition: BodyNodePtr.hpp:199
void set(BodyNodeT *_ptr)
Set the BodyNode for this WeakBodyNodePtr.
Definition: BodyNodePtr.hpp:257
TemplateWeakBodyNodePtr & operator=(BodyNodeT *_ptr)
Assignment operator for raw BodyNode pointers.
Definition: BodyNodePtr.hpp:218
BodyNodeT * mPtr
Raw pointer for the BodyNode that this WeakBodyNodePtr references.
Definition: BodyNodePtr.hpp:316
TemplateWeakBodyNodePtr(BodyNodeT *_ptr)
Typical constructor.
Definition: BodyNodePtr.hpp:209
void set(const TemplateWeakBodyNodePtr< OtherBodyNodeT > &_weakPtr)
Attempt to set the BodyNode for this WeakBodyNodePtr based on another WeakBodyNodePtr.
Definition: BodyNodePtr.hpp:271
TemplateBodyNodePtr< BodyNodeT > lock() const
Locks the BodyNode reference to ensure that the referenced BodyNode (1) is currently still available,...
Definition: BodyNodePtr.hpp:240
TemplateWeakBodyNodePtr()
Default constructor.
Definition: BodyNodePtr.hpp:205
TemplateWeakBodyNodePtr(const TemplateWeakBodyNodePtr< OtherBodyNodeT > &_weakPtr)
Constructor that takes in a WeakBodyNodePtr.
Definition: BodyNodePtr.hpp:213
bool expired() const
Returns true if this WeakBodyNodePtr is referencing a nullptr or a pointer which has been deleted.
Definition: BodyNodePtr.hpp:299
std::shared_ptr< MutexedWeakSkeletonPtr > mLocker
A shared_ptr that allows the WeakBodyNodePtr to know whether it can lock into a BodyNodePtr.
Definition: BodyNodePtr.hpp:320
Definition: BulletCollisionDetector.cpp:63
Definition: BodyNodePtr.hpp:47
std::weak_ptr< const Skeleton > mSkeleton
Definition: BodyNodePtr.hpp:49
std::mutex mMutex
Definition: BodyNodePtr.hpp:48