1 /*! 2 @file 3 @author Albert Semenov 4 @date 08/2010 5 */ 6 7 #include "Precompiled.h" 8 #include "Property.h" 9 #include "Data.h" 10 #include "IPropertyInitialisator.h" 11 #include "FactoryManager.h" 12 13 namespace tools 14 { 15 Property(DataTypePropertyPtr _type,DataPtr _owner)16 Property::Property(DataTypePropertyPtr _type, DataPtr _owner) : 17 mType(_type), 18 mOwner(_owner) 19 { 20 } 21 getValue() const22 const std::string& Property::getValue() const 23 { 24 return mValue; 25 } 26 setValue(const std::string & _value)27 void Property::setValue(const std::string& _value) 28 { 29 if (mValue != _value) 30 { 31 mValue = _value; 32 eventChangeProperty(mWeakThis.lock()); 33 } 34 } 35 getType()36 DataTypePropertyPtr Property::getType() 37 { 38 return mType; 39 } 40 getOwner()41 DataPtr Property::getOwner() 42 { 43 return mOwner; 44 } 45 initialise()46 void Property::initialise() 47 { 48 if (!mType->getInitialisator().empty()) 49 { 50 IPropertyInitialisator* initialisator = components::FactoryManager::GetInstance().CreateItem<IPropertyInitialisator>(mType->getInitialisator()); 51 if (initialisator != nullptr) 52 initialisator->initialise(mWeakThis.lock()); 53 } 54 else 55 { 56 mValue = mType->getDefaultValue(); 57 } 58 } 59 CreateInstance(DataTypePropertyPtr _type,DataPtr _owner)60 PropertyPtr Property::CreateInstance(DataTypePropertyPtr _type, DataPtr _owner) 61 { 62 PropertyPtr result = PropertyPtr(new Property(_type, _owner)); 63 result->mWeakThis = PropertyWeak(result); 64 return result; 65 } 66 67 } 68