fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / WRL / OSGVRMLFile.h
blob4ebc715eef01caccdda12bb48cd6a89a958047c6
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 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 _OSGVRMLFILE_H_
40 #define _OSGVRMLFILE_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGFileIODef.h"
47 #include <map>
48 #include <stack>
49 #include <vector>
51 #include "OSGBaseTypes.h"
52 #include "OSGScanParseSkel.h"
53 #include "OSGScanParseFieldTypeMapper.h"
55 #include "OSGField.h"
56 #include "OSGFieldContainer.h"
58 #include "OSGVRMLPrototypeHandler.h"
60 OSG_BEGIN_NAMESPACE
62 /*! \ingroup GrpFileIOWRL
65 typedef VRMLNodePrototypeHandler<
66 ScanParseFieldTypeMapper<ScanParseSkel> > Parent;
68 /*! \brief VRML97 Loader (Geometry only)
69 \ingroup GrpFileIOWRL
70 \ingroup GrpLibOSGFileIO
73 class OSG_FILEIO_DLLMAPPING VRMLFile : public Parent
75 /*========================= PROTECTED ===============================*/
77 protected:
79 typedef Parent Inherited;
80 typedef VRMLFile Self;
82 /*========================== PUBLIC =================================*/
84 public:
86 enum
88 CreateNormals = Inherited::LastOption << 1,
89 StripeGeometry = CreateNormals << 1,
90 LogProtoGeneration = StripeGeometry << 1,
91 LogObjectGeneration = LogProtoGeneration << 1,
92 PushNames = LogObjectGeneration << 1,
94 LastOption = PushNames
97 /*---------------------------------------------------------------------*/
98 /*! \name Constructors */
99 /*! \{ */
101 VRMLFile(void);
103 /*! \} */
104 /*---------------------------------------------------------------------*/
105 /*! \name Destructor */
106 /*! \{ */
108 virtual ~VRMLFile(void);
110 /*! \} */
111 /*---------------------------------------------------------------------*/
112 /*! \name Skel replacements */
113 /*! \{ */
115 virtual NodeTransitPtr scanStream(std::istream &iStream);
117 /*! \} */
118 /*---------------------------------------------------------------------*/
119 /*! \name Skel replacements */
120 /*! \{ */
122 virtual bool checkHeader ( void );
124 virtual void handleError (void *pSelf, const Char8 *szErrorText);
126 virtual void beginProto (const Char8 *szProtoname);
127 virtual void endProtoInterface ( void);
128 virtual void endProto ( void);
130 virtual void beginFieldDecl(const Char8 *szFieldType,
131 const UInt32 uiFieldTypeId,
132 const Char8 *szFieldName);
134 virtual void endFieldDecl (void );
136 virtual void beginNode (const Char8 *szNodeTypename,
137 const Char8 *szNodename,
138 const BitVector bvLocalFlags );
140 virtual void endNode (void);
142 virtual void beginScript (const Char8 *szNodename);
144 virtual void endScript (void);
147 virtual void beginField (const Char8 *szFieldname,
148 const UInt32 uiFieldTypeId);
150 virtual void endField (void);
153 virtual void addFieldValue(const Char8 *szFieldVal);
155 virtual void addImageValue( Image *pImage );
158 virtual UInt32 getFieldType (const Char8 *szFieldname);
161 virtual void use (const Char8 *szName);
163 virtual void addRoute (const Char8 *szOutNodename,
164 const Char8 *szOutFieldname,
165 const Char8 *szInNodename,
166 const Char8 *szInFieldname );
168 /*! \} */
169 /*---------------------------------------------------------------------*/
170 /*! \name Helper */
171 /*! \{ */
173 void scanStandardPrototypes (const Char8 *szFilename);
175 void createStandardPrototypes(void);
177 /*! \} */
178 /*========================= PROTECTED ===============================*/
179 protected:
181 typedef std::map<std::string, FieldContainerUnrecPtr> NameContainerMap;
183 /*---------------------------------------------------------------------*/
184 /*! \name Member */
185 /*! \{ */
187 NodeUnrecPtr _pSceneRootNode;
189 VRMLNodeHelper * _pCurrNodeHelper;
190 std::stack<VRMLNodeHelper *> _sNodeHelpers;
192 FieldContainerUnrecPtr _pCurrentFC;
193 FieldContainer *_pCurrentFieldFC;
194 EditFieldHandlePtr _pCurrentField;
195 const FieldDescriptionBase *_pCurrentFieldDesc;
197 std::stack< FieldContainerUnrecPtr> _fcStack;
198 std::stack< EditFieldHandlePtr > _fStack;
199 std::stack<const FieldDescriptionBase *> _fdStack;
201 NameContainerMap _nameFCMap;
204 void initIntExtFieldTypeMapper(void);
205 void initExtIntFieldTypeMapper(void);
207 FieldContainer *findFCByName (const Char8 *szName,
208 Node *pNode);
210 FieldContainer *findReference (const Char8 *szName);
212 /*! \} */
213 /*========================== PRIVATE ================================*/
214 private:
216 /*!\brief prohibit default function (move to 'public' if needed) */
217 VRMLFile(const VRMLFile &source);
218 /*!\brief prohibit default function (move to 'public' if needed) */
219 void operator =(const VRMLFile &source);
222 OSG_END_NAMESPACE
224 #endif /* _OSGVRMLFILE_H_ */