1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2007 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 _OSGOSBCOMMONELEMENT_H_
40 #define _OSGOSBCOMMONELEMENT_H_
45 #include "OSGOSBElementBase.h"
51 /*! \ingroup GrpFileIOOSB
55 class OSG_FILEIO_DLLMAPPING OSBCommonElement
: public OSBElementBase
57 /*========================== PUBLIC =================================*/
59 /*---------------------------------------------------------------------*/
63 typedef OSBElementBase Inherited
;
64 typedef OSBCommonElement Self
;
67 /*---------------------------------------------------------------------*/
68 /*! \name Constants */
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
;
80 /*---------------------------------------------------------------------*/
81 /*! \name Constructor */
84 OSBCommonElement(OSBRootElement
*root
, UInt16 version
);
87 /*---------------------------------------------------------------------*/
88 /*! \name Destructor */
91 virtual ~OSBCommonElement(void);
94 /*---------------------------------------------------------------------*/
98 virtual void read (const std::string
&typeName
) = 0;
99 virtual void postRead( void ) = 0;
100 virtual void postMap ( void );
103 /*---------------------------------------------------------------------*/
107 virtual void preWrite(FieldContainer
* const fc
) = 0;
108 virtual void write (void ) = 0;
111 /*========================= PROTECTED ===============================*/
113 /*---------------------------------------------------------------------*/
114 /*! \name Reading Helper methods */
117 bool readFieldContainerHeader(std::string
&typeName
,
120 bool readFieldHeader (const std::string
&endMarkers
,
121 std::string
&fieldName
,
122 std::string
&fieldTypeName
,
124 bool readFieldHeaderContinue(
125 const std::string
&endMarkers
,
126 const std::string
&fieldName
,
127 std::string
&fieldTypeName
,
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
);
147 /*---------------------------------------------------------------------*/
148 /*! \name Prewriting Helper Methods */
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
);
159 /*---------------------------------------------------------------------*/
160 /*! \name Writing Helper Methods */
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 );
173 /*---------------------------------------------------------------------*/
174 /*! \name Map Helper Methods */
177 void handleAttachmentMapElementPreWrite(FieldContainer
*refedFC
);
178 void handleMapElementPreWrite (FieldContainer
*refedFC
);
181 /*---------------------------------------------------------------------*/
182 /*! \name Misc Helper Methods */
186 FieldContainerTransitPtr
187 createReplacementFC(const UInt8 fcPtrType
);
188 UInt8
getFCPtrType (FieldContainer
* const container
);
191 /*========================== 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
);
201 #endif /* _OSGOSBCOMMONELEMENT_H_ */