Refactored Observer/ObserverNodePath and DatabasePager to improve their robustness.
This commit is contained in:
@@ -15,17 +15,16 @@
|
||||
#define OSG_OBSERVERNODEPATH 1
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osg/Observer>
|
||||
#include <osg/ref_ptr>
|
||||
#include <list>
|
||||
#include <osg/observer_ptr>
|
||||
#include <vector>
|
||||
|
||||
namespace osg {
|
||||
|
||||
typedef std::list< osg::ref_ptr<osg::Node> > RefNodePath;
|
||||
typedef std::vector< osg::ref_ptr<osg::Node> > RefNodePath;
|
||||
|
||||
/** ObserverNodePath is an observer class for tracking changes to a NodePath,
|
||||
* that automatically invalidates it when nodes are deleted.*/
|
||||
class OSG_EXPORT ObserverNodePath : public osg::Observer
|
||||
class OSG_EXPORT ObserverNodePath
|
||||
{
|
||||
public:
|
||||
ObserverNodePath();
|
||||
@@ -38,9 +37,6 @@ class OSG_EXPORT ObserverNodePath : public osg::Observer
|
||||
|
||||
ObserverNodePath& operator = (const ObserverNodePath& rhs);
|
||||
|
||||
bool valid() const { return _valid; }
|
||||
|
||||
|
||||
/** get the NodePath from the first parental chain back to root, plus the specified node.*/
|
||||
void setNodePathTo(osg::Node* node);
|
||||
|
||||
@@ -61,21 +57,18 @@ class OSG_EXPORT ObserverNodePath : public osg::Observer
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
if (!_valid) return true;
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(*getObserverMutex());
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
return _nodePath.empty();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void _setNodePath(const osg::NodePath& nodePath);
|
||||
|
||||
void _clearNodePath();
|
||||
|
||||
virtual bool objectUnreferenced(void* ptr);
|
||||
|
||||
osg::NodePath _nodePath;
|
||||
bool _valid;
|
||||
typedef std::vector< osg::observer_ptr<osg::Node> > ObsNodePath;
|
||||
mutable OpenThreads::Mutex _mutex;
|
||||
ObsNodePath _nodePath;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user