fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / OSB / OSGOSBElementFactoryHelper.inl
blobdc5280366dafebaf1f86091d19e4f8565e3f3eaf
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *                   Copyright (C) 2006 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 OSG_BEGIN_NAMESPACE
41 /*-------------------------------------------------------------------------*/
42 /* OSBElementRegistrationHelper<ElementTypeT>                              */
43 /*-------------------------------------------------------------------------*/
45 /*! \class OSG::OSBElementRegistrationHelper
46     Helper class to register an element for an OpenSG type. The usual way to
47     use this, is to put a static member of this type into the element.
49     \param ElementTypeT Type of the element to register.
50  */
52 /*-------------------------------------------------------------------------*/
53 /* Constructor                                                             */
55 /*! Constructor. Registers the \a ElementTypeT with the OSG::OSBElementFactory
56     to be responsible for the OpenSG type \a typeName.
58     \param[in] typeName OpenSG type that is handled by \a ElementTypeT.
59  */
60 template <class ElementTypeT>
61 OSBElementRegistrationHelper<ElementTypeT>::OSBElementRegistrationHelper(
62     const std::string &typeName)
64     OSBElementFactory::the()->registerElement(
65         typeName, new OSBElementCreator<ElementType>);
68 /*-------------------------------------------------------------------------*/
69 /* OSBDefaultElementRegistrationHelper<ElementTypeT>                       */
70 /*-------------------------------------------------------------------------*/
72 /*! \class OSG::OSBDefaultElementRegistrationHelper
73     Helper class to register an element as the default element, if no
74     specific element is registered for a type. The usual way to
75     use this, is to put a static member of this type into the element.
77     \note This can be used sensibly only once in the system.
79     \param ElementTypeT Type of the element to register as default element.
80  */
82 /*-------------------------------------------------------------------------*/
83 /* Constructor                                                             */
85 /*! Constructor. Registers \a ElementTypeT as the default element with the
86     OSG::OSBElementFactory.
87  */
88 template <class ElementTypeT>
89 OSBDefaultElementRegistrationHelper<ElementTypeT>
90     ::OSBDefaultElementRegistrationHelper(void)
92     OSBElementFactory::the()->registerDefault(
93         new OSBElementCreator<ElementType>());
96 OSG_END_NAMESPACE