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 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGOSGSCENEFILETYPE_H_
40 #define _OSGOSGSCENEFILETYPE_H_
45 #include "boost/function.hpp"
47 #include "OSGBaseTypes.h"
48 #include "OSGSceneFileType.h"
54 class FileContextAttachment
;
56 /*! \brief OSGSceneFileType
57 \ingroup GrpSystemFileIOOSG
58 \ingroup GrpLibOSGSystem
61 class OSG_SYSTEM_DLLMAPPING OSGSceneFileType
: public SceneFileType
63 /*========================== PUBLIC =================================*/
67 typedef boost::function
<void(FieldContainer
* const,
68 FileContextAttachment
* const)> Functor
;
70 typedef void (FieldContainer::*Callback
)(FileContextAttachment
* const);
73 struct PostLoadingDispatcher
75 PostLoadingDispatcher(void) { }
77 void dispatch(FieldContainer
* pTarget
,
78 FileContextAttachment
* const pContext
)
80 static_cast<T
*>(pTarget
)->postOSGLoading(pContext
);
84 /*---------------------------------------------------------------------*/
85 /*! \name Class Get */
88 static OSGSceneFileType
&the(void);
91 /*---------------------------------------------------------------------*/
92 /*! \name Destructor */
95 virtual ~OSGSceneFileType (void);
97 /*---------------------------------------------------------------------*/
101 virtual const Char8
*getName(void) const;
104 /*---------------------------------------------------------------------*/
108 virtual NodeTransitPtr
read( std::istream
&is
,
109 const Char8
*fileNameOrExtension
,
110 Resolver resolver
= NULL
) const;
114 /*---------------------------------------------------------------------*/
119 FieldContainerTransitPtr
readContainer(
120 const Char8
*fileName
,
121 Resolver resolver
= NULL
) const;
124 /*---------------------------------------------------------------------*/
128 virtual bool write(Node
* const node
,
130 Char8
const *fileNameOrExtension
) const;
133 /*---------------------------------------------------------------------*/
137 virtual bool writeContainer(FieldContainer
* const pContainer
,
138 Char8
const *fileName
) const;
141 /*---------------------------------------------------------------------*/
145 void registerEndNodeCallback(const FieldContainerType
&type
,
146 const Functor
&func
);
149 /*========================= PROTECTED ===============================*/
153 /*---------------------------------------------------------------------*/
157 static const Char8
*_suffixA
[];
158 static OSGSceneFileType _the
;
160 std::vector
<Functor
> _endNodeFunctors
;
163 /*---------------------------------------------------------------------*/
164 /*! \name Constructors */
167 OSGSceneFileType(const Char8
*suffixArray
[],
168 UInt16 suffixByteCount
,
170 UInt32 overridePriority
,
174 /*---------------------------------------------------------------------*/
175 /*! \name Termination */
178 virtual void terminate(void);
181 /*========================== PRIVATE ================================*/
185 typedef SceneFileType Inherited
;
187 /*!\brief prohibit default function (move to 'public' if needed) */
188 OSGSceneFileType(const OSGSceneFileType
&source
);
189 /*!\brief prohibit default function (move to 'public' if needed) */
190 void operator =(const OSGSceneFileType
&source
);
193 //---------------------------------------------------------------------------
195 //---------------------------------------------------------------------------
199 #endif /* _OSGOSGSCENEFILETYPE_H_ */