TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/graph/ProcessVertexAtTimeData.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_HOST_PROCESSVERTEXATTIMEDATA_HPP_
00002 #define _TUTTLE_HOST_PROCESSVERTEXATTIMEDATA_HPP_
00003 
00004 #include "ProcessVertexData.hpp"
00005 
00006 #include <tuttle/host/ofx/attribute/OfxhClipImage.hpp>
00007 #include <tuttle/host/ofx/OfxhCore.hpp>
00008 
00009 #include <string>
00010 
00011 namespace tuttle {
00012 namespace host {
00013 namespace graph {
00014 
00015 class ProcessEdgeAtTime;
00016 
00017 class ProcessVertexAtTimeInfo
00018 {
00019 typedef ProcessVertexAtTimeInfo This;
00020 
00021 public:
00022         ProcessVertexAtTimeInfo()
00023                 : _nodes( 0 )
00024                 , _memory( 0 )
00025         {}
00026 
00027         std::size_t _nodes;
00028         std::size_t _memory;
00029 
00030         ProcessVertexAtTimeInfo& operator+=( const ProcessVertexAtTimeInfo& p )
00031         {
00032                 _nodes  += p._nodes;
00033                 _memory += p._memory;
00034                 return *this;
00035         }
00036 
00037 public:
00038         friend std::ostream& operator<<( std::ostream& os, const This& g );
00039 };
00040 
00041 class ProcessVertexAtTimeData
00042 {
00043 typedef ProcessVertexAtTimeData This;
00044 
00045 public:
00046         ProcessVertexAtTimeData()
00047                 : _nodeData( NULL )
00048                 , _time( 0 )
00049                 , _isFinalNode( false )
00050                 , _outDegree( 0 )
00051                 , _inDegree( 0 )
00052         {
00053                 _localInfos._nodes = 1; // local infos can contain only 1 node by definition...
00054         }
00055 
00056         ProcessVertexAtTimeData( const ProcessVertexData& nodeData, const OfxTime time )
00057                 : _nodeData( &nodeData )
00058                 , _time( time )
00059                 , _isFinalNode( false )
00060                 , _outDegree( 0 )
00061                 , _inDegree( 0 )
00062         {
00063                 _localInfos._nodes = 1; // local infos can contain only 1 node by definition...
00064         }
00065 
00066         ProcessVertexAtTimeData( const This& other )
00067                 : _nodeData( other._nodeData )
00068         {
00069                 operator=( other );
00070         }
00071         ~ProcessVertexAtTimeData() {}
00072 
00073         This& operator=( const This& v )
00074         {
00075                 _nodeData = v._nodeData;
00076                 
00077                 _time = v._time;
00078                 _isFinalNode = v._isFinalNode;
00079                 _outDegree = v._outDegree;
00080                 _inDegree = v._inDegree;
00081                 _localInfos = v._localInfos;
00082                 _inputsInfos = v._inputsInfos;
00083                 _globalInfos = v._globalInfos;
00084 
00085                 _apiImageEffect = v._apiImageEffect;
00086                 
00087                 return *this;
00088         }
00089         
00090         inline const ProcessEdgeAtTime& getInputEdgeByClipName( const std::string& inputClipName, const OfxTime time ) const
00091         {
00092                 Key k(inputClipName, time);
00093                 ProcessEdgeAtTimeByClipName::const_iterator it = _inEdges.find(k);
00094                 if( it == _inEdges.end() )
00095                         BOOST_THROW_EXCEPTION( exception::Bug()
00096                                 << exception::dev() + "No input clip " + quotes(inputClipName) + " at time " + time + " inside input edges map." );
00097                 return *(it->second);
00098         }
00099         
00100 public:
00101         friend std::ostream& operator<<( std::ostream& os, const This& vData );
00102 
00103 public:
00104         const ProcessVertexData* _nodeData;
00105 
00106         OfxTime _time;
00107         bool _isFinalNode;
00108 
00109         typedef std::pair<std::string, OfxTime> Key;
00110         typedef std::map<Key, const ProcessEdgeAtTime*> ProcessEdgeAtTimeByClipName;
00111         ProcessEdgeAtTimeByClipName _inEdges;
00112         std::vector<const ProcessEdgeAtTime*> _outEdges;
00113         
00114         std::size_t _outDegree; ///< number of connected input clips
00115         std::size_t _inDegree; ///< number of nodes using the output of this node
00116 
00117         ProcessVertexAtTimeInfo _localInfos;
00118         ProcessVertexAtTimeInfo _inputsInfos;
00119         ProcessVertexAtTimeInfo _globalInfos;
00120 
00121         /// @group API Specific datas
00122         /// @{
00123         /**
00124          * @brief imageEffect specific process datas
00125          */
00126         struct ImageEffect
00127         {
00128                 std::string _field;
00129                 OfxRectD _renderRoD; // is it a good thing to store this here ?
00130                 OfxRectD _renderRoI;
00131 
00132                 typedef std::map<tuttle::host::ofx::attribute::OfxhClipImage*, OfxRectD> MapClipImageRod;
00133                 MapClipImageRod _inputsRoI; ///<< in which the plugin set the RoI it needs for each input clip
00134 
00135         } _apiImageEffect;
00136         /// @}
00137 
00138 };
00139 
00140 }
00141 }
00142 }
00143 
00144 #endif
00145