1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 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 \*---------------------------------------------------------------------------*/
45 #include "OSGSystemDef.h"
46 #include "OSGBaseTypes.h"
47 #include "OSGScanParseSkel.h"
48 #include "OSGScanParseFieldTypeMapper.h"
52 #include "OSGFieldContainer.h"
53 #include "OSGFileContextAttachment.h"
55 #include "OSGDynamicAttachmentMixin.h"
63 class FileContextAttachment
;
65 /*! \ingroup GrpSystemFileIOOSG
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)
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 ================================*/
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
*,
120 typedef boost::function
<void(FieldContainer
* const,
121 FileContextAttachment
* const)> Functor
;
123 /*---------------------------------------------------------------------*/
124 /*! \name Constructors */
127 OSGLoader(const std::vector
<Functor
> & endNodeFunctors
,
128 FileContextAttachment
* const pFileContext
);
131 /*---------------------------------------------------------------------*/
132 /*! \name Destructor */
135 virtual ~OSGLoader(void);
138 /*---------------------------------------------------------------------*/
139 /*! \name Skel replacements */
142 NodeTransitPtr
scanStream (std::istream
&iStream
,
144 FieldContainerTransitPtr
scanStreamContainer(std::istream
&iStream
,
148 /*---------------------------------------------------------------------*/
149 /*! \name Skel replacements */
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 );
189 /*---------------------------------------------------------------------*/
193 virtual FieldContainer
*getReference (const Char8
*szName
);
196 /*========================= PROTECTED ===============================*/
200 /*---------------------------------------------------------------------*/
204 FieldContainerUnrecPtr _pCurrentFC
;
205 NodeUnrecPtr _pRootNode
;
206 FieldContainerUnrecPtr _pRootContainer
;
207 EditFieldHandlePtr _pCurrentField
;
208 const FieldDescriptionBase
*_pCurrentFieldDesc
;
210 bool _bReadContainer
;
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
);
228 /*========================== 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 //---------------------------------------------------------------------------
240 //---------------------------------------------------------------------------
244 typedef OSGLoader
*OSGLoaderP
;
248 #endif /* _OSGLOADER_H_ */