DART
6.7.3
|
This class watches when ShapeFrames get deleted so that they can be safely removes from the CollisionGroup. More...
Public Member Functions | |
void | addShapeFrame (const dynamics::ShapeFrame *shapeFrame) |
Add a shape frame to this observer. More... | |
void | removeShapeFrame (const dynamics::ShapeFrame *shapeFrame) |
Remove a shape frame from this observer. More... | |
void | removeAllShapeFrames () |
Remove all shape frames from this observer. More... | |
Public Attributes | |
std::unordered_set< const dynamics::ShapeFrame * > | mDeletedFrames |
Whenever an observed shape frame gets deleted, its pointer will be added to this set. More... | |
Protected Member Functions | |
void | handleDestructionNotification (const common::Subject *subject) override |
This will be called each time an observed shape frame is deleted. More... | |
void | receiveDestructionNotification (const Subject *_subject) |
Called whenever a Subject is destroyed (or sends out a destruction notification). More... | |
void | addSubject (const Subject *_subject) |
Add a Subject for this Observer. More... | |
void | removeSubject (const Subject *_subject) |
Remove a Subject from this Observer. More... | |
void | removeAllSubjects () |
Remove all Subjects from this Observer. More... | |
Protected Attributes | |
std::set< const Subject * > | mSubjects |
List of current Subjects for this Observer. More... | |
Private Attributes | |
std::unordered_map< const common::Subject *, const dynamics::ShapeFrame * > | mMap |
A map from a subject pointer to its corresponding ShapeFrame pointer. More... | |
This class watches when ShapeFrames get deleted so that they can be safely removes from the CollisionGroup.
We cannot have a weak_ptr to a ShapeFrame because some are managed by std::shared_ptr while others are managed by NodePtr.
If we don't carefully track when each ShapeFrame gets destructed, then we can land in a situation where a ShapeFrame gets removed from a BodyNode, deallocated, and then a new ShapeFrame is allocated in the memory address of the old one. This can lead to invalid memory accesses if we neglect to correctly clean up our references to deleted ShapeFrames.
void dart::collision::CollisionGroup::ShapeFrameObserver::addShapeFrame | ( | const dynamics::ShapeFrame * | shapeFrame | ) |
Add a shape frame to this observer.
|
protectedinherited |
Add a Subject for this Observer.
|
overrideprotectedvirtual |
This will be called each time an observed shape frame is deleted.
Reimplemented from dart::common::Observer.
|
protectedinherited |
Called whenever a Subject is destroyed (or sends out a destruction notification).
Override handleDestructionNotification() in order to customize your class's response to destruction notifications.
void dart::collision::CollisionGroup::ShapeFrameObserver::removeAllShapeFrames | ( | ) |
Remove all shape frames from this observer.
|
protectedinherited |
Remove all Subjects from this Observer.
void dart::collision::CollisionGroup::ShapeFrameObserver::removeShapeFrame | ( | const dynamics::ShapeFrame * | shapeFrame | ) |
Remove a shape frame from this observer.
|
protectedinherited |
Remove a Subject from this Observer.
std::unordered_set<const dynamics::ShapeFrame*> dart::collision::CollisionGroup::ShapeFrameObserver::mDeletedFrames |
Whenever an observed shape frame gets deleted, its pointer will be added to this set.
The next time the collision group updates, it will check this set and wipe away any references to the pointers in this set.
|
private |
A map from a subject pointer to its corresponding ShapeFrame pointer.
This needs to be stored because by the time a Subject is being destructed, it can no longer be cast back to its ShapeFrame.
|
protectedinherited |
List of current Subjects for this Observer.