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 #include "CEGUIPropertySet.h"
00027 #include "CEGUIProperty.h"
00028 #include "CEGUIExceptions.h"
00029
00030
00031 namespace CEGUI
00032 {
00033
00034
00035
00036
00037 void PropertySet::addProperty(Property* property)
00038 {
00039 if (property == NULL)
00040 {
00041 throw NullObjectException((utf8*)"The given Property object pointer is NULL.");
00042 }
00043
00044 if (d_properties.find(property->getName()) != d_properties.end())
00045 {
00046 throw AlreadyExistsException((utf8*)"A Property named '" + property->getName() + (utf8*)"' already exists in the PropertySet.");
00047 }
00048
00049 d_properties[property->getName()] = property;
00050 }
00051
00052
00053
00054
00055 void PropertySet::removeProperty(const String& name)
00056 {
00057 PropertyRegistry::iterator pos = d_properties.find(name);
00058
00059 if (pos != d_properties.end())
00060 {
00061 d_properties.erase(pos);
00062 }
00063 }
00064
00065
00066
00067
00068 void PropertySet::clearProperties(void)
00069 {
00070 d_properties.clear();
00071 }
00072
00073
00074
00075
00076 bool PropertySet::isPropertyPresent(const String& name) const
00077 {
00078 return (d_properties.find(name) != d_properties.end());
00079 }
00080
00081
00082
00083
00084 const String& PropertySet::getPropertyHelp(const String& name) const
00085 {
00086 PropertyRegistry::const_iterator pos = d_properties.find(name);
00087
00088 if (pos == d_properties.end())
00089 {
00090 throw UnknownObjectException((utf8*)"There is no Property named '" + name + (utf8*)"' available in the set.");
00091 }
00092
00093 return pos->second->getHelp();
00094 }
00095
00096
00097
00098
00099 String PropertySet::getProperty(const String& name) const
00100 {
00101 PropertyRegistry::const_iterator pos = d_properties.find(name);
00102
00103 if (pos == d_properties.end())
00104 {
00105 throw UnknownObjectException((utf8*)"There is no Property named '" + name + (utf8*)"' available in the set.");
00106 }
00107
00108 return pos->second->get(this);
00109 }
00110
00111
00112
00113
00114 void PropertySet::setProperty(const String& name,const String& value)
00115 {
00116 PropertyRegistry::iterator pos = d_properties.find(name);
00117
00118 if (pos == d_properties.end())
00119 {
00120 throw UnknownObjectException((utf8*)"There is no Property named '" + name + (utf8*)"' available in the set.");
00121 }
00122
00123 pos->second->set(this, value);
00124 }
00125
00126
00127
00128
00129
00130
00131 PropertySet::PropertyIterator PropertySet::getIterator(void) const
00132 {
00133 return PropertyIterator(d_properties.begin(), d_properties.end());
00134 }
00135
00136
00137
00138
00139
00140 bool PropertySet::isPropertyDefault(const String& name) const
00141 {
00142 PropertyRegistry::const_iterator pos = d_properties.find(name);
00143
00144 if (pos == d_properties.end())
00145 {
00146 throw UnknownObjectException((utf8*)"There is no Property named '" + name + (utf8*)"' available in the set.");
00147 }
00148
00149 return pos->second->isDefault(this);
00150 }
00151
00152
00153
00154
00155
00156 String PropertySet::getPropertyDefault(const String& name) const
00157 {
00158 PropertyRegistry::const_iterator pos = d_properties.find(name);
00159
00160 if (pos == d_properties.end())
00161 {
00162 throw UnknownObjectException((utf8*)"There is no Property named '" + name + (utf8*)"' available in the set.");
00163 }
00164
00165 return pos->second->getDefault(this);
00166 }
00167
00168 }