1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000,2001,2002 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 \*---------------------------------------------------------------------------*/
42 #include "OSGConfig.h"
44 #include "OSGAttachmentContainer.h"
45 #include "OSGNameAttachment.h"
49 OSG_SIMPLEATTACHMENT_INST(NameAttachmentDesc
);
52 SimpleAttachment
<NameAttachmentDesc
>::TypeObject
&
53 SimpleAttachment
<NameAttachmentDesc
>::getType(void)
59 const SimpleAttachment
<NameAttachmentDesc
>::TypeObject
&
60 SimpleAttachment
<NameAttachmentDesc
>::getType(void) const
66 SimpleAttachment
<NameAttachmentDesc
>::TypeObject
&
67 SimpleAttachment
<NameAttachmentDesc
>::getClassType(void)
72 /*-------------------------------------------------------------------------*/
73 /* Name Attachment Utility Functions */
76 Return the name attached to the container, NULL if none attached or
80 const Char8
*getName(AttachmentContainer
const * const pContainer
)
82 if(pContainer
== NULL
)
85 // Get attachment pointer
87 pContainer
->findAttachment(Name::getClassType().getGroupId());
92 // Cast to name pointer
94 Name
*name
= dynamic_cast<Name
*>(att
);
99 return name
->getFieldPtr()->getValue().c_str();
102 /*! Set the name attached to the container. If the container doesn't have a
103 name attachement yet one is created.
106 void setName(AttachmentContainer
* const pContainer
,
107 std::string
const &namestring
)
109 if(pContainer
== NULL
)
111 FFATAL(("setName: no container?!?\n"));
115 // Get attachment pointer
117 NameUnrecPtr name
= NULL
;
119 pContainer
->findAttachment(Name::getClassType().getGroupId());
123 name
= Name::createDependent(
124 pContainer
->getFieldFlags()->_bNamespaceMask
);
126 pContainer
->addAttachment(name
);
130 name
= dynamic_cast<Name
*>(att
);
134 FFATAL(("setName: Name Attachment is not castable to Name?!?\n"));
140 name
->editFieldPtr()->getValue().assign(namestring
);
144 Set the name attached to the container. If the container doesn't have
145 name attachement yet one is created. If the name is NULL, an attached
149 void setName(AttachmentContainer
* const pContainer
, const Char8
*name
)
154 pContainer
->findAttachment(Name::getClassType().getGroupId());
158 pContainer
->subAttachment(att
);
163 setName(pContainer
, std::string(name
));