1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2009 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 #include "OSGOSBGenericAttElement.h"
41 #include "OSGOSBRootElement.h"
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 /*-------------------------------------------------------------------------*/
57 OSBElementRegistrationHelper
<OSBGenericAttElement
>
58 OSBGenericAttElement::_regHelper
=
59 OSBElementRegistrationHelper
<OSBGenericAttElement
>("GenericAtt");
61 /*-------------------------------------------------------------------------*/
64 OSBGenericAttElement::OSBGenericAttElement(OSBRootElement
*root
)
65 : Inherited(root
, OSGOSBHeaderVersion200
)
69 /*-------------------------------------------------------------------------*/
72 OSBGenericAttElement::~OSBGenericAttElement(void)
76 /*-------------------------------------------------------------------------*/
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
90 // rh->getValue(ptrTypeTag);
91 rh
->getValue(version
);
93 OSG_OSB_LOG(("OSBGenericAttElement::read: version: [%u]\n", version
));
99 OSBGenericAttElement::postRead(void)
101 Inherited::postRead();
104 /*-------------------------------------------------------------------------*/
108 OSBGenericAttElement::preWrite(FieldContainer
* const fc
)
110 OSG_OSB_LOG(("OSBGenericAttElement::preWrite\n"));
112 preWriteFieldContainer(fc
, "");
116 OSBGenericAttElement::write(void)
118 OSG_OSB_LOG(("OSBGenericAttElement::write\n"));
120 if(getContainer() == NULL
)
122 FWARNING(("OSBGenericAttElement::write: Attempt to write NULL.\n"));
126 BinaryWriteHandler
*wh
= editRoot()->getWriteHandler();
128 wh
->putValue(getFCPtrType(getContainer()));
129 wh
->putValue(getVersion() );
131 writeFields("", true);