changed: gcc8 base update
[opensg.git] / Source / System / FileIO / OSB / OSGOSBCommonElement.h
blob6a7b57fbf0e74e67ab822d31dc1384010ae2e4bf
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 _OSGOSBCOMMONELEMENT_H_
40 #define _OSGOSBCOMMONELEMENT_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGOSBElementBase.h"
47 #include <string>
49 OSG_BEGIN_NAMESPACE
51 /*! \ingroup GrpFileIOOSB
52 \nohierarchy
55 class OSG_FILEIO_DLLMAPPING OSBCommonElement : public OSBElementBase
57 /*========================== PUBLIC =================================*/
58 public:
59 /*---------------------------------------------------------------------*/
60 /*! \name Types */
61 /*! \{ */
63 typedef OSBElementBase Inherited;
64 typedef OSBCommonElement Self;
66 /*! \} */
67 /*---------------------------------------------------------------------*/
68 /*! \name Constants */
69 /*! \{ */
71 static const UInt8 FCPtrUnknown;
72 static const UInt8 FCPtrFieldContainer;
73 static const UInt8 FCPtrNode;
74 static const UInt8 FCPtrNodeCore;
75 static const UInt8 FCPtrAttachment;
76 static const UInt8 FCPtrMaterial;
77 static const UInt8 FCPtrStateChunk;
79 /*! \} */
80 /*---------------------------------------------------------------------*/
81 /*! \name Constructor */
82 /*! \{ */
84 OSBCommonElement(OSBRootElement *root, UInt16 version);
86 /*! \} */
87 /*---------------------------------------------------------------------*/
88 /*! \name Destructor */
89 /*! \{ */
91 virtual ~OSBCommonElement(void);
93 /*! \} */
94 /*---------------------------------------------------------------------*/
95 /*! \name Reading */
96 /*! \{ */
98 virtual void read (const std::string &typeName) = 0;
99 virtual void postRead( void ) = 0;
100 virtual void postMap ( void );
102 /*! \} */
103 /*---------------------------------------------------------------------*/
104 /*! \name Writing */
105 /*! \{ */
107 virtual void preWrite(FieldContainer * const fc) = 0;
108 virtual void write (void ) = 0;
110 /*! \} */
111 /*========================= PROTECTED ===============================*/
112 protected:
113 /*---------------------------------------------------------------------*/
114 /*! \name Reading Helper methods */
115 /*! \{ */
117 bool readFieldContainerHeader(std::string &typeName,
118 UInt32 &fcId);
120 bool readFieldHeader (const std::string &endMarkers,
121 std::string &fieldName,
122 std::string &fieldTypeName,
123 UInt32 &fieldSize );
124 bool readFieldHeaderContinue(
125 const std::string &endMarkers,
126 const std::string &fieldName,
127 std::string &fieldTypeName,
128 UInt32 &fieldSize );
129 bool readFieldContent (const std::string &fieldName,
130 const std::string &fieldTypeName,
131 const UInt32 fieldSize,
132 const std::string &excludeFields,
133 PtrFieldListIt &ptrFieldIt );
134 std::string readFields (const std::string &excludeFields,
135 const std::string &endMarkers );
136 std::string readFieldsContinue (const std::string &fieldName,
137 const std::string &excludeFields,
138 const std::string &endMarkers );
139 void skipFields ( void );
140 PtrFieldListIt readPtrSingleField (const UInt32 fieldId );
141 PtrFieldListIt readPtrMultiField (const UInt32 fieldId,
142 const UInt32 fieldSize );
143 PtrFieldListIt readAttachmentMapField(const UInt32 fieldId,
144 const UInt32 fieldSize );
146 /*! \} */
147 /*---------------------------------------------------------------------*/
148 /*! \name Prewriting Helper Methods */
149 /*! \{ */
151 void preWritePtrSingleField (const UInt32 fieldId );
152 void preWritePtrMultiField (const UInt32 fieldId );
153 void preWriteAttachmentMapField(const UInt32 fieldId );
154 void preWriteMapField (const UInt32 fieldId );
155 void preWriteFieldContainer ( FieldContainer *fc,
156 const std::string &excludeFields);
158 /*! \} */
159 /*---------------------------------------------------------------------*/
160 /*! \name Writing Helper Methods */
161 /*! \{ */
163 void writeFieldContainerHeader(FieldContainer * const fc );
164 void writeFieldHeader (const std::string &fieldName,
165 const std::string &fieldTypeName,
166 const UInt32 fieldSize );
167 void writeFieldContent (const UInt32 fieldId );
168 void writeFields (const std::string &excludeFields,
169 const bool endMarker );
170 void writeEndMarker ( void );
172 /*! \} */
173 /*---------------------------------------------------------------------*/
174 /*! \name Map Helper Methods */
175 /*! \{ */
177 void handleAttachmentMapElementPreWrite(FieldContainer *refedFC);
178 void handleMapElementPreWrite (FieldContainer *refedFC);
180 /*! \} */
181 /*---------------------------------------------------------------------*/
182 /*! \name Misc Helper Methods */
183 /*! \{ */
186 FieldContainerTransitPtr
187 createReplacementFC(const UInt8 fcPtrType);
188 UInt8 getFCPtrType (FieldContainer * const container);
190 /*! \} */
191 /*========================== PRIVATE ================================*/
192 private:
193 /*!\brief prohibit default function (move to 'public' if needed) */
194 OSBCommonElement(const OSBCommonElement &source);
195 /*!\brief prohibit default function (move to 'public' if needed) */
196 void operator =(const OSBCommonElement &source);
199 OSG_END_NAMESPACE
201 #endif /* _OSGOSBCOMMONELEMENT_H_ */