00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "PropertyManager.h"
00017 #include "Exception.h"
00018
00019 namespace nrEngine {
00020
00021
00022 PropertyManager::PropertyManager()
00023 {
00024
00025 }
00026
00027
00028 PropertyManager::~PropertyManager()
00029 {
00030
00031 mPropertyMap.clear();
00032 }
00033
00034
00035 void PropertyManager::createGroup(const std::string& name)
00036 {
00037 mPropertyMap.insert(std::pair<std::string, PropertyList>(name, PropertyList()));
00038 }
00039
00040
00041 const PropertyList& PropertyManager::getPropertyList(const std::string& group)
00042 {
00043 return mPropertyMap[group];
00044 }
00045
00046
00047 Property& PropertyManager::getProperty(const std::string& name, const std::string& group)
00048 {
00049 return mPropertyMap[group][name];
00050 }
00051
00052
00053 Property& PropertyManager::getPropertyByFullName(const std::string& fullname)
00054 {
00055
00056 PropertyMap::iterator it = mPropertyMap.begin();
00057 for (; it != mPropertyMap.end(); it++)
00058 {
00059
00060 PropertyList::iterator jt = it->second.begin();
00061 for (; jt != it->second.end(); jt++)
00062 if (jt->getFullName() == fullname)
00063 {
00064 return *jt;
00065 }
00066 }
00067
00068
00069 NR_Log(Log::LOG_ENGINE, Log::LL_WARNING, "PropertyManager: Property with fullname '%s' is not registered, so create it in default group", fullname.c_str());
00070 return getProperty(fullname, "");
00071 }
00072
00073
00074 void PropertyManager::set(const Property& property, const std::string& name, const std::string& group)
00075 {
00076 Property& p = getProperty(name, group);
00077 p.copyDataOnly(property);
00078 p.mName = name;
00079 p.mFullName = group + std::string(".") + name;
00080 }
00081
00082
00083 void PropertyManager::setByFullName(const Property& property, const std::string& fullname)
00084 {
00085
00086 Property& p = getPropertyByFullName(fullname);
00087 p.copyDataOnly(property);
00088 p.mFullName = fullname;
00089 if (p.mName.length() == 0) p.mName = fullname;
00090 }
00091
00092
00093
00094 void PropertyManager::set(const boost::any& value, const std::string& name, const std::string& group)
00095 {
00096
00097 Property& p = getProperty(name, group);
00098
00099
00100 p.mValue = value;
00101 }
00102
00103
00104 void PropertyManager::setByFullName(const boost::any& value, const std::string& fullname)
00105 {
00106
00107 Property& p = getPropertyByFullName(fullname);
00108
00109
00110 p.mValue = value;
00111 }
00112
00113 };
00114
00115
00116