Refactored the UserDataContainer so that the osg::UserDataContainer is now a pure virtual base class,

with a osg::DefaultUserDataContainer subclassed from this.  The user object access methods have now all
been moved from osg::Object into the UserDataContainer class, except for the set/getUserData() methods
that are left in osg::Object for backwards compatibility, and the description list access methods have
been moved back into osg::Node.

main UserObject access methods are now all def
This commit is contained in:
Robert Osfield
2011-06-09 12:57:14 +00:00
parent 1016092720
commit 22bc0391c7
10 changed files with 317 additions and 234 deletions

View File

@@ -17,6 +17,7 @@
#include <osg/Notify>
#include <osg/OccluderNode>
#include <osg/Transform>
#include <osg/UserDataContainer>
#include <algorithm>
@@ -472,6 +473,51 @@ bool Node::containsOccluderNodes() const
return _numChildrenWithOccluderNodes>0 || dynamic_cast<const OccluderNode*>(this);
}
void Node::setDescriptions(const DescriptionList& descriptions)
{
getOrCreateUserDataContainer()->setDescriptions(descriptions);
}
Node::DescriptionList& Node::getDescriptions()
{
return getOrCreateUserDataContainer()->getDescriptions();
}
static OpenThreads::Mutex s_mutex_StaticDescriptionList;
static const Node::DescriptionList& getStaticDescriptionList()
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_StaticDescriptionList);
static Node::DescriptionList s_descriptionList;
return s_descriptionList;
}
const Node::DescriptionList& Node::getDescriptions() const
{
if (_userDataContainer) return _userDataContainer->getDescriptions();
else return getStaticDescriptionList();
}
std::string& Node::getDescription(unsigned int i)
{
return getOrCreateUserDataContainer()->getDescriptions()[i];
}
const std::string& Node::getDescription(unsigned int i) const
{
if (_userDataContainer) return _userDataContainer->getDescriptions()[i];
else return getStaticDescriptionList()[i];
}
unsigned int Node::getNumDescriptions() const
{
return _userDataContainer ? _userDataContainer->getDescriptions().size() : 0;
}
void Node::addDescription(const std::string& desc)
{
getOrCreateUserDataContainer()->getDescriptions().push_back(desc);
}
BoundingSphere Node::computeBound() const
{
return BoundingSphere();