changed: gcc8 base update
[opensg.git] / Source / System / FileIO / Collada / OSGColladaElementFactory.h
blob2d96aff080a8b65cc67b9b0813d225b7f88a46d1
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 #ifndef _OSGCOLLADAELEMENTFACTORY_H_
40 #define _OSGCOLLADAELEMENTFACTORY_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
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"
53 #include <map>
54 #include <string>
56 #include <boost/function.hpp>
58 OSG_BEGIN_NAMESPACE
60 /*! \ingroup GrpFileIOCollada
61 \nohierarchy
64 class OSG_FILEIO_DLLMAPPING ColladaElementFactorySingleton
66 /*========================== PUBLIC =================================*/
67 public:
68 /*---------------------------------------------------------------------*/
69 /*! \name Types */
70 /*! \{ */
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;
84 /*! \} */
85 /*---------------------------------------------------------------------*/
86 /*! \name Registration */
87 /*! \{ */
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);
102 /*! \} */
103 /*---------------------------------------------------------------------*/
104 /*! \name Default Profile */
105 /*! \{ */
107 const std::string &getDefaultProfile(void ) const;
108 void setDefaultProfile(const std::string &profile);
110 /*! \} */
111 /*---------------------------------------------------------------------*/
112 /*! \name Create */
113 /*! \{ */
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 = "" );
123 /*! \} */
124 /*========================= PROTECTED ===============================*/
125 protected:
126 /*---------------------------------------------------------------------*/
127 /*! \name Helper */
128 /*! \{ */
130 bool doRegisterElement (CreateFunctor createFunc,
131 const std::string &elemName,
132 HandlerMap &handlerMap,
133 bool override );
134 bool doUnregisterElement(const std::string &elemName,
135 HandlerMap &handlerMap );
137 CreateFunctor doGetCreateFunc (const std::string &elemName,
138 HandlerMap &handlerMap );
140 /*! \} */
141 /*========================== PRIVATE ================================*/
142 private:
144 /*---------------------------------------------------------------------*/
145 /*! \name Constructors/Destructor */
146 /*! \{ */
148 ColladaElementFactorySingleton(void);
149 ~ColladaElementFactorySingleton(void);
151 /*! \} */
152 /*---------------------------------------------------------------------*/
154 template <class SingletonT>
155 friend class SingletonHolder;
157 std::string _defaultProfile;
158 HandlerMap _defaultHandlerMap;
159 ProfileHandlerMap _profileHandlerMap;
162 #if defined(WIN32)
163 OSG_FILEIO_EXPIMP_TMPL
164 template class OSG_FILEIO_DLLMAPPING SingletonHolder<ColladaElementFactorySingleton>;
165 #endif
167 /*! \ingroup GrpFileIOCollada
170 typedef SingletonHolder<ColladaElementFactorySingleton> ColladaElementFactory;
172 OSG_END_NAMESPACE
174 #endif // OSG_WITH_COLLADA
176 #endif // _OSGCOLLADAELEMENTFACTORY_H_