00001 00025 #include <magic/mattribute.h> 00026 #include <magic/mmap.h> 00027 00028 BEGIN_NAMESPACE (MagiC); 00029 00030 Attributed::Attributed () : mAttributes (NULL) 00031 { 00032 } 00033 00034 Attributed::~Attributed () 00035 { 00036 delete mAttributes; 00037 } 00038 00043 void Attributed::setAttribute (const String& key, Object* value) 00044 { 00045 if (!mAttributes) 00046 mAttributes = new Map<String,Object> (); 00047 mAttributes->set (key, value); 00048 } 00049 00050 const Object& Attributed::getAttribute (const String& key) const 00051 { 00052 return mAttributes? (*mAttributes)[key] : *(Object*)NULL; 00053 } 00054 00055 Object& Attributed::getAttribute (const String& key) 00056 { 00057 return mAttributes? (*mAttributes)[key] : *(Object*)NULL; 00058 } 00059 00060 const Object* Attributed::getAttributep (const String& key) const 00061 { 00062 return mAttributes? mAttributes->getp(key) : NULL; 00063 } 00064 00065 bool Attributed::hasAttribute (const String& key) const 00066 { 00067 return mAttributes? mAttributes->hasKey(key) : false; 00068 } 00069 00070 END_NAMESPACE; 00071