fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / FileIO / OSB / OSGOSBRootElement.h
blob6a5b2ccf775155d7c41d01bdddb01cba70d913ad
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2007 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 _OSGOSBROOTELEMENT_H_
40 #define _OSGOSBROOTELEMENT_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGOSBCommonElement.h"
46 #include "OSGOSBElementFactoryHelper.h"
47 #include "OSGNFIOOptions.h"
48 #include "OSGBinaryDataHandler.h"
50 // TODO: Add infrastructure for file level and element level options
51 // Keep it simple: Option object serializes to a string and must be able
52 // to parse that string.
54 OSG_BEGIN_NAMESPACE
56 /*! \ingroup GrpFileIOOSB
57 \nohierarchy
60 class OSG_FILEIO_DLLMAPPING OSBRootElement : public OSBCommonElement
62 /*========================== PUBLIC =================================*/
63 public:
64 /*---------------------------------------------------------------------*/
65 /*! \name Types */
66 /*! \{ */
68 typedef OSBCommonElement Inherited;
69 typedef OSBRootElement Self;
71 typedef Inherited::BinaryReadHandler BinaryReadHandler;
72 typedef Inherited::BinaryWriteHandler BinaryWriteHandler;
74 typedef Inherited::PtrFieldList PtrFieldList;
75 typedef Inherited::PtrFieldListIt PtrFieldListIt;
76 typedef Inherited::PtrFieldListConstIt PtrFieldListConstIt;
78 typedef Inherited::FieldContainerIdMap FieldContainerIdMap;
79 typedef Inherited::FieldContainerIdMapIt FieldContainerIdMapIt;
80 typedef Inherited::FieldContainerIdMapConstIt FieldContainerIdMapConstIt;
82 typedef Inherited::FieldContainerList FieldContainerList;
83 typedef Inherited::FieldContainerListIt FieldContainerListIt;
84 typedef Inherited::FieldContainerListConstIt FieldContainerListConstIt;
86 typedef Inherited::FieldContainerIdSet FieldContainerIdSet;
87 typedef Inherited::FieldContainerIdSetIt FieldContainerIdSetIt;
88 typedef Inherited::FieldContainerIdSetConstIt FieldContainerIdSetConstIt;
90 typedef std::list<OSBElementBase *> ElementList;
91 typedef ElementList::iterator ElementListIt;
92 typedef ElementList::const_iterator ElementListConstIt;
94 typedef std::map<UInt32, OSBElementBase *> IdElemMap;
95 typedef IdElemMap::iterator IdElemMapIt;
96 typedef IdElemMap::const_iterator IdElemMapConstIt;
98 /*! \} */
99 /*---------------------------------------------------------------------*/
100 /*! \name Constructor */
101 /*! \{ */
103 OSBRootElement(OSBRootElement *root);
105 /*! \} */
106 /*---------------------------------------------------------------------*/
107 /*! \name Destructor */
108 /*! \{ */
110 virtual ~OSBRootElement(void);
112 /*! \} */
113 /*---------------------------------------------------------------------*/
114 /*! \name Reading */
115 /*! \{ */
117 void initialiseRead( std::istream &inStream);
118 void terminateRead ( void );
120 virtual void read (const std::string &typeName);
121 virtual void postRead ( void );
122 virtual void postMap ( void );
124 /*! \} */
125 /*---------------------------------------------------------------------*/
126 /*! \name Writing */
127 /*! \{ */
129 void initialiseWrite(std::ostream &outStream);
130 void terminateWrite (void );
132 virtual void preWrite (FieldContainer * const fc);
133 virtual void write (void );
135 /*! \} */
136 /*---------------------------------------------------------------------*/
137 /*! \name State access */
138 /*! \{ */
140 inline BinaryReadHandler *getReadHandler (void);
141 inline BinaryWriteHandler *getWriteHandler (void);
143 inline const NFIOOptions &getOptions (void) const;
144 inline NFIOOptions &editOptions (void);
146 inline void setHeaderVersion (const UInt16 version);
147 inline UInt16 getHeaderVersion (void) const;
149 inline const FieldContainerIdMap &getIdMap (void) const;
150 inline FieldContainerIdMap &editIdMap (void);
152 inline const PtrFieldList &getPtrFieldList (void) const;
153 inline PtrFieldList &editPtrFieldList (void);
155 inline const ElementList &getElementList (void) const;
156 inline ElementList &editElementList (void);
158 inline const IdElemMap &getIdElemMap (void) const;
159 inline IdElemMap &editIdElemMap (void);
161 inline const FieldContainerList &getContainerList (void) const;
162 inline FieldContainerList &editContainerList(void);
164 inline const FieldContainerIdSet &getIdSet (void) const;
165 inline FieldContainerIdSet &editIdSet (void);
167 /*! \} */
168 /*========================= PROTECTED ===============================*/
169 protected:
171 /*---------------------------------------------------------------------*/
172 /*! \name Helper methods */
173 /*! \{ */
175 void mapPtrField(const PtrFieldInfo &ptrField);
177 void dumpIdMap(void) const;
179 /*! \} */
180 /*---------------------------------------------------------------------*/
182 static OSBElementRegistrationHelper<OSBRootElement> _regHelper;
184 BinaryReadHandler *_readHandler;
185 BinaryWriteHandler *_writeHandler;
187 NFIOOptions _options;
188 ElementList _elements;
189 IdElemMap _idElemMap;
191 UInt16 _readHeaderVersion;
192 FieldContainerIdMap _readIdMap;
193 PtrFieldList _readPtrFields;
195 FieldContainerList _writeFCList;
196 FieldContainerIdSet _writeIdSet;
198 private:
200 OSBRootElement(const OSBRootElement &other);
201 void operator =(const OSBRootElement &rhs);
204 OSG_END_NAMESPACE
206 #include "OSGOSBRootElement.inl"
208 #endif /* _OSGOSBROOTELEMENT_H_ */