Introduce new templated clone(..) methods that return the correct type of object cloned.
This commit is contained in:
parent
97b37cb117
commit
7ec5632bcc
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user