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 "OSGVoidPAttachment.h"
49 OSG_SIMPLEATTACHMENT_INST(VoidPAttachmentDesc
);
52 SimpleAttachment
<VoidPAttachmentDesc
>::TypeObject
&
53 SimpleAttachment
<VoidPAttachmentDesc
>::getType(void)
59 const SimpleAttachment
<VoidPAttachmentDesc
>::TypeObject
&
60 SimpleAttachment
<VoidPAttachmentDesc
>::getType(void) const
66 SimpleAttachment
<VoidPAttachmentDesc
>::TypeObject
&
67 SimpleAttachment
<VoidPAttachmentDesc
>::getClassType(void)
72 /*-------------------------------------------------------------------------*/
73 /* Name Attachment Utility Functions */
76 Return the void * attached to the container, NULL if none attached or
80 void *getVoidP(AttachmentContainer
* const pContainer
)
82 if(pContainer
== NULL
)
85 // Get attachment pointer
87 pContainer
->findAttachment(
88 VoidPAttachment::getClassType().getGroupId());
93 // Cast to name pointer
95 VoidPAttachment
*voidP
= dynamic_cast<VoidPAttachment
*>(att
);
100 return voidP
->getFieldPtr()->getValue();
104 /*! Set the name attached to the container. If the container doesn't have a
105 name attachement yet one is created.
108 void setVoidP(AttachmentContainer
* const pContainer
,
112 if(pContainer
== NULL
)
114 FFATAL(("setVoidP: no container?!?"));
118 // Get attachment pointer
120 VoidPAttachmentUnrecPtr voidP
= NULL
;
122 pContainer
->findAttachment(
123 VoidPAttachment::getClassType().getGroupId());
127 voidP
= VoidPAttachment::create();
129 pContainer
->addAttachment(voidP
);
133 voidP
= dynamic_cast<VoidPAttachment
*>(att
);
137 FFATAL(("setVoidP: VoidP Attachment is not castable to Name?!?"));
142 voidP
->editFieldPtr()->setValue(pData
);
143 voidP
->setInternal(bInternal
);