changed: gcc8 base update
[opensg.git] / Source / System / FileIO / OSB / OSGOSBGenericAttElement.cpp
blob8d7cecfb7cfa788c0567c849eb68d33f8415f1ae
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2009 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 #include "OSGOSBGenericAttElement.h"
41 #include "OSGOSBRootElement.h"
43 OSG_USING_NAMESPACE
45 /*-------------------------------------------------------------------------*/
46 /* OSBGenericAttElement */
47 /*-------------------------------------------------------------------------*/
49 /*! Skips a 1.x GenericAtt attachment in the stream. This is not handled
50 correctly by the GenericElement, because the GenericAtt has a header
51 format that is inconsistent with other elements.
54 /*-------------------------------------------------------------------------*/
55 /* Static members */
57 OSBElementRegistrationHelper<OSBGenericAttElement>
58 OSBGenericAttElement::_regHelper =
59 OSBElementRegistrationHelper<OSBGenericAttElement>("GenericAtt");
61 /*-------------------------------------------------------------------------*/
62 /* Constructor */
64 OSBGenericAttElement::OSBGenericAttElement(OSBRootElement *root)
65 : Inherited(root, OSGOSBHeaderVersion200)
69 /*-------------------------------------------------------------------------*/
70 /* Destructor */
72 OSBGenericAttElement::~OSBGenericAttElement(void)
76 /*-------------------------------------------------------------------------*/
77 /* Reading */
79 void
80 OSBGenericAttElement::read(const std::string &typeName)
82 OSG_OSB_LOG(("OSBGenericAttElement::read: [%s]\n", typeName.c_str()));
84 BinaryReadHandler *rh = editRoot()->getReadHandler();
86 // GenericAtt only exists in 1.x osb files, but has no ptrTypeTag
87 // UInt8 ptrTypeTag;
88 UInt16 version;
90 // rh->getValue(ptrTypeTag);
91 rh->getValue(version );
93 OSG_OSB_LOG(("OSBGenericAttElement::read: version: [%u]\n", version));
95 skipFields();
98 void
99 OSBGenericAttElement::postRead(void)
101 Inherited::postRead();
104 /*-------------------------------------------------------------------------*/
105 /* Writing */
107 void
108 OSBGenericAttElement::preWrite(FieldContainer * const fc)
110 OSG_OSB_LOG(("OSBGenericAttElement::preWrite\n"));
112 preWriteFieldContainer(fc, "");
115 void
116 OSBGenericAttElement::write(void)
118 OSG_OSB_LOG(("OSBGenericAttElement::write\n"));
120 if(getContainer() == NULL)
122 FWARNING(("OSBGenericAttElement::write: Attempt to write NULL.\n"));
123 return;
126 BinaryWriteHandler *wh = editRoot()->getWriteHandler();
128 wh->putValue(getFCPtrType(getContainer()));
129 wh->putValue(getVersion() );
131 writeFields("", true);