fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / WRL / OSGVRMLNodeHelper.inl
blob8b77e7f1f6d12d843aac64840fbf96fb2a343143
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *             Copyright (C) 2008 by the OpenSG Forum                        *
6  *                                                                           *
7  *                            www.opensg.org                                 *
8  *                                                                           *
9  *   contact: dirk@opensg.org, vossg@vossg.org, carsten_neumann@gmx.net      *
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 OSG_BEGIN_NAMESPACE
41 template<class ContainerT> inline
42 VRMLNodeHelper *VRMLGenericHelper<ContainerT>::create(void)
44     return new VRMLGenericHelper<ContainerT>();
46        
48 template<class ContainerT> inline
49 VRMLGenericHelper<ContainerT>::~VRMLGenericHelper(void)
53 template<class ContainerT> inline
54 void VRMLGenericHelper<ContainerT>::init(const Char8 *szName)
56     Inherited::init(szName);
58 #ifdef OSG_DEBUG_VRML
59     indentLog(getIndent(), PINFO);
60     PINFO << "GenericHelper::init : " << szName << std::endl;
61 #endif
63     _pNodeProto     = Node      ::create();
64     _pNodeCoreProto = ContainerT::create();
66     _pGenAttProto   = VRMLGenericAtt::createLocal(FCLocal::Cluster);
67     _pGenAttProto->setInternal(true);
70 template<class ContainerT> inline
71 void VRMLGenericHelper<ContainerT>::mapFieldname(
72     const std::string &szVRMLNodeName,
73           std::string &szFieldName   )
75     if(_mFieldNameMap.empty() == false)
76     {
77         FieldNameMapConstIt nIt = _mFieldNameMap.find(szFieldName);
79         if(nIt != _mFieldNameMap.end())
80         {
81             szFieldName = nIt->second;
82         }
83     }
86 template<class ContainerT> inline
87 bool VRMLGenericHelper<ContainerT>::prototypeAddField(
88     const Char8  *szFieldType,
89     const UInt32  uiFieldTypeId,
90     const Char8  *szFieldName)
92     if(szFieldName == NULL)
93         return false;
95     std::string szDummyVRMLNodeName;
96     std::string szTmpFieldName(szFieldName);
98     this->mapFieldname(szDummyVRMLNodeName, szTmpFieldName);
100     return Inherited::prototypeAddField(szFieldType, 
101                                         uiFieldTypeId, 
102                                         szTmpFieldName.c_str());
105 template<class ContainerT> inline
106 void VRMLGenericHelper<ContainerT>::getFieldAndDesc  (     
107           FieldContainer       * pFC,
108     const Char8                * szFieldname,
109           FieldContainer       *&pFieldFC,
110           EditFieldHandlePtr    &pField,
111     const FieldDescriptionBase *&pDesc)
113     if(szFieldname == NULL)
114         return;
116     std::string szDummyVRMLNodeName;
117     std::string szTmpFieldName(szFieldname);
119     this->mapFieldname(szDummyVRMLNodeName, szTmpFieldName);
121     Inherited::getFieldAndDesc(pFC, 
122                                szTmpFieldName.c_str(),
123                                pFieldFC,
124                                pField,
125                                pDesc);
129 template<class ContainerT> inline
130 void VRMLGenericHelper<ContainerT>::dump(const Char8 *szNodeName)
134 template<class ContainerT> inline
135 VRMLGenericHelper<ContainerT>::VRMLGenericHelper(void) :
136     Inherited()
140 OSG_END_NAMESPACE