From 7ec5632bccc170282356ec656a1292670b4aa7a4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 17 Sep 2008 14:21:19 +0000 Subject: [PATCH] Introduce new templated clone(..) methods that return the correct type of object cloned. --- include/osg/Object | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/osg/Object b/include/osg/Object index 546636c72..bdc100770 100644 --- a/include/osg/Object +++ b/include/osg/Object @@ -36,6 +36,20 @@ class State; virtual const char* libraryName() const { return #library; }\ virtual const char* className() const { return #name; } +template +T* clone(const T* t, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) +{ + return dynamic_cast(t->clone(copyop)); +} + + +template +T* clone(const T* t, const std::string& name, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) +{ + T* newObject = dynamic_cast(t->clone(copyop)); + newObject->setName(name); + return newObject; +} /** Base class/standard interface for objects which require IO support, cloning and reference counting.