1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2006 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
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.
52 /*-------------------------------------------------------------------------*/
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.
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.
82 /*-------------------------------------------------------------------------*/
85 /*! Constructor. Registers \a ElementTypeT as the default element with the
86 OSG::OSBElementFactory.
88 template <class ElementTypeT>
89 OSBDefaultElementRegistrationHelper<ElementTypeT>
90 ::OSBDefaultElementRegistrationHelper(void)
92 OSBElementFactory::the()->registerDefault(
93 new OSBElementCreator<ElementType>());