fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / OSG / OSGOSGSceneFileType.h
blob2f4a1cc052589413a9059032950a99ff30b5d29e
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 _OSGOSGSCENEFILETYPE_H_
40 #define _OSGOSGSCENEFILETYPE_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "boost/function.hpp"
47 #include "OSGBaseTypes.h"
48 #include "OSGSceneFileType.h"
50 OSG_BEGIN_NAMESPACE
52 class OSGLoader;
53 class FieldContainer;
54 class FileContextAttachment;
56 /*! \brief OSGSceneFileType
57 \ingroup GrpSystemFileIOOSG
58 \ingroup GrpLibOSGSystem
61 class OSG_SYSTEM_DLLMAPPING OSGSceneFileType : public SceneFileType
63 /*========================== PUBLIC =================================*/
65 public:
67 typedef boost::function<void(FieldContainer * const,
68 FileContextAttachment * const)> Functor;
70 typedef void (FieldContainer::*Callback)(FileContextAttachment * const);
72 template <class T>
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 */
86 /*! \{ */
88 static OSGSceneFileType &the(void);
90 /*! \} */
91 /*---------------------------------------------------------------------*/
92 /*! \name Destructor */
93 /*! \{ */
95 virtual ~OSGSceneFileType (void);
97 /*---------------------------------------------------------------------*/
98 /*! \name Get */
99 /*! \{ */
101 virtual const Char8 *getName(void) const;
103 /*! \} */
104 /*---------------------------------------------------------------------*/
105 /*! \name Read */
106 /*! \{ */
108 virtual NodeTransitPtr read( std::istream &is,
109 const Char8 *fileNameOrExtension,
110 Resolver resolver = NULL ) const;
113 /*! \} */
114 /*---------------------------------------------------------------------*/
115 /*! \name Read */
116 /*! \{ */
118 virtual
119 FieldContainerTransitPtr readContainer(
120 const Char8 *fileName,
121 Resolver resolver = NULL) const;
123 /*! \} */
124 /*---------------------------------------------------------------------*/
125 /*! \name Write */
126 /*! \{ */
128 virtual bool write(Node * const node,
129 std::ostream &os,
130 Char8 const *fileNameOrExtension) const;
132 /*! \} */
133 /*---------------------------------------------------------------------*/
134 /*! \name Write */
135 /*! \{ */
137 virtual bool writeContainer(FieldContainer * const pContainer,
138 Char8 const *fileName ) const;
140 /*! \} */
141 /*---------------------------------------------------------------------*/
142 /*! \name Write */
143 /*! \{ */
145 void registerEndNodeCallback(const FieldContainerType &type,
146 const Functor &func);
148 /*! \} */
149 /*========================= PROTECTED ===============================*/
151 protected:
153 /*---------------------------------------------------------------------*/
154 /*! \name Member */
155 /*! \{ */
157 static const Char8 *_suffixA[];
158 static OSGSceneFileType _the;
160 std::vector<Functor> _endNodeFunctors;
162 /*! \} */
163 /*---------------------------------------------------------------------*/
164 /*! \name Constructors */
165 /*! \{ */
167 OSGSceneFileType(const Char8 *suffixArray[],
168 UInt16 suffixByteCount,
169 bool override,
170 UInt32 overridePriority,
171 UInt32 flags);
173 /*! \} */
174 /*---------------------------------------------------------------------*/
175 /*! \name Termination */
176 /*! \{ */
178 virtual void terminate(void);
180 /*! \} */
181 /*========================== PRIVATE ================================*/
183 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 //---------------------------------------------------------------------------
194 // Exported Types
195 //---------------------------------------------------------------------------
197 OSG_END_NAMESPACE
199 #endif /* _OSGOSGSCENEFILETYPE_H_ */