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
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #include <OSGConfig.h>
00047
00048 #include "OSGStringAttributeMap.h"
00049
00050 OSG_USING_NAMESPACE
00051
00052
00053
00054
00055
00062
00063
00064
00065
00066
00067
00068
00069
00070 void StringAttributeMap::initMethod (void)
00071 {
00072 }
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 StringAttributeMap::StringAttributeMap(void) :
00086 Inherited()
00087 {
00088 }
00089
00090 StringAttributeMap::StringAttributeMap(const StringAttributeMap &source) :
00091 Inherited(source)
00092 {
00093 }
00094
00095 StringAttributeMap::~StringAttributeMap(void)
00096 {
00097 }
00098
00099
00100
00101 void StringAttributeMap::changed(BitVector whichField, UInt32 origin)
00102 {
00103 Inherited::changed(whichField, origin);
00104 }
00105
00106 void StringAttributeMap::dump( UInt32 ,
00107 const BitVector ) const
00108 {
00109 SLOG << "Dump StringAttributeMap NI" << std::endl;
00110 }
00111
00122 void StringAttributeMap::setAttribute(const std::string& key,
00123 const std::string& value)
00124 {
00125 MFString& keys = this->StringAttributeMapBase::getKeys();
00126 MFString& values = this->StringAttributeMapBase::getValues();
00127
00128 unsigned int index(0);
00129
00130
00131
00132 for ( MFString::iterator i = keys.begin(); i != keys.end(); ++i, ++index )
00133 {
00134 if ( *i == key )
00135 {
00136 values[index] = value;
00137 return;
00138 }
00139 }
00140
00141
00142
00143 keys.push_back(key);
00144 values.push_back(value);
00145 }
00146
00153 bool StringAttributeMap::getAttribute(const std::string& key,
00154 std::string& value)
00155 const
00156 {
00157 if ( hasAttribute(key) )
00158 {
00159 const MFString& keys = this->StringAttributeMapBase::getKeys();
00160 const MFString& values = this->StringAttributeMapBase::getValues();
00161
00162
00163
00164 unsigned int index(0);
00165 MFString::const_iterator i;
00166 for ( i = keys.begin(); i != keys.end(); ++i, ++index )
00167 {
00168 if ( *i == key )
00169 {
00170
00171 value = values[index];
00172 return true;
00173 }
00174 }
00175 }
00176
00177
00178 return false;
00179 }
00180
00181
00182
00183
00184 OSG_BEGIN_NAMESPACE
00185
00195 StringAttributeMapPtr stringAttributeMap(AttachmentContainerPtr container)
00196 {
00197 if ( NullFC == container )
00198 {
00199 FFATAL(("stringAttributeMap: no container?!?\n"));
00200 return NullFC;
00201 }
00202
00203 StringAttributeMapPtr attr_map = NullFC;
00204 AttachmentPtr attach_ptr =
00205 container->findAttachment(StringAttributeMap::getClassType().getGroupId());
00206
00207 if ( NullFC == attach_ptr )
00208 {
00209 attr_map = StringAttributeMap::create();
00210 beginEditCP(container, AttachmentContainer::AttachmentsFieldMask);
00211 container->addAttachment(attr_map);
00212 endEditCP(container, AttachmentContainer::AttachmentsFieldMask);
00213 }
00214 else
00215 {
00216 attr_map = StringAttributeMapPtr::dcast(attach_ptr);
00217
00218 if ( NullFC == attr_map )
00219 {
00220 FFATAL(("stringAttributeMap: StringAttributeMap Attachment is not castable to StringAttributeMap?!?\n"));
00221 return NullFC;
00222 }
00223 }
00224
00225 return attr_map;
00226 }
00227
00228 OSG_END_NAMESPACE
00229
00230
00231
00232
00233 #ifdef OSG_SGI_CC
00234 #pragma set woff 1174
00235 #endif
00236
00237 #ifdef OSG_LINUX_ICC
00238 #pragma warning( disable : 177 )
00239 #endif
00240
00241 namespace
00242 {
00243 static Char8 cvsid_cpp [] = "@(#)$Id: OSGStringAttributeMap.cpp,v 1.2 2005/09/28 03:01:44 vossg Exp $";
00244 static Char8 cvsid_hpp [] = OSGSTRINGATTRIBUTEMAPBASE_HEADER_CVSID;
00245 static Char8 cvsid_inl [] = OSGSTRINGATTRIBUTEMAPBASE_INLINE_CVSID;
00246
00247 static Char8 cvsid_fields_hpp[] = OSGSTRINGATTRIBUTEMAPFIELDS_HEADER_CVSID;
00248 }
00249
00250 #ifdef __sgi
00251 #pragma reset woff 1174
00252 #endif
00253