changed: gcc8 base update
[opensg.git] / Source / System / FileIO / OSB / OSGOSBNameElement.cpp
blob7b81b0da13626dc3bb8c23d878c6b9d8e73cb9c4
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2006 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 "OSGOSBNameElement.h"
41 #include "OSGOSBRootElement.h"
42 #include "OSGNameAttachment.h"
44 OSG_USING_NAMESPACE
46 /*-------------------------------------------------------------------------*/
47 /* OSBNameElement */
48 /*-------------------------------------------------------------------------*/
50 /*-------------------------------------------------------------------------*/
51 /* Static members */
53 OSBElementRegistrationHelper<OSBNameElement>
54 OSBNameElement::_regHelper =
55 OSBElementRegistrationHelper<OSBNameElement>("Name");
57 /*-------------------------------------------------------------------------*/
58 /* Constructor */
60 OSBNameElement::OSBNameElement(OSBRootElement *root)
61 : Inherited(root, OSGOSBHeaderVersion200)
65 /*-------------------------------------------------------------------------*/
66 /* Destructor */
68 OSBNameElement::~OSBNameElement(void)
72 /*-------------------------------------------------------------------------*/
73 /* Reading */
75 void
76 OSBNameElement::read(const std::string &typeName)
78 OSG_OSB_LOG(("OSBNameElement::read [%s]\n", typeName.c_str()));
80 BinaryReadHandler *rh = editRoot()->getReadHandler();
81 UInt8 fcPtrType;
82 UInt16 version;
84 rh->getValue(fcPtrType);
85 rh->getValue(version );
87 setContainer(NameUnrecPtr(Name::create()));
88 readFields("", "");
91 void
92 OSBNameElement::postRead(void)
96 /*-------------------------------------------------------------------------*/
97 /* Writing */
99 void
100 OSBNameElement::preWrite(FieldContainer * const fc)
102 OSG_OSB_LOG(("OSBNameElement::preWrite\n"));
104 preWriteFieldContainer(fc, "");
107 void
108 OSBNameElement::write(void)
110 OSG_OSB_LOG(("OSBNameElement::write\n"));
112 if(getContainer() == NULL)
114 FWARNING(("OSBNameElement::write: Attempt to write NULL.\n"));
115 return;
118 BinaryWriteHandler *wh = editRoot()->getWriteHandler();
120 wh->putValue(getFCPtrType(getContainer()));
121 wh->putValue(getVersion() );
123 writeFields("", true);