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

@@ -15,6 +15,7 @@
#define OSG_VALUEOBJECT 1
#include <osg/Object>
#include <osg/UserDataContainer>
namespace osg {
@@ -171,7 +172,7 @@ template<typename T>
bool osg::Object::getUserValue(const std::string& name, T& value) const
{
typedef TemplateValueObject<T> UserValueObject;
const UserValueObject* uvo = dynamic_cast<const UserValueObject*>(getUserObject(name));
const UserValueObject* uvo = _userDataContainer ? dynamic_cast<const UserValueObject*>(_userDataContainer->getUserObject(name)) : 0;
if (uvo)
{
value = uvo->getValue();
@@ -189,9 +190,11 @@ void osg::Object::setUserValue(const std::string& name, const T& value)
{
typedef TemplateValueObject<T> UserValueObject;
unsigned int i = getUserObjectIndex(name);
if (i<getNumUserObjects()) setUserObject(i, new UserValueObject(name,value));
else addUserObject(new UserValueObject(name,value));
getOrCreateUserDataContainer();
unsigned int i = _userDataContainer->getUserObjectIndex(name);
if (i<_userDataContainer->getNumUserObjects()) _userDataContainer->setUserObject(i, new UserValueObject(name,value));
else _userDataContainer->addUserObject(new UserValueObject(name,value));
}
}