TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/ofx/attribute/OfxhAttribute.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_HOST_OFX_ATTRIBUTE_HPP_
00002 #define _TUTTLE_HOST_OFX_ATTRIBUTE_HPP_
00003 
00004 #include "OfxhAttributeDescriptor.hpp"
00005 
00006 #include <boost/serialization/serialization.hpp>
00007 #include <boost/serialization/nvp.hpp>
00008 #include <boost/serialization/export.hpp>
00009 #include <boost/type_traits/is_virtual_base_of.hpp>
00010 
00011 namespace tuttle {
00012 namespace host {
00013 namespace ofx {
00014 namespace attribute {
00015 
00016 enum EChange
00017 {
00018         eChangeNone,
00019         eChangeTime,
00020         eChangeUserEdited,
00021         eChangePluginEdited,
00022 };
00023 
00024 inline std::string mapChangeEnumToString( const EChange change )
00025 {
00026         switch( change )
00027         {
00028                 case eChangeTime:
00029                         return kOfxChangeTime;
00030                 case eChangeUserEdited:
00031                         return kOfxChangeUserEdited;
00032                 case eChangePluginEdited:
00033                         return kOfxChangePluginEdited;
00034                 case eChangeNone:
00035                         return "eChangeNone";
00036         }
00037         return "eChangeNone";
00038 }
00039 
00040 inline EChange mapChangeStringToEnum( const std::string& change )
00041 {
00042         if( change == kOfxChangeTime )
00043                 return eChangeTime;
00044         else if( change == kOfxChangeUserEdited )
00045                 return eChangeUserEdited;
00046         else if( change == kOfxChangePluginEdited )
00047                 return eChangePluginEdited;
00048         else
00049                 return eChangeNone;
00050 }
00051 
00052 class OfxhAttribute : virtual public OfxhAttributeAccessor
00053 {
00054 public:
00055         typedef OfxhAttribute This;
00056 
00057 protected:
00058         OfxhAttribute() {}
00059 
00060 public:
00061         OfxhAttribute( const property::OfxhSet& properties );
00062         OfxhAttribute( const OfxhAttributeDescriptor& desc );
00063         virtual ~OfxhAttribute() = 0;
00064 
00065         virtual bool operator==( const This& other ) const
00066         {
00067                 if( getProperties() != other.getProperties() )
00068                         return false;
00069                 return true;
00070         }
00071 
00072         bool operator!=( const This& other ) const { return !This::operator==( other ); }
00073 
00074 protected:
00075         property::OfxhSet _properties;
00076     
00077 protected:
00078         void setProperties( const property::OfxhSet& properties )
00079         {
00080                 _properties = properties;
00081                 BOOST_ASSERT( getAttributeType().c_str() );
00082         }
00083 
00084 public:
00085         const property::OfxhSet& getProperties() const
00086         {
00087                 return _properties;
00088         }
00089 
00090         property::OfxhSet& getEditableProperties()
00091         {
00092                 return _properties;
00093         }
00094 
00095         virtual void copyValues( const This& other )
00096         {
00097                 _properties.copyValues( other._properties );
00098         }
00099 
00100 private:
00101         friend class boost::serialization::access;
00102         template<class Archive>
00103         void serialize( Archive& ar, const unsigned int version )
00104         {
00105                 ar& BOOST_SERIALIZATION_NVP( _properties );
00106         }
00107 
00108 };
00109 
00110 }
00111 }
00112 }
00113 }
00114 
00115 #endif