![]() |
OpenWalnut
1.5.0dev
|
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism. More...
#include <WGEGroupNode.h>
Inheritance diagram for WGEGroupNode:
Collaboration diagram for WGEGroupNode:Classes | |
| struct | ChildOperation |
| A struct denoting an operation on this group. More... | |
| class | SafeUpdaterCallback |
| Update callback which inserts and removes nodes from m_childRemovalQueue and m_childInsertionQueue to the group node. More... | |
Public Types | |
| typedef WPredicateHelper::ArbitraryPredicateBase< osg::ref_ptr< osg::Node > const > | NodePredicate |
| The base type of predicate. More... | |
Public Member Functions | |
| WGEGroupNode () | |
| Default constructor. More... | |
| void | insert (osg::ref_ptr< osg::Node > node) |
| Adds the specified node to the child list of this node in a safe manner. More... | |
| void | remove (osg::ref_ptr< osg::Node > node) |
| Removes the specified node from this group in a thread safe manner. More... | |
| void | remove_if (std::shared_ptr< WGEGroupNode::NodePredicate > predicate) |
| Removes a node if the specified predicate evaluates to true. More... | |
| void | clear () |
| Removes all children from this node. More... | |
Protected Types | |
| enum | ChildOperationType { INSERT = 0 , REMOVE , REMOVE_IF , CLEAR } |
| The type of operation to perform. More... | |
Protected Member Functions | |
| virtual | ~WGEGroupNode () |
| Destructor. More... | |
Protected Attributes | |
| osg::ref_ptr< SafeUpdaterCallback > | m_nodeUpdater |
| Node callback used to update this root node. More... | |
| std::queue< std::shared_ptr< ChildOperation > > | m_childOperationQueue |
| Queue of childs that need to be added/removed during the next update cycle. More... | |
| std::shared_mutex | m_childOperationQueueLock |
| Lock used for inserting and removing childs into the child insertion/removal queue. More... | |
| bool | m_childOperationQueueDirty |
| Flag denoting whether the m_childOperationQueue should be considered during the next update of the node. More... | |
| bool | m_removeAll |
| True whenever all child nodes should be removed. More... | |
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism.
Please be sure to use addUpdateCallback() to set your own update callbacks instead of setUpdateCallback, as this class already has set a callback, which would be overwritten by a subsequent call to setUpdateCallback(). It is derived from osg::MatrixTransform to allow easy transformations of a whole bunch of nodes.
Definition at line 47 of file WGEGroupNode.h.
| typedef WPredicateHelper::ArbitraryPredicateBase< osg::ref_ptr< osg::Node > const > WGEGroupNode::NodePredicate |
The base type of predicate.
Use a specific WPredicateHelper::ArbitraryPredicate instance. For details, see WPredicateHelper::ArbitraryPredicateBase.
Definition at line 76 of file WGEGroupNode.h.
|
protected |
The type of operation to perform.
| Enumerator | |
|---|---|
| REMOVE | insert the specified node |
| REMOVE_IF | remove the specified node |
| CLEAR | remove all items where the predicate evaluates to true clear group node completely |
Definition at line 123 of file WGEGroupNode.h.
| WGEGroupNode::WGEGroupNode | ( | ) |
|
protectedvirtual |
Destructor.
Definition at line 50 of file WGEGroupNode.cpp.
| void WGEGroupNode::clear | ( | ) |
Removes all children from this node.
Definition at line 79 of file WGEGroupNode.cpp.
References CLEAR, m_childOperationQueue, m_childOperationQueueDirty, and m_childOperationQueueLock.
| void WGEGroupNode::insert | ( | osg::ref_ptr< osg::Node > | node | ) |
Adds the specified node to the child list of this node in a safe manner.
OSG officially requires nodes to be added exclusively during update callbacks. Using this method it is ensured to be added during update cycle.
| node | the node to add. |
Definition at line 55 of file WGEGroupNode.cpp.
References m_childOperationQueue, m_childOperationQueueDirty, and m_childOperationQueueLock.
Referenced by WGEOffscreenRenderNode::addGeometryRenderPass(), WGEOffscreenRenderNode::addRenderPass(), WGEBorderLayout::WGEBorderLayout(), and WGEOffscreenRenderNode::WGEOffscreenRenderNode().
Here is the caller graph for this function:| void WGEGroupNode::remove | ( | osg::ref_ptr< osg::Node > | node | ) |
Removes the specified node from this group in a thread safe manner.
It returns if the node has been removed.
| node | the node to remove |
Definition at line 63 of file WGEGroupNode.cpp.
References m_childOperationQueue, m_childOperationQueueDirty, m_childOperationQueueLock, and REMOVE.
| void WGEGroupNode::remove_if | ( | std::shared_ptr< WGEGroupNode::NodePredicate > | predicate | ) |
Removes a node if the specified predicate evaluates to true.
| predicate | the predicate. |
Definition at line 71 of file WGEGroupNode.cpp.
References m_childOperationQueue, m_childOperationQueueDirty, m_childOperationQueueLock, and REMOVE_IF.
|
protected |
Queue of childs that need to be added/removed during the next update cycle.
It is a pair per operation, where the bool is denoting removal or insertion.
Definition at line 172 of file WGEGroupNode.h.
Referenced by clear(), insert(), WGEGroupNode::SafeUpdaterCallback::operator()(), remove(), and remove_if().
|
protected |
Flag denoting whether the m_childOperationQueue should be considered during the next update of the node.
Definition at line 182 of file WGEGroupNode.h.
Referenced by clear(), insert(), WGEGroupNode::SafeUpdaterCallback::operator()(), remove(), and remove_if().
|
protected |
Lock used for inserting and removing childs into the child insertion/removal queue.
Definition at line 177 of file WGEGroupNode.h.
Referenced by clear(), insert(), WGEGroupNode::SafeUpdaterCallback::operator()(), remove(), and remove_if().
|
protected |
Node callback used to update this root node.
Definition at line 118 of file WGEGroupNode.h.
Referenced by WGEGroupNode().
|
protected |
True whenever all child nodes should be removed.
Definition at line 187 of file WGEGroupNode.h.
Referenced by WGEGroupNode::SafeUpdaterCallback::operator()().