fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / Collada / OSGColladaGlobal.h
blobf6ab9c406e975a7cc3f312c29fa72f3c06f09aa7
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 _OSGCOLLADAGLOBAL_H_
40 #define _OSGCOLLADAGLOBAL_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 /*! \file OSGColladaGlobal.h
46 \ingroup GrpLoader
48 #include "OSGConfig.h"
50 #if defined(OSG_WITH_COLLADA) || defined(OSG_DO_DOC)
52 #include "OSGFileIODef.h"
53 #include "OSGMemoryObject.h"
54 #include "OSGPathHandler.h"
55 #include "OSGNode.h"
56 #include "OSGColladaElement.h"
57 #include "OSGColladaLoaderState.h"
58 #include "OSGColladaOptions.h"
59 #include "OSGStatElemTypes.h"
60 #include "OSGStatCollector.h"
61 #include "OSGGlobalsAttachment.h"
63 // collada dom includes
64 #include <dae.h>
65 #include <dom/domCOLLADA.h>
67 #include <deque>
68 #include <map>
69 #include <string>
70 #include <vector>
72 OSG_BEGIN_NAMESPACE
74 // forward decl
75 class ColladaInstInfo;
76 OSG_GEN_MEMOBJPTR(ColladaInstInfo);
80 // forward decl
81 class ColladaInstInfo;
82 OSG_GEN_MEMOBJPTR(ColladaInstInfo);
84 /*! \ingroup GrpFileIOCollada
85 \nohierarchy
88 class OSG_FILEIO_DLLMAPPING ColladaGlobal : public MemoryObject
90 /*========================== PUBLIC =================================*/
91 public:
92 /*---------------------------------------------------------------------*/
93 /*! \name Types */
94 /*! \{ */
96 typedef MemoryObject Inherited;
97 typedef ColladaGlobal Self;
99 OSG_GEN_INTERNAL_MEMOBJPTR(ColladaGlobal);
101 typedef std::deque<ColladaInstInfoRefPtr> InstanceQueue;
102 typedef InstanceQueue::iterator InstanceQueueIt;
103 typedef InstanceQueue::const_iterator InstanceQueueConstIt;
105 typedef std::map<std::string,
106 ColladaLoaderStateRefPtr> LoaderStateMap;
107 typedef LoaderStateMap::iterator LoaderStateMapIt;
108 typedef LoaderStateMap::const_iterator LoaderStateMapConstIt;
110 typedef std::vector<ColladaElementRefPtr> ElementStore;
111 typedef ElementStore::iterator ElementStoreIt;
112 typedef ElementStore::const_iterator ElementStoreConstIt;
114 /*! \} */
115 /*---------------------------------------------------------------------*/
116 /*! \name Statistics */
117 /*! \{ */
119 static StatElemDesc<StatIntElem> statNGeometryCreated;
120 static StatElemDesc<StatIntElem> statNGeometryUsed;
121 static StatElemDesc<StatIntElem> statNMaterialCreated;
122 static StatElemDesc<StatIntElem> statNMaterialUsed;
123 static StatElemDesc<StatIntElem> statNLightCreated;
124 static StatElemDesc<StatIntElem> statNLightUsed;
125 static StatElemDesc<StatIntElem> statNTextureCreated;
126 static StatElemDesc<StatIntElem> statNTextureUsed;
128 StatCollector *getStatCollector(void );
129 void setStatCollector(StatCollector *statColl);
131 /*! \} */
132 /*---------------------------------------------------------------------*/
133 /*! \name Create */
134 /*! \{ */
136 static ObjTransitPtr create(void);
138 /*! \} */
139 /*---------------------------------------------------------------------*/
140 /*! \name Read */
141 /*! \{ */
143 NodeTransitPtr read( std::istream &is,
144 const std::string &fileName);
146 NodeTransitPtr read( DAE *dae,
147 const std::string &fileName);
149 /*! \} */
150 /*---------------------------------------------------------------------*/
151 /*! \name Access */
152 /*! \{ */
154 inline const DAE *getDAE (void ) const;
155 inline DAE *editDAE (void );
156 inline domCOLLADA *getDocRoot (void ) const;
158 inline const std::string &getDocPath (void ) const;
159 inline void setDocPath (const std::string &docPath);
161 inline ColladaOptions *getOptions (void ) const;
162 inline void setOptions (ColladaOptions *options);
164 inline Node *getRoot (void ) const;
165 inline void setRoot (Node *rootN );
167 inline GlobalsAttachment *getGlobalsAtt(void ) const;
169 /*! \} */
170 /*---------------------------------------------------------------------*/
171 /*! \name LoaderState */
172 /*! \{ */
174 inline void addLoaderState(const std::string &name,
175 ColladaLoaderState *state);
176 inline void subLoaderState(const std::string &name );
178 inline ColladaLoaderState *getLoaderState (const std::string &name) const;
179 template <class StateTypeT>
180 inline StateTypeT *getLoaderStateAs(const std::string &name) const;
182 /*! \} */
183 /*---------------------------------------------------------------------*/
184 /*! \name ElementStore */
185 /*! \{ */
187 inline const InstanceQueue &getInstQueue (void ) const;
188 inline InstanceQueue &editInstQueue(void );
190 inline const ElementStore &getElemStore (void ) const;
191 inline ElementStore &editElemStore(void );
193 void addElement (ColladaElement *elem );
195 ColladaElement *getElement (const daeURI &elemURI) const;
196 ColladaElement *getElement (const std::string &elemId ) const;
198 /*! \} */
199 /*---------------------------------------------------------------------*/
200 /*! \name ElementStore */
201 /*! \{ */
203 static std::string fixFilepath ( std::string szFilepath );
204 static std::string fixImageFilepath( std::string szImgPath );
205 static std::string uriToNativePath (const std::string &uriRef,
206 cdom::systemType type =
207 cdom::getSystemType());
209 /*! \} */
210 /*========================= PROTECTED ===============================*/
211 protected:
212 /*---------------------------------------------------------------------*/
213 /*! \name Constructors/Destructor */
214 /*! \{ */
216 ColladaGlobal(void);
217 virtual ~ColladaGlobal(void);
219 /*! \} */
220 /*---------------------------------------------------------------------*/
221 /*! \name Read */
222 /*! \{ */
224 NodeTransitPtr doRead(void);
226 /*! \} */
227 /*---------------------------------------------------------------------*/
229 InstanceQueue _instQueue;
230 LoaderStateMap _loaderState;
231 ElementStore _elemStore;
233 ColladaOptionsRefPtr _options;
234 StatCollectorRefPtr _statColl;
236 PathHandler _pathHandler;
237 std::string _docPath;
239 domCOLLADARef _docRoot;
240 DAE *_dae;
242 NodeUnrecPtr _rootN;
243 GlobalsAttachmentUnrecPtr _globalsAtt;
245 private:
247 ColladaGlobal(const ColladaGlobal &other);
248 void operator=(const ColladaGlobal &rhs);
252 OSG_GEN_MEMOBJPTR(ColladaGlobal);
254 OSG_END_NAMESPACE
256 #include "OSGColladaGlobal.inl"
258 #endif // OSG_WITH_COLLADA
260 #endif // _OSGCOLLADAGLOBAL_H_