fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / Collada / OSGColladaInstanceNode.cpp
bloba745e268b581aba8867b9a508cbbe9c0e6c0c7f6
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2009 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
40 #pragma GCC diagnostic ignored "-Wold-style-cast"
41 #endif
43 #include "OSGColladaInstanceNode.h"
45 #if defined(OSG_WITH_COLLADA) || defined(OSG_DO_DOC)
47 #include "OSGColladaLog.h"
49 OSG_BEGIN_NAMESPACE
51 ColladaElementRegistrationHelper ColladaInstanceNode::_regHelper(
52 &ColladaInstanceNode::create,
53 "instance_node" );
56 ColladaElementTransitPtr
57 ColladaInstanceNode::create(daeElement *elem, ColladaGlobal *global)
59 return ColladaElementTransitPtr(new ColladaInstanceNode(elem, global));
62 void
63 ColladaInstanceNode::read(ColladaElement *colElemParent)
65 OSG_COLLADA_LOG(("ColladaInstanceNode::read\n"));
67 ColladaNodeRefPtr colNode = getTargetElem();
69 if(colNode == NULL)
71 colNode = dynamic_pointer_cast<ColladaNode>(
72 ColladaElementFactory::the()->create(
73 getTargetDOMElem(), getGlobal()));
75 colNode->read(this);
79 ColladaNode *
80 ColladaInstanceNode::getTargetElem(void) const
82 ColladaNode *retVal = NULL;
83 daeElementRef targetElem = getTargetDOMElem();
85 if(targetElem != NULL)
87 retVal = getUserDataAs<ColladaNode>(targetElem);
90 return retVal;
93 domNode *
94 ColladaInstanceNode::getTargetDOMElem(void) const
96 domNodeRef retVal = NULL;
97 domInstance_nodeRef instNode = getDOMElementAs<domInstance_node>();
99 if(instNode->getUrl().getElement() != NULL)
101 retVal = daeSafeCast<domNode>(instNode->getUrl().getElement());
104 return retVal;
107 ColladaInstanceNode::ColladaInstanceNode(
108 daeElement *elem, ColladaGlobal *global)
110 : Inherited(elem, global)
114 ColladaInstanceNode::~ColladaInstanceNode(void)
118 OSG_END_NAMESPACE
120 #endif // OSG_WITH_COLLADA