OpenWalnut
1.4.0
|
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism. More...
#include <WGEGroupNode.h>
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. | |
Public Member Functions | |
WGEGroupNode () | |
Default constructor. | |
void | insert (osg::ref_ptr< osg::Node > node) |
Adds the specified node to the child list of this node in a safe manner. | |
void | remove (osg::ref_ptr< osg::Node > node) |
Removes the specified node from this group in a thread safe manner. | |
void | remove_if (boost::shared_ptr< WGEGroupNode::NodePredicate > predicate) |
Removes a node if the specified predicate evaluates to true. | |
void | clear () |
Removes all children from this node. | |
Protected Types | |
enum | ChildOperationType { INSERT = 0, REMOVE, REMOVE_IF, CLEAR } |
The type of operation to perform. More... | |
Protected Member Functions | |
virtual | ~WGEGroupNode () |
Destructor. | |
Protected Attributes | |
osg::ref_ptr< SafeUpdaterCallback > | m_nodeUpdater |
Node callback used to update this root node. | |
std::queue< boost::shared_ptr < ChildOperation > > | m_childOperationQueue |
Queue of childs that need to be added/removed during the next update cycle. | |
boost::shared_mutex | m_childOperationQueueLock |
Lock used for inserting and removing childs into the child insertion/removal queue. | |
bool | m_childOperationQueueDirty |
Flag denoting whether the m_childOperationQueue should be considered during the next update of the node. | |
bool | m_removeAll |
True whenever all child nodes should be removed. |
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 46 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 75 of file WGEGroupNode.h.
enum WGEGroupNode::ChildOperationType [protected] |
The type of operation to perform.
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 122 of file WGEGroupNode.h.
WGEGroupNode::~WGEGroupNode | ( | ) | [protected, virtual] |
Destructor.
Definition at line 49 of file WGEGroupNode.cpp.
void WGEGroupNode::clear | ( | ) |
Removes all children from this node.
Definition at line 78 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 54 of file WGEGroupNode.cpp.
References m_childOperationQueue, m_childOperationQueueDirty, and m_childOperationQueueLock.
Referenced by WGEOffscreenRenderNode::addGeometryRenderPass(), WGEOffscreenRenderNode::addRenderPass(), WGEBorderLayout::WGEBorderLayout(), and WGEOffscreenRenderNode::WGEOffscreenRenderNode().
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 62 of file WGEGroupNode.cpp.
References m_childOperationQueue, m_childOperationQueueDirty, m_childOperationQueueLock, and REMOVE.
void WGEGroupNode::remove_if | ( | boost::shared_ptr< WGEGroupNode::NodePredicate > | predicate | ) |
Removes a node if the specified predicate evaluates to true.
predicate | the predicate. |
Definition at line 70 of file WGEGroupNode.cpp.
References m_childOperationQueue, m_childOperationQueueDirty, m_childOperationQueueLock, and REMOVE_IF.
std::queue< boost::shared_ptr< ChildOperation > > WGEGroupNode::m_childOperationQueue [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 171 of file WGEGroupNode.h.
Referenced by clear(), insert(), WGEGroupNode::SafeUpdaterCallback::operator()(), remove(), and remove_if().
bool WGEGroupNode::m_childOperationQueueDirty [protected] |
Flag denoting whether the m_childOperationQueue should be considered during the next update of the node.
Definition at line 181 of file WGEGroupNode.h.
Referenced by clear(), insert(), WGEGroupNode::SafeUpdaterCallback::operator()(), remove(), and remove_if().
boost::shared_mutex WGEGroupNode::m_childOperationQueueLock [protected] |
Lock used for inserting and removing childs into the child insertion/removal queue.
Definition at line 176 of file WGEGroupNode.h.
Referenced by clear(), insert(), WGEGroupNode::SafeUpdaterCallback::operator()(), remove(), and remove_if().
osg::ref_ptr< SafeUpdaterCallback > WGEGroupNode::m_nodeUpdater [protected] |
Node callback used to update this root node.
Definition at line 117 of file WGEGroupNode.h.
Referenced by WGEGroupNode().
bool WGEGroupNode::m_removeAll [protected] |
True whenever all child nodes should be removed.
Definition at line 186 of file WGEGroupNode.h.
Referenced by WGEGroupNode::SafeUpdaterCallback::operator()().