TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/ofx/attribute/OfxhClipImageSet.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_HOST_OFX_ATTRIBUTE_CLIPIMAGESET_HPP_
00002 #define _TUTTLE_HOST_OFX_ATTRIBUTE_CLIPIMAGESET_HPP_
00003 
00004 #include "OfxhClipImageAccessor.hpp"
00005 #include "OfxhClipDescriptor.hpp"
00006 #include "OfxhClipImage.hpp"
00007 
00008 #include <tuttle/host/ofx/OfxhIObject.hpp>
00009 
00010 #include <boost/foreach.hpp>
00011 
00012 namespace tuttle {
00013 namespace host {
00014 namespace ofx {
00015 namespace imageEffect {
00016 class OfxhImageEffectNodeDescriptor;
00017 }
00018 namespace attribute {
00019 
00020 class OfxhClipImageSet
00021         : virtual public OfxhIObject
00022         //, public ClipAccessorSet
00023 {
00024 public:
00025         typedef OfxhClipImageSet This;
00026         typedef std::map<std::string, OfxhClipImage*> ClipImageMap;
00027         typedef boost::ptr_vector<OfxhClipImage> ClipImageVector;
00028 
00029 protected:
00030         ClipImageVector _clipsByOrder; ///< clips list (data owner)
00031         ClipImageMap _clipImages; ///< clips by name (link to datas)
00032         bool _clipPrefsDirty; ///< do we need to re-run the clip prefs action
00033 
00034 public:
00035         /// The propery set being passed in belongs to the owning
00036         /// plugin instance.
00037         explicit OfxhClipImageSet();
00038 
00039         explicit OfxhClipImageSet( const OfxhClipImageSet& other );
00040 
00041         virtual ~OfxhClipImageSet() = 0;
00042 
00043         bool operator==( const This& other ) const;
00044         bool operator!=( const This& other ) const { return !This::operator==( other ); }
00045 
00046         void copyClipsValues( const OfxhClipImageSet& other );
00047 
00048         void populateClips( const imageEffect::OfxhImageEffectNodeDescriptor& descriptor ) OFX_EXCEPTION_SPEC;
00049 
00050         const ClipImageMap& getClipsByName() const
00051         {
00052                 return _clipImages;
00053         }
00054 
00055         ClipImageMap& getClipsByName()
00056         {
00057                 return _clipImages;
00058         }
00059 
00060         const ClipImageVector& getClipsByOrder() const
00061         {
00062                 return _clipsByOrder;
00063         }
00064 
00065         ClipImageVector& getClipsByOrder()
00066         {
00067                 return _clipsByOrder;
00068         }
00069 
00070         /**
00071          * get the clip
00072          */
00073         OfxhClipImage& getClip( const std::string& name, const bool acceptPartialName = false );
00074         
00075         const OfxhClipImage& getClip( const std::string& name, const bool acceptPartialName = false ) const
00076         {
00077                  return const_cast<This*>( this )->getClip( name, acceptPartialName );
00078         }
00079 
00080         const OfxhClipImage* getClipPtr( const std::string& name, const bool acceptPartialName = false ) const;
00081         
00082         OfxhClipImage* getClipPtr( const std::string& name, const bool acceptPartialName = false );
00083 
00084 
00085 #ifndef SWIG
00086         /**
00087          * add a clip
00088          */
00089         void addClip( const std::string& name, OfxhClipImage* instance ) OFX_EXCEPTION_SPEC
00090         {
00091                 if( _clipImages.find( name ) != _clipImages.end() )
00092                         BOOST_THROW_EXCEPTION( OfxhException( kOfxStatErrExists ) );
00093                 _clipImages[name] = instance;
00094                 _clipsByOrder.push_back( instance );
00095         }
00096 
00097         /**
00098          * make a clip instance
00099          *
00100          * Client host code needs to implement this
00101          */
00102         virtual OfxhClipImage* newClipImage( const OfxhClipImageDescriptor& descriptor ) = 0;
00103 #endif
00104 
00105         /**
00106          * get the nth clip, in order of declaration
00107          */
00108         OfxhClipImage& getNthClip( int index )
00109         {
00110                 return _clipsByOrder[index];
00111         }
00112 
00113         /**
00114          * get the number of clips
00115          */
00116         int getNbClips() const
00117         {
00118                 return int(_clipImages.size() );
00119         }
00120 
00121         /**
00122          * are the clip preferences currently dirty
00123          */
00124         bool areClipPrefsDirty() const
00125         {
00126                 return _clipPrefsDirty;
00127         }
00128 
00129 private:
00130         void initMapFromList();
00131 };
00132 
00133 }
00134 }
00135 }
00136 }
00137 
00138 #endif
00139