TuttleOFX
1
|
00001 #ifndef _TUTTLE_HOST_PROCESSGRAPH_HPP_ 00002 #define _TUTTLE_HOST_PROCESSGRAPH_HPP_ 00003 00004 #include "ProcessVertex.hpp" 00005 #include "ProcessVertexAtTime.hpp" 00006 #include "ProcessEdge.hpp" 00007 #include "ProcessEdgeAtTime.hpp" 00008 00009 #include "InternalGraph.hpp" 00010 00011 #include <tuttle/host/Graph.hpp> 00012 #include <tuttle/host/NodeHashContainer.hpp> 00013 00014 #include <string> 00015 00016 /** 00017 * @brief If there is a define PROCESSGRAPH_USE_LINK, we don't create a copy of all nodes and 00018 * The ProcessGraph only contains link to the node in the original Graph. 00019 */ 00020 #define PROCESSGRAPH_USE_LINK 00021 00022 namespace tuttle { 00023 namespace host { 00024 namespace graph { 00025 00026 /** 00027 * @brief Created from a user Graph, this class allows you to launch the process. 00028 * 00029 * Internally this class use multiple graphs with different representation of the graph. 00030 * It create a new graph with a vertex for each node at each time. 00031 * It reorder the nodes to optimise memory usage. 00032 */ 00033 class ProcessGraph 00034 { 00035 public: 00036 typedef Graph::Node Node; /// @todo tuttle ProcessNode... 00037 typedef graph::ProcessVertex Vertex; 00038 typedef graph::ProcessVertexAtTime VertexAtTime; 00039 typedef graph::ProcessEdge Edge; 00040 typedef graph::ProcessEdgeAtTime EdgeAtTime; 00041 typedef Graph::Attribute Attribute; 00042 typedef InternalGraph<Vertex, Edge> InternalGraphImpl; 00043 typedef InternalGraph<ProcessVertexAtTime, ProcessEdgeAtTime> InternalGraphAtTimeImpl; 00044 #ifdef PROCESSGRAPH_USE_LINK 00045 typedef std::map<std::string, Node*> NodeMap; 00046 #else 00047 typedef Graph::NodeMap NodeMap; 00048 #endif 00049 typedef Graph::InstanceCountMap InstanceCountMap; 00050 00051 public: 00052 ProcessGraph( const ComputeOptions& options, Graph& graph, 00053 const std::list<std::string>& nodes, memory::IMemoryCache& internMemoryCache ); ///@ todo: const Graph, no ? 00054 ~ProcessGraph(); 00055 00056 private: 00057 VertexAtTime::Key getOutputKeyAtTime( const OfxTime time ); 00058 InternalGraphAtTimeImpl::vertex_descriptor getOutputVertexAtTime( const OfxTime time ); 00059 00060 void relink(); 00061 void bakeGraphInformationToNodes( InternalGraphAtTimeImpl& renderGraphAtTime ); 00062 00063 public: 00064 void updateGraph( Graph& userGraph, const std::list<std::string>& outputNodes ); 00065 00066 void setup(); 00067 std::list<TimeRange> computeTimeRange(); 00068 void computeHashAtTime( NodeHashContainer& outNodesHash, const OfxTime time ); 00069 00070 void beginSequence( const TimeRange& timeRange ); 00071 void setupAtTime( const OfxTime time ); 00072 void processAtTime( memory::IMemoryCache& outCache, const OfxTime time ); 00073 void endSequence(); 00074 00075 bool process( memory::IMemoryCache& outCache ); 00076 00077 private: 00078 InternalGraphImpl _renderGraph; 00079 InternalGraphAtTimeImpl _renderGraphAtTime; 00080 NodeMap _nodes; 00081 InstanceCountMap _instanceCount; 00082 00083 static const std::string _outputId; 00084 00085 const ComputeOptions& _options; 00086 memory::IMemoryCache& _internMemoryCache; 00087 ProcessVertexData _procOptions; 00088 }; 00089 00090 } 00091 } 00092 } 00093 00094 #endif 00095