fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / OSG / OSGOSGLoader.h
blob73652a0de5dffd43c67fea6839fa75ca4a531348
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 _OSGLOADER_H_
40 #define _OSGLOADER_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGSystemDef.h"
46 #include "OSGBaseTypes.h"
47 #include "OSGScanParseSkel.h"
48 #include "OSGScanParseFieldTypeMapper.h"
50 #include "OSGNode.h"
51 #include "OSGField.h"
52 #include "OSGFieldContainer.h"
53 #include "OSGFileContextAttachment.h"
55 #include "OSGDynamicAttachmentMixin.h"
57 #include <stack>
58 #include <map>
59 #include <string>
61 OSG_BEGIN_NAMESPACE
63 class FileContextAttachment;
65 /*! \ingroup GrpSystemFileIOOSG
66 \nohierarchy
69 struct OSGGenericAttDesc
71 typedef Attachment Parent;
72 typedef Attachment *ParentPtr;
74 static const Char8 *getTypeName (void) { return "OSGGenericAtt"; }
75 static const Char8 *getParentTypeName(void)
77 return "Attachment";
79 static const Char8 *getGroupName (void) { return "OSGGenAtt"; }
82 static InitContainerF getInitMethod(void) { return NULL; }
84 static FieldDescriptionBase **getDesc (void) { return NULL; }
87 /*! \ingroup GrpSystemFileIOOSG
90 typedef DynFieldAttachment<OSGGenericAttDesc> OSGGenericAtt;
92 /*! \ingroup GrpSystemFileIOOSG
94 typedef OSGGenericAtt::ObjUnrecPtr OSGGenericAttUnrecPtr;
97 /*! \brief native osg loader (vrml syntax)
98 \ingroup GrpSystemFileIOOSG
99 \ingroup GrpLibOSGSystem
102 class OSG_SYSTEM_DLLMAPPING OSGLoader :
103 public ScanParseFieldTypeMapper<ScanParseSkel>
105 /*========================== PRIVATE ================================*/
107 private:
109 typedef ScanParseFieldTypeMapper<ScanParseSkel > Inherited;
110 typedef std::map <std::string,
111 FieldContainerUnrecPtr> NamedFCMap;
112 typedef OSGLoader Self;
114 typedef boost::function<FieldContainer *(const Char8 *,
115 FieldContainer *,
116 Int32 )> Resolver;
118 public :
120 typedef boost::function<void(FieldContainer * const,
121 FileContextAttachment * const)> Functor;
123 /*---------------------------------------------------------------------*/
124 /*! \name Constructors */
125 /*! \{ */
127 OSGLoader(const std::vector<Functor> & endNodeFunctors,
128 FileContextAttachment * const pFileContext );
130 /*! \} */
131 /*---------------------------------------------------------------------*/
132 /*! \name Destructor */
133 /*! \{ */
135 virtual ~OSGLoader(void);
137 /*! \} */
138 /*---------------------------------------------------------------------*/
139 /*! \name Skel replacements */
140 /*! \{ */
142 NodeTransitPtr scanStream (std::istream &iStream,
143 Resolver fResolver);
144 FieldContainerTransitPtr scanStreamContainer(std::istream &iStream,
145 Resolver fResolver);
147 /*! \} */
148 /*---------------------------------------------------------------------*/
149 /*! \name Skel replacements */
150 /*! \{ */
152 virtual bool checkHeader ( void );
154 virtual void beginNode (const Char8 *szNodeTypename,
155 const Char8 *szNodename,
156 const BitVector bvLocalFlags );
158 virtual void endNode (void);
160 virtual void nullNode (void);
162 virtual void use (const Char8 *szName );
164 virtual void beginField (const Char8 *szFieldname,
165 const UInt32 uiFieldTypeId );
167 virtual void endField (void );
169 virtual void addFieldValue (const Char8 *szFieldVal );
171 virtual Int32 mapExtIntFieldType(const Char8 *szFieldname,
172 const Int32 iFieldTypeId );
174 virtual UInt32 getFieldType (const Char8 *szFieldname );
176 virtual void addRoute (const Char8 *szOutNodename,
177 const Char8 *szOutFieldname,
178 const Char8 *szInNodename,
179 const Char8 *szInFieldname );
181 virtual void beginFieldDecl (const Char8 *szFieldType,
182 const UInt32 uiFieldTypeId,
183 const Char8 *szFieldName );
185 virtual void endFieldDecl ( void );
188 /*! \} */
189 /*---------------------------------------------------------------------*/
190 /*! \name Get */
191 /*! \{ */
193 virtual FieldContainer *getReference (const Char8 *szName);
195 /*! \} */
196 /*========================= PROTECTED ===============================*/
198 protected:
200 /*---------------------------------------------------------------------*/
201 /*! \name Member */
202 /*! \{ */
204 FieldContainerUnrecPtr _pCurrentFC;
205 NodeUnrecPtr _pRootNode;
206 FieldContainerUnrecPtr _pRootContainer;
207 EditFieldHandlePtr _pCurrentField;
208 const FieldDescriptionBase *_pCurrentFieldDesc;
209 NamedFCMap _defMap;
210 bool _bReadContainer;
211 Resolver _fResolver;
212 const std::vector<Functor> &_endNodeFunctors;
214 std::stack< FieldContainerUnrecPtr> _fcStack;
215 std::stack< EditFieldHandlePtr > _fStack;
216 std::stack<const FieldDescriptionBase *> _fdStack;
218 BitVector _bvChanged;
219 std::stack< BitVector > _sChangedStack;
221 FileContextAttachmentUnrecPtr _pFileContext;
223 void initFieldTypeMapper ( void );
225 void setFieldContainerValue( FieldContainer *pNewNode);
227 /*! \} */
228 /*========================== PRIVATE ================================*/
230 private:
232 /*!\brief prohibit default function (move to 'public' if needed) */
233 OSGLoader(const OSGLoader &source);
234 /*!\brief prohibit default function (move to 'public' if needed) */
235 void operator =(const OSGLoader &source);
238 //---------------------------------------------------------------------------
239 // Exported Types
240 //---------------------------------------------------------------------------
242 // class pointer
244 typedef OSGLoader *OSGLoaderP;
246 OSG_END_NAMESPACE
248 #endif /* _OSGLOADER_H_ */