TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/ofx/attribute/OfxhParam.cpp
Go to the documentation of this file.
00001 #include "OfxhParam.hpp"
00002 #include "OfxhParamSet.hpp"
00003 #include "OfxhParamDescriptor.hpp"
00004 
00005 #include <boost/numeric/conversion/cast.hpp>
00006 
00007 namespace tuttle {
00008 namespace host {
00009 namespace ofx {
00010 namespace attribute {
00011 
00012 /**
00013  * make a parameter, with the given type and name
00014  */
00015 OfxhParam::OfxhParam( const OfxhParamDescriptor& descriptor, const std::string& name, attribute::OfxhParamSet& setInstance )
00016         : attribute::OfxhAttribute( descriptor )
00017         , _paramSetInstance( &setInstance )
00018         , _parentInstance( NULL )
00019         , _avoidRecursion( false )
00020 {
00021         // parameter has to be owned by paramSet
00022         //setInstance.referenceParam( name, this ); ///< @todo tuttle move this outside
00023 
00024         getEditableProperties().addNotifyHook( kOfxParamPropEnabled, this );
00025         getEditableProperties().addNotifyHook( kOfxParamPropSecret, this );
00026         getEditableProperties().addNotifyHook( kOfxPropLabel, this );
00027 }
00028 
00029 /**
00030  * the description of a plugin parameter
00031  */
00032 OfxhParam::~OfxhParam() {}
00033 
00034 void OfxhParam::paramChanged( const EChange change )
00035 {
00036         _paramSetInstance->paramChanged( *this, change );
00037 }
00038 
00039 /**
00040  * callback which should set enabled state as appropriate
00041  */
00042 void OfxhParam::setEnabled() {}
00043 
00044 /**
00045  * callback which should set secret state as appropriate
00046  */
00047 void OfxhParam::setSecret() {}
00048 
00049 /**
00050  * callback which should update label
00051  */
00052 void OfxhParam::setLabel() {}
00053 
00054 /**
00055  * callback which should set
00056  */
00057 void OfxhParam::setDisplayRange() {}
00058 
00059 /**
00060  * get a value, implemented by instances to deconstruct var args
00061  */
00062 void OfxhParam::getV( va_list arg ) const OFX_EXCEPTION_SPEC
00063 {
00064         BOOST_THROW_EXCEPTION( OfxhException( kOfxStatErrUnsupported, std::string( "ParamInstance getV failed (paramName:" ) + getName() + ")" ) );
00065 }
00066 
00067 /**
00068  * get a value, implemented by instances to deconstruct var args
00069  */
00070 void OfxhParam::getV( const OfxTime time, va_list arg ) const OFX_EXCEPTION_SPEC
00071 {
00072         BOOST_THROW_EXCEPTION( OfxhException( kOfxStatErrUnsupported, std::string( "ParamInstance getV at time failed (paramName:" ) + getName() + ")" ) );
00073 }
00074 
00075 /**
00076  * set a value, implemented by instances to deconstruct var args
00077  */
00078 void OfxhParam::setV( va_list arg, const EChange change ) OFX_EXCEPTION_SPEC
00079 {
00080         BOOST_THROW_EXCEPTION( OfxhException( kOfxStatErrUnsupported, std::string( "ParamInstance setV failed (paramName:" ) + getName() + ")" ) );
00081 }
00082 
00083 /**
00084  * key a value, implemented by instances to deconstruct var args
00085  */
00086 void OfxhParam::setV( const OfxTime time, va_list arg, const EChange change ) OFX_EXCEPTION_SPEC
00087 {
00088         BOOST_THROW_EXCEPTION( OfxhException( kOfxStatErrUnsupported, std::string( "ParamInstance setV at time failed (paramName:" ) + getName() + ")" ) );
00089 }
00090 
00091 /**
00092  * derive a value, implemented by instances to deconstruct var args
00093  */
00094 void OfxhParam::deriveV( const OfxTime time, va_list arg ) const OFX_EXCEPTION_SPEC
00095 {
00096         BOOST_THROW_EXCEPTION( OfxhException( kOfxStatErrUnsupported ) );
00097 }
00098 
00099 /**
00100  * integrate a value, implemented by instances to deconstruct var args
00101  */
00102 void OfxhParam::integrateV( const OfxTime time1, const OfxTime time2, va_list arg ) const OFX_EXCEPTION_SPEC
00103 {
00104         BOOST_THROW_EXCEPTION( OfxhException( kOfxStatErrUnsupported ) );
00105 }
00106 
00107 /**
00108  * overridden from Property::NotifyHook
00109  */
00110 void OfxhParam::notify( const std::string& name, bool single, int num ) OFX_EXCEPTION_SPEC
00111 {
00112         if( name == kOfxPropLabel )
00113         {
00114                 setLabel();
00115         }
00116         if( name == kOfxParamPropEnabled )
00117         {
00118                 setEnabled();
00119         }
00120         if( name == kOfxParamPropSecret )
00121         {
00122                 setSecret();
00123         }
00124         if( name == kOfxParamPropDisplayMin || name == kOfxParamPropDisplayMax )
00125         {
00126                 setDisplayRange();
00127         }
00128 }
00129 
00130 /**
00131  * copy one parameter to another
00132  */
00133 void OfxhParam::copy( const OfxhParam& instance, OfxTime offset ) OFX_EXCEPTION_SPEC
00134 {
00135         BOOST_THROW_EXCEPTION( OfxhException( kOfxStatErrMissingHostFeature ) );
00136 }
00137 
00138 /**
00139  * copy one parameter to another, with a range
00140  */
00141 void OfxhParam::copy( const OfxhParam& instance, OfxTime offset, OfxRangeD range ) OFX_EXCEPTION_SPEC
00142 {
00143         BOOST_THROW_EXCEPTION( OfxhException( kOfxStatErrMissingHostFeature ) );
00144 }
00145 
00146 void OfxhParam::setParentInstance( OfxhParam* instance )
00147 {
00148         _parentInstance = instance;
00149 }
00150 
00151 OfxhParam* OfxhParam::getParentInstance()
00152 {
00153         return _parentInstance;
00154 }
00155 
00156 std::ostream& operator<<( std::ostream& os, const OfxhParam& v )
00157 {
00158         os << "Param {" << std::endl;
00159         os << v.getProperties();
00160         os << "}" << std::endl;
00161         return os;
00162 }
00163 
00164 }
00165 }
00166 }
00167 }