TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/ofx/OfxhImageEffectNodeDescriptor.cpp
Go to the documentation of this file.
00001 #include "OfxhImageEffectNodeDescriptor.hpp"
00002 #include "OfxhPlugin.hpp"
00003 #include "OfxhPluginBinary.hpp"
00004 
00005 #include <tuttle/host/Core.hpp> /// @todo tuttle: please remove this ! (don't use as singleton)
00006 
00007 namespace tuttle {
00008 namespace host {
00009 namespace ofx {
00010 namespace imageEffect {
00011 
00012 ////////////////////////////////////////////////////////////////////////////////
00013 // descriptor
00014 
00015 /// properties common on an effect and a descriptor
00016 static property::OfxhPropSpec effectDescriptorStuff[] = {
00017     /* name                                 type                   dim. r/o default value */
00018     { kOfxPropType, property::ePropTypeString, 1, true, kOfxTypeImageEffect },
00019     { kOfxPropName, property::ePropTypeString, 1, false, "UNIQUE_NAME_NOT_SET" },
00020     { kOfxPropLabel, property::ePropTypeString, 1, false, "" },
00021     { kOfxPropShortLabel, property::ePropTypeString, 1, false, "" },
00022     { kOfxPropLongLabel, property::ePropTypeString, 1, false, "" },
00023     { kOfxPropPluginDescription, property::ePropTypeString, 1, false, "No plugin description." },
00024     { kOfxImageEffectPropSupportedContexts, property::ePropTypeString, 0, false, "" },
00025     { kOfxImageEffectPluginPropGrouping, property::ePropTypeString, 1, false, "" },
00026     { kOfxImageEffectPluginPropSingleInstance, property::ePropTypeInt, 1, false, "0" },
00027     { kOfxImageEffectPluginRenderThreadSafety, property::ePropTypeString, 1, false, kOfxImageEffectRenderInstanceSafe },
00028     { kOfxImageEffectPluginPropHostFrameThreading, property::ePropTypeInt, 1, false, "1" },
00029     { kOfxImageEffectPluginPropOverlayInteractV1, property::ePropTypePointer, 1, false, NULL },
00030     { kOfxImageEffectPropSupportsMultiResolution, property::ePropTypeInt, 1, false, "1" },
00031     { kOfxImageEffectPropSupportsTiles, property::ePropTypeInt, 1, false, "1" },
00032     { kOfxImageEffectPropTemporalClipAccess, property::ePropTypeInt, 1, false, "0" },
00033     { kOfxImageEffectPropSupportedPixelDepths, property::ePropTypeString, 0, false, "" },
00034     { kTuttleOfxImageEffectPropSupportedExtensions, property::ePropTypeString, 0, false, "" },
00035     { kTuttleOfxImageEffectPropEvaluation, property::ePropTypeDouble, 1, false, "-1" },
00036     { kOfxImageEffectPluginPropFieldRenderTwiceAlways, property::ePropTypeInt, 1, false, "1" },
00037     { kOfxImageEffectPropSupportsMultipleClipDepths, property::ePropTypeInt, 1, false, "0" },
00038     { kOfxImageEffectPropSupportsMultipleClipPARs, property::ePropTypeInt, 1, false, "0" },
00039     { kOfxImageEffectPropClipPreferencesSlaveParam, property::ePropTypeString, 0, false, "" },
00040     { kOfxImageEffectInstancePropSequentialRender, property::ePropTypeInt, 1, false, "0" },
00041     { kOfxPluginPropFilePath, property::ePropTypeString, 1, true, "" },
00042     { 0 }
00043 };
00044 
00045 OfxhImageEffectNodeDescriptor::OfxhImageEffectNodeDescriptor()
00046     : OfxhImageEffectNodeBase( effectDescriptorStuff )
00047     , _plugin( NULL )
00048 {
00049     /// @todo tuttle...
00050 }
00051 
00052 OfxhImageEffectNodeDescriptor::OfxhImageEffectNodeDescriptor( OfxhPlugin& plug )
00053     : OfxhImageEffectNodeBase( effectDescriptorStuff )
00054     , _plugin( &plug )
00055 {
00056     _properties.setStringProperty( kOfxPluginPropFilePath, plug.getBinary().getBundlePath() );
00057     tuttle::host::core().getHost().initDescriptor( *this );
00058 }
00059 
00060 OfxhImageEffectNodeDescriptor::OfxhImageEffectNodeDescriptor( const OfxhImageEffectNodeDescriptor& other, OfxhPlugin& plug )
00061     : OfxhImageEffectNodeBase( other._properties )
00062     , _plugin( &plug )
00063 {
00064     _properties.setStringProperty( kOfxPluginPropFilePath, plug.getBinary().getBundlePath() );
00065     tuttle::host::core().getHost().initDescriptor( *this );
00066 }
00067 
00068 OfxhImageEffectNodeDescriptor::OfxhImageEffectNodeDescriptor( const std::string& bundlePath, OfxhPlugin& plug )
00069     : OfxhImageEffectNodeBase( effectDescriptorStuff )
00070     , _plugin( &plug )
00071 {
00072     _properties.setStringProperty( kOfxPluginPropFilePath, bundlePath );
00073     tuttle::host::core().getHost().initDescriptor( *this );
00074 }
00075 
00076 OfxhImageEffectNodeDescriptor::~OfxhImageEffectNodeDescriptor()
00077 {}
00078 
00079 bool OfxhImageEffectNodeDescriptor::operator==( const This& other ) const
00080 {
00081     if( OfxhImageEffectNodeBase::operator!=( other ) ||
00082         attribute::OfxhParamSetDescriptor::operator!=( other ) ||
00083         _clipsByOrder != other._clipsByOrder )
00084         return false;
00085     return true;
00086 }
00087 
00088 /**
00089  * @brief create a new clip and add this to the clip map
00090  */
00091 attribute::OfxhClipImageDescriptor* OfxhImageEffectNodeDescriptor::defineClip( const std::string& name )
00092 {
00093     attribute::OfxhClipImageDescriptor* c = new attribute::OfxhClipImageDescriptor( name );
00094 
00095     _clips[name] = c;
00096     _clipsByOrder.push_back( c );
00097     return c;
00098 }
00099 
00100 /// @warning tuttle some modifs here, doc needs update
00101 /// get the interact description, this will also call describe on the interact
00102 void OfxhImageEffectNodeDescriptor::initOverlayDescriptor( int bitDepthPerComponent, bool hasAlpha )
00103 {
00104     if( _overlayDescriptor.getState() == interact::eUninitialised )
00105     {
00106                 OfxPluginEntryPoint* overlayEntryPoint = getOverlayInteractMainEntry();
00107         // OK, we need to describe it, set the entry point and describe away
00108         _overlayDescriptor.setEntryPoint( overlayEntryPoint );
00109         _overlayDescriptor.describe( bitDepthPerComponent, hasAlpha );
00110     }
00111 }
00112 
00113 void OfxhImageEffectNodeDescriptor::addClip( const std::string& name, attribute::OfxhClipImageDescriptor* clip )
00114 {
00115     _clips[name] = clip;
00116     _clipsByOrder.push_back( clip );
00117 }
00118 
00119 }
00120 }
00121 }
00122 }
00123