1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2009 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 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGCOLLADAELEMENTFACTORY_H_
40 #define _OSGCOLLADAELEMENTFACTORY_H_
45 #include "OSGConfig.h"
47 #if defined(OSG_WITH_COLLADA) || defined(OSG_DO_DOC)
49 #include "OSGFileIODef.h"
50 #include "OSGSingletonHolder.h"
51 #include "OSGColladaElement.h"
56 #include <boost/function.hpp>
60 /*! \ingroup GrpFileIOCollada
64 class OSG_FILEIO_DLLMAPPING ColladaElementFactorySingleton
66 /*========================== PUBLIC =================================*/
68 /*---------------------------------------------------------------------*/
72 typedef boost::function
<
73 ColladaElementTransitPtr (daeElement
*,
74 ColladaGlobal
*)> CreateFunctor
;
76 typedef std::map
<std::string
, CreateFunctor
> HandlerMap
;
77 typedef HandlerMap::iterator HandlerMapIt
;
78 typedef HandlerMap::const_iterator HandlerMapConstIt
;
80 typedef std::map
<std::string
, HandlerMap
> ProfileHandlerMap
;
81 typedef ProfileHandlerMap::iterator ProfileHandlerMapIt
;
82 typedef ProfileHandlerMap::const_iterator ProfileHandlerMapConstIt
;
85 /*---------------------------------------------------------------------*/
86 /*! \name Registration */
89 bool registerElement (CreateFunctor createFunc
,
90 const std::string
&elemName
,
91 const std::string
&profile
= "",
92 bool override
= false);
93 bool unregisterElement(const std::string
&elemName
,
94 const std::string
&profile
= "");
96 const HandlerMap
&getDefaultHandlerMap (void) const;
97 HandlerMap
&editDefaultHandlerMap(void);
99 const ProfileHandlerMap
&getProfileHandlerMap (void) const;
100 ProfileHandlerMap
&editProfileHandlerMap(void);
103 /*---------------------------------------------------------------------*/
104 /*! \name Default Profile */
107 const std::string
&getDefaultProfile(void ) const;
108 void setDefaultProfile(const std::string
&profile
);
111 /*---------------------------------------------------------------------*/
115 CreateFunctor
getCreateFunc(const std::string
&elemName
,
116 const std::string
&profile
= "" );
118 ColladaElementTransitPtr
create (daeElement
*daeElem
,
119 ColladaGlobal
*global
,
120 const std::string
&elemName
= "",
121 const std::string
&profile
= "" );
124 /*========================= PROTECTED ===============================*/
126 /*---------------------------------------------------------------------*/
130 bool doRegisterElement (CreateFunctor createFunc
,
131 const std::string
&elemName
,
132 HandlerMap
&handlerMap
,
134 bool doUnregisterElement(const std::string
&elemName
,
135 HandlerMap
&handlerMap
);
137 CreateFunctor
doGetCreateFunc (const std::string
&elemName
,
138 HandlerMap
&handlerMap
);
141 /*========================== PRIVATE ================================*/
144 /*---------------------------------------------------------------------*/
145 /*! \name Constructors/Destructor */
148 ColladaElementFactorySingleton(void);
149 ~ColladaElementFactorySingleton(void);
152 /*---------------------------------------------------------------------*/
154 template <class SingletonT
>
155 friend class SingletonHolder
;
157 std::string _defaultProfile
;
158 HandlerMap _defaultHandlerMap
;
159 ProfileHandlerMap _profileHandlerMap
;
163 OSG_FILEIO_EXPIMP_TMPL
164 template class OSG_FILEIO_DLLMAPPING SingletonHolder
<ColladaElementFactorySingleton
>;
167 /*! \ingroup GrpFileIOCollada
170 typedef SingletonHolder
<ColladaElementFactorySingleton
> ColladaElementFactory
;
174 #endif // OSG_WITH_COLLADA
176 #endif // _OSGCOLLADAELEMENTFACTORY_H_