Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

TBaseProperty.h

Go to the documentation of this file.
00001 
00046 #ifndef _AMIRE_PROPERTY_T_BASE_PROPERTY_H
00047 #define _AMIRE_PROPERTY_T_BASE_PROPERTY_H
00048 
00049 #include <amire/common/Defines.h>
00050 #include <amire/property/PersistentProperty.h>
00051 #include <amire/property/PropertyTypeManager.h>
00052 
00053 namespace amire {
00054   namespace property {
00062     template <class type> class AMIRE_EXPORT_API TBaseProperty : public virtual PersistentProperty {
00063     protected:
00064       type value;
00065 
00066     public:
00067       inline TBaseProperty(const PropertyTypeManager *propertyTypeManager)
00068           : Property(propertyTypeManager, propertyTypeManager->getBaseType(value)), PersistentProperty(propertyTypeManager, propertyType) {
00069         initValue(value);
00070       }
00071 
00072       inline TBaseProperty(const type &value, const PropertyTypeManager *propertyTypeManager)
00073           : Property(propertyTypeManager, propertyTypeManager->getBaseType(value)), PersistentProperty(propertyTypeManager, propertyType) {
00074         this->value = value;
00075       }
00076 
00077       inline TBaseProperty(const TBaseProperty<type> &property)
00078           : Property(property.propertyTypeManager, property.propertyType), PersistentProperty(propertyTypeManager, propertyType), value(property.value) {
00079       }
00080 
00081       virtual ~TBaseProperty() {
00082       }
00083 
00084       virtual bool equals(const osg::ref_ptr<const Property> &property) const {
00085         const TBaseProperty<type> *baseProperty = dynamic_cast<const TBaseProperty<type>*>(property.get());
00086         return baseProperty && equalsValue(value, baseProperty->value);
00087       }
00088 
00089       virtual osg::ref_ptr<Property> clone() const {
00090         return new TBaseProperty<type>(*this);
00091       }
00092 
00093       virtual void cloneFrom(const osg::ref_ptr<const Property> &property) {
00094         const TBaseProperty<type> *baseProperty = amire::common::guarded_cast<const TBaseProperty<type>, const Property>(property.get());
00095         value = baseProperty->value;
00096         propertyType = baseProperty->propertyType;
00097       }
00098 
00105       inline const type &getValue() const {
00106         return value;
00107       }
00108 
00113       inline void setValue(const type &value) {
00114         this->value = value;
00115       }
00116     };
00117   }
00118 }
00119 
00120 #endif
00121 

Generated on Tue May 20 17:23:53 2003 for AMIRE-Framework by doxygen1.3