1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2011 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 \*---------------------------------------------------------------------------*/
30 #include "OSGOSBVoidPAttachmentElement.h"
32 #include "OSGOSBRootElement.h"
33 #include "OSGVoidPAttachment.h"
37 /*-------------------------------------------------------------------------*/
38 /* OSBVoidPAttachmentElement */
39 /*-------------------------------------------------------------------------*/
41 /*-------------------------------------------------------------------------*/
44 OSBElementRegistrationHelper
<OSBVoidPAttachmentElement
>
45 OSBVoidPAttachmentElement::_regHelper
=
46 OSBElementRegistrationHelper
<OSBVoidPAttachmentElement
>("VoidPAttachment");
48 /*-------------------------------------------------------------------------*/
51 OSBVoidPAttachmentElement::OSBVoidPAttachmentElement(OSBRootElement
*root
)
52 : Inherited(root
, OSGOSBHeaderVersion200
)
56 /*-------------------------------------------------------------------------*/
59 OSBVoidPAttachmentElement::~OSBVoidPAttachmentElement(void)
63 /*-------------------------------------------------------------------------*/
67 OSBVoidPAttachmentElement::read(const std::string
&typeName
)
69 OSG_OSB_LOG(("OSBVoidPAttachmentElement::read [%s]\n", typeName
.c_str()));
71 OSBRootElement
*root
= editRoot();
72 BinaryReadHandler
*rh
= editRoot()->getReadHandler();
76 rh
->getValue(fcPtrType
);
77 rh
->getValue(version
);
79 setContainer(VoidPAttachmentUnrecPtr(VoidPAttachment::create()));
81 // keep these ordered from highest to lowest version
82 if(root
->getHeaderVersion() >= OSGOSBHeaderVersion200
)
84 if(root
->getHeaderVersion() > OSGOSBHeaderVersion200
)
86 FINFO(("OSBVoidPAttachmentElement::read: "
87 "Unknown header version, trying to read as latest.\n"));
92 else if(root
->getHeaderVersion() >= OSGOSBHeaderVersion100
)
94 // 1.x stores the address in 32 (!) chars and writes a string,
97 readFields("'data'", "");
102 OSBVoidPAttachmentElement::postRead(void)
106 /*-------------------------------------------------------------------------*/
110 OSBVoidPAttachmentElement::preWrite(FieldContainer
* const fc
)
112 OSG_OSB_LOG(("OSBVoidPAttachmentElement::preWrite\n"));
114 preWriteFieldContainer(fc
, "");
118 OSBVoidPAttachmentElement::write(void)
120 OSG_OSB_LOG(("OSBVoidPAttachmentElement::write\n"));
122 if(getContainer() == NULL
)
124 FWARNING(("OSBVoidPAttachmentElement::write: Attempt to write NULL.\n"));
128 BinaryWriteHandler
*wh
= editRoot()->getWriteHandler();
130 wh
->putValue(getFCPtrType(getContainer()));
131 wh
->putValue(getVersion() );
133 writeFields("", true);