Introduce new templated clone(..) methods that return the correct type of object cloned.

This commit is contained in:
Robert Osfield 2008-09-17 14:21:19 +00:00
parent 97b37cb117
commit 7ec5632bcc

View File

@ -36,6 +36,20 @@ class State;
virtual const char* libraryName() const { return #library; }\
virtual const char* className() const { return #name; }
template<typename T>
T* clone(const T* t, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY)
{
return dynamic_cast<T*>(t->clone(copyop));
}
template<typename T>
T* clone(const T* t, const std::string& name, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY)
{
T* newObject = dynamic_cast<T*>(t->clone(copyop));
newObject->setName(name);
return newObject;
}
/** Base class/standard interface for objects which require IO support,
cloning and reference counting.