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, const std::list<std::string>& nodes ); ///@ todo: const Graph, no ? 00053 ~ProcessGraph(); 00054 00055 private: 00056 VertexAtTime::Key getOutputKeyAtTime( const OfxTime time ); 00057 InternalGraphAtTimeImpl::vertex_descriptor getOutputVertexAtTime( const OfxTime time ); 00058 00059 void relink(); 00060 void bakeGraphInformationToNodes( InternalGraphAtTimeImpl& renderGraphAtTime ); 00061 00062 public: 00063 void updateGraph( Graph& userGraph, const std::list<std::string>& outputNodes ); 00064 00065 void setup(); 00066 std::list<TimeRange> computeTimeRange(); 00067 void computeHashAtTime( NodeHashContainer& outNodesHash, const OfxTime time ); 00068 00069 void beginSequence( const TimeRange& timeRange ); 00070 void setupAtTime( const OfxTime time ); 00071 void processAtTime( memory::MemoryCache& outCache, const OfxTime time ); 00072 void endSequence(); 00073 00074 bool process( memory::MemoryCache& outCache ); 00075 00076 private: 00077 InternalGraphImpl _renderGraph; 00078 InternalGraphAtTimeImpl _renderGraphAtTime; 00079 NodeMap _nodes; 00080 InstanceCountMap _instanceCount; 00081 00082 static const std::string _outputId; 00083 00084 const ComputeOptions& _options; 00085 ProcessVertexData _procOptions; 00086 }; 00087 00088 } 00089 } 00090 } 00091 00092 #endif 00093