25 #ifndef WGEGROUPNODE_H
26 #define WGEGROUPNODE_H
30 #include <shared_mutex>
32 #include <boost/thread.hpp>
33 #include <osg/MatrixTransform>
34 #include <osg/NodeCallback>
36 #include "../common/WPredicateHelper.h"
63 void insert( osg::ref_ptr< osg::Node > node );
70 void remove( osg::ref_ptr< osg::Node > node );
84 void remove_if( std::shared_ptr< WGEGroupNode::NodePredicate > predicate );
112 virtual void operator()( osg::Node* node, osg::NodeVisitor* nv );
Update callback which inserts and removes nodes from m_childRemovalQueue and m_childInsertionQueue to...
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
Callback method called by the NodeVisitor when visiting a node.
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism.
void remove_if(std::shared_ptr< WGEGroupNode::NodePredicate > predicate)
Removes a node if the specified predicate evaluates to true.
bool m_childOperationQueueDirty
Flag denoting whether the m_childOperationQueue should be considered during the next update of the no...
virtual ~WGEGroupNode()
Destructor.
std::queue< std::shared_ptr< ChildOperation > > m_childOperationQueue
Queue of childs that need to be added/removed during the next update cycle.
std::shared_mutex m_childOperationQueueLock
Lock used for inserting and removing childs into the child insertion/removal queue.
void remove(osg::ref_ptr< osg::Node > node)
Removes the specified node from this group in a thread safe manner.
bool m_removeAll
True whenever all child nodes should be removed.
WPredicateHelper::ArbitraryPredicateBase< osg::ref_ptr< osg::Node > const > NodePredicate
The base type of predicate.
osg::ref_ptr< SafeUpdaterCallback > m_nodeUpdater
Node callback used to update this root node.
WGEGroupNode()
Default constructor.
ChildOperationType
The type of operation to perform.
@ CLEAR
remove all items where the predicate evaluates to true
@ REMOVE_IF
remove the specified node
@ REMOVE
insert the specified node
void clear()
Removes all children from this node.
void insert(osg::ref_ptr< osg::Node > node)
Adds the specified node to the child list of this node in a safe manner.
This class builds the base for wrapping around nearly every possible predicates like functors,...
A struct denoting an operation on this group.
osg::ref_ptr< osg::Node > m_item
the item to delete/add
ChildOperation(ChildOperationType what, std::shared_ptr< NodePredicate > predicate)
Constructs instance and fills members properly.
std::shared_ptr< NodePredicate > m_predicate
the predicate used by conditional operations
ChildOperationType m_operation
the operation to take
ChildOperation(ChildOperationType what, osg::ref_ptr< osg::Node > item)
Constructs instance and fills members properly.