00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifdef OSG_DOC_FILES_IN_MODULE
00040
00043 #endif
00044
00045 #define OSG_COMPILESIMPLEATTACHMENTSINST
00046
00047 #include <stdlib.h>
00048 #include <stdio.h>
00049
00050 #include "OSGConfig.h"
00051
00052 #include "OSGAttachmentContainer.h"
00053 #include "OSGSimpleAttachments.h"
00054
00055 OSG_USING_NAMESPACE
00056
00057
00058 #ifdef WIN32
00059 OSG_FC_TYPE_FUNCTIONS_INL_TMPL_DEF(AttachmentDescT,
00060 SimpleAttachment);
00061 #endif
00062
00063
00064
00065
00066 FieldDescription *NameAttachmentDesc::_desc[] =
00067 {
00068 new FieldDescription(
00069 FieldTypeT::getClassType(),
00070 getFieldName(),
00071 OSG_FC_FIELD_IDM_DESC(
00072 SimpleAttachment<NameAttachmentDesc>::SimpleField),
00073 false,
00074 (FieldAccessMethod) &SimpleAttachment<
00075 NameAttachmentDesc>::getFieldPtr)
00076 };
00077
00078 OSG_BEGIN_NAMESPACE
00079
00080 OSG_FC_DLLEXPORT_DEF(SimpleAttachment,
00081 NameAttachmentDesc,
00082 OSG_SYSTEMLIB_DLLTMPLMAPPING);
00083
00084 OSG_END_NAMESPACE
00085
00086
00087
00088
00089 FieldDescription *VoidPAttachmentDesc::_desc[] =
00090 {
00091 new FieldDescription(
00092 FieldTypeT::getClassType(),
00093 getFieldName(),
00094 OSG_FC_FIELD_IDM_DESC(
00095 SimpleAttachment<VoidPAttachmentDesc>::SimpleField),
00096 false,
00097 (FieldAccessMethod) &SimpleAttachment<
00098 VoidPAttachmentDesc>::getFieldPtr)
00099 };
00100
00101 OSG_BEGIN_NAMESPACE
00102
00103 OSG_FC_DLLEXPORT_DEF(SimpleAttachment,
00104 VoidPAttachmentDesc,
00105 OSG_SYSTEMLIB_DLLTMPLMAPPING);
00106
00107
00108
00109
00110
00116 const Char8 *getName(AttachmentContainerPtr container)
00117 {
00118 if(container == NullFC)
00119 return NULL;
00120
00121
00122 AttachmentPtr att =
00123 container->findAttachment(Name::getClassType().getGroupId());
00124
00125 if(att == NullFC)
00126 return NULL;
00127
00128
00129
00130 NamePtr name = NamePtr::dcast(att);
00131
00132 if(name == NullFC)
00133 return NULL;
00134
00135 return name->getFieldPtr()->getValue().c_str();
00136 }
00137
00142 void setName( AttachmentContainerPtr container,
00143 const std::string &namestring)
00144 {
00145 if(container == NullFC)
00146 {
00147 FFATAL(("setName: no container?!?\n"));
00148 return;
00149 }
00150
00151
00152
00153 NamePtr name = NullFC;
00154 AttachmentPtr att =
00155 container->findAttachment(Name::getClassType().getGroupId());
00156
00157 if(att == NullFC)
00158 {
00159 name = Name::create();
00160 beginEditCP(container, AttachmentContainer::AttachmentsFieldMask);
00161 {
00162 container->addAttachment(name);
00163 }
00164 endEditCP(container, AttachmentContainer::AttachmentsFieldMask);
00165 }
00166 else
00167 {
00168 name = NamePtr::dcast(att);
00169
00170 if(name == NullFC)
00171 {
00172 FFATAL(("setName: Name Attachment is not castable to Name?!?\n"));
00173 return;
00174 }
00175 }
00176
00177
00178 beginEditCP(name);
00179 {
00180 name->getFieldPtr()->getValue().assign(namestring);
00181 }
00182 endEditCP(name);
00183 }
00184
00191 void setName(AttachmentContainerPtr container, const Char8 *name)
00192 {
00193 if(name == NULL)
00194 {
00195 AttachmentPtr att =
00196 container->findAttachment(Name::getClassType().getGroupId());
00197
00198 if(att != NullFC)
00199 {
00200 container->subAttachment(att);
00201 }
00202 }
00203 else
00204 {
00205 setName(container, std::string(name));
00206 }
00207 }
00208
00209
00210
00211
00212
00218 void *getVoidP(AttachmentContainerPtr container)
00219 {
00220 if(container == NullFC)
00221 return NULL;
00222
00223
00224 AttachmentPtr att =
00225 container->findAttachment(VoidPAttachment::getClassType().getGroupId());
00226
00227 if(att == NullFC)
00228 return NULL;
00229
00230
00231
00232 VoidPAttachmentPtr pVoid = VoidPAttachmentPtr::dcast(att);
00233
00234 if(pVoid == NullFC)
00235 return NULL;
00236
00237 return pVoid->getFieldPtr()->getValue();
00238 }
00239
00245 void setVoidP(AttachmentContainerPtr container,
00246 void *pData,
00247 bool internal )
00248 {
00249 if(container == NullFC)
00250 {
00251 FFATAL(("setVoidP: no container?!?\n"));
00252 return;
00253 }
00254
00255
00256
00257 VoidPAttachmentPtr pVoid = NullFC;
00258 AttachmentPtr att =
00259 container->findAttachment(VoidPAttachment::getClassType().getGroupId());
00260
00261 if(att == NullFC)
00262 {
00263 pVoid = VoidPAttachment::create();
00264 container->addAttachment(pVoid);
00265 }
00266 else
00267 {
00268 pVoid = VoidPAttachmentPtr::dcast(att);
00269
00270 if(pVoid == NullFC)
00271 {
00272 FFATAL(("setVoidP: VoidP Attachment is not castable "
00273 "to VoidPAttachment?!?\n"));
00274 return;
00275 }
00276 }
00277
00278 pVoid->setInternal(internal);
00279 pVoid->getFieldPtr()->setValue(pData);
00280 }
00281
00282 OSG_END_NAMESPACE
00283
00284
00285
00286
00287
00288 #ifdef __sgi
00289 #pragma set woff 1174
00290 #endif
00291
00292 #ifdef OSG_LINUX_ICC
00293 #pragma warning( disable : 177 )
00294 #endif
00295
00296 namespace
00297 {
00298 static Char8 cvsid_cpp[] = "@(#)$Id: $";
00299 static Char8 cvsid_hpp[] = OSGSIMPLEATTACHMENTS_HEADER_CVSID;
00300 }
00301