TuttleOFX
1
|
A user graph to manipulate OpenFX nodes. More...
#include <Graph.hpp>
Public Types | |
enum | EDotExportLevel { eDotExportLevelSimple, eDotExportLevelDetailed } |
typedef graph::UVertex | Vertex |
typedef graph::UEdge | Edge |
typedef INode | Node |
typedef attribute::Attribute | Attribute |
typedef graph::InternalGraph < Vertex, Edge > | InternalGraphImpl |
typedef InternalGraphImpl::vertex_descriptor | vertex_descriptor |
typedef InternalGraphImpl::edge_descriptor | edge_descriptor |
typedef std::map< std::string, int > | InstanceCountMap |
typedef boost::ptr_map < std::string, Node > | NodeMap |
Public Member Functions | |
Graph () | |
~Graph () | |
InputBufferWrapper | createInputBuffer () |
Create a new input node in the current graph, to give an input buffer. | |
OutputBufferWrapper | createOutputBuffer () |
Create a new output buffer node in the current graph, wrapped up for easy use. | |
Node & | createNode (const std::string &id) |
Create a new node in the graph. | |
Node & | addNode (const NodeInit &node) |
Add a node to the graph. It takes the ownership of the node object. | |
Node & | addNode (INode &node) |
Add a node to the graph. It takes the ownership of the node object. | |
std::vector< INode * > | addNodes (const std::vector< NodeInit > &nodes) |
Add nodes to the graph. | |
std::vector< INode * > | addConnectedNodes (const std::vector< NodeInit > &nodes) |
Add nodes to the graph and connect them linearly. | |
void | renameNode (Node &node, const std::string &newUniqueName) |
Rename a node in the current graph. | |
void | deleteNode (Node &node) |
Delete a node from the current graph. This will remove all the connections. | |
std::size_t | deleteUnconnectedNodes (const Node &node) |
Delete all unconnected nodes from the current graph. | |
void | clear () |
Delete all nodes from the current graph. This will remove all the connections. | |
void | connect (const std::string &outNode, const std::string &inNode, const std::string &inAttr=kOfxSimpleSourceAttributeName) |
Connect nodes (using there unique name in this graph). | |
void | connect (const std::list< std::string > &nodes) |
Connect nodes the list of nodes linearly. | |
void | connect (const Node &outNode, const Node &inNode) |
void | connect (const std::list< Node * > &nodes) |
void | connect (const std::vector< Node * > &nodes) |
void | connect (const Node &outNode, const Attribute &inAttr) |
void | connect (const Attribute &outAttr, const Attribute &inAttr) |
void | unconnect (const Attribute &outAttr, const Attribute &inAttr) |
void | unconnect (const Node &node) |
void | replaceNodeConnections (const Node &fromNode, const Node &toNode) |
std::size_t | getNbInputConnections (const Node &node) const |
std::size_t | getNbOutputConnections (const Node &node) const |
void | init () |
Temporary solution ! Prepare the user graph, so we can call getTimeDomain (and maybe others functions) on nodes. | |
void | setup () |
void | setupAtTime (const OfxTime time, const NodeListArg &nodes=NodeListArg()) |
void | computeGlobalHashAtTime (NodeHashContainer &outNodesHash, const OfxTime time, const NodeListArg &nodes=NodeListArg()) |
bool | compute (const ComputeOptions &options=ComputeOptions()) |
bool | compute (const NodeListArg &nodes, const ComputeOptions &options=ComputeOptions()) |
bool | compute (memory::IMemoryCache &memoryCache, const ComputeOptions &options) |
bool | compute (memory::IMemoryCache &memoryCache, const NodeListArg &nodes=NodeListArg(), const ComputeOptions &options=ComputeOptions()) |
bool | compute (memory::IMemoryCache &memoryCache, const NodeListArg &nodes, const ComputeOptions &options, memory::IMemoryCache &internMemoryCache) |
const InternalGraphImpl & | getGraph () const |
const NodeMap & | getNodesMap () const |
NodeMap & | getNodesMap () |
std::vector< const Node * > | getNodes () const |
std::vector< Node * > | getNodes () |
std::vector< Node * > | getConnectedNodes (const Node &node) |
std::vector< Node * > | getUnconnectedNodes (const Node &node) |
std::size_t | getNbNodes () const |
std::size_t | getNbConnections () const |
std::vector< Node * > | getNodesByContext (const std::string &type) |
std::vector< Node * > | getNodesByPlugin (const std::string &pluginId) |
const Node & | getNode (const std::string &name) const |
Node & | getNode (const std::string &name) |
const InstanceCountMap & | getInstanceCount () const |
void | exportDot (const std::string &filename, const EDotExportLevel level=eDotExportLevelSimple) const |
Private Member Functions | |
void | addToInternalGraph (Node &node) |
void | removeFromInternalGraph (Node &node) |
Private Attributes | |
InternalGraphImpl | _graph |
NodeMap | _nodesMap |
InstanceCountMap | _instanceCount |
used to assign a unique name to each node | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Graph &g) |
typedef std::map<std::string, int> tuttle::host::Graph::InstanceCountMap |
typedef INode tuttle::host::Graph::Node |
typedef boost::ptr_map<std::string, Node> tuttle::host::Graph::NodeMap |
std::vector< INode * > tuttle::host::Graph::addConnectedNodes | ( | const std::vector< NodeInit > & | nodes | ) |
Add nodes to the graph and connect them linearly.
Definition at line 78 of file Graph.cpp.
References addNodes(), and connect().
Referenced by BOOST_AUTO_TEST_CASE(), tuttle::host::compute(), and tuttle::host::loadAndGenerateThumbnail().
Graph::Node & tuttle::host::Graph::addNode | ( | const NodeInit & | node | ) |
Add a node to the graph. It takes the ownership of the node object.
Definition at line 49 of file Graph.cpp.
References tuttle::host::NodeInit::release().
Referenced by addNodes(), BOOST_AUTO_TEST_CASE(), and createNode().
Graph::Node & tuttle::host::Graph::addNode | ( | INode & | node | ) |
Add a node to the graph. It takes the ownership of the node object.
Definition at line 54 of file Graph.cpp.
References _instanceCount, _nodesMap, addToInternalGraph(), tuttle::host::INode::getLabel(), tuttle::host::INode::getName(), and tuttle::host::INode::setName().
Add nodes to the graph.
Definition at line 67 of file Graph.cpp.
References addNode().
Referenced by addConnectedNodes().
void tuttle::host::Graph::addToInternalGraph | ( | Node & | node | ) | [private] |
Definition at line 123 of file Graph.cpp.
References _graph, tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::addVertex(), and tuttle::host::INode::getName().
Referenced by addNode(), and renameNode().
void tuttle::host::Graph::clear | ( | ) |
Delete all nodes from the current graph. This will remove all the connections.
Definition at line 159 of file Graph.cpp.
References _graph, _instanceCount, _nodesMap, and tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::clear().
bool tuttle::host::Graph::compute | ( | const ComputeOptions & | options = ComputeOptions() | ) |
Definition at line 345 of file Graph.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), tuttle::host::ThreadEnv::compute(), tuttle::host::compute(), compute(), tuttle::host::loadAndGenerateThumbnail(), and tuttle::host::ThreadEnv::runProcessFunc().
bool tuttle::host::Graph::compute | ( | const NodeListArg & | nodes, |
const ComputeOptions & | options = ComputeOptions() |
||
) |
bool tuttle::host::Graph::compute | ( | memory::IMemoryCache & | memoryCache, |
const ComputeOptions & | options | ||
) |
bool tuttle::host::Graph::compute | ( | memory::IMemoryCache & | memoryCache, |
const NodeListArg & | nodes = NodeListArg() , |
||
const ComputeOptions & | options = ComputeOptions() |
||
) |
Definition at line 363 of file Graph.cpp.
References compute(), and tuttle::host::core().
bool tuttle::host::Graph::compute | ( | memory::IMemoryCache & | memoryCache, |
const NodeListArg & | nodes, | ||
const ComputeOptions & | options, | ||
memory::IMemoryCache & | internMemoryCache | ||
) |
Definition at line 368 of file Graph.cpp.
References _graph, tuttle::host::graph::exportAsDOT(), tuttle::host::NodeListArg::getNodes(), and tuttle::host::graph::ProcessGraph::process().
void tuttle::host::Graph::computeGlobalHashAtTime | ( | NodeHashContainer & | outNodesHash, |
const OfxTime | time, | ||
const NodeListArg & | nodes = NodeListArg() |
||
) |
Definition at line 336 of file Graph.cpp.
References tuttle::host::core(), tuttle::host::Core::getMemoryCache(), tuttle::host::NodeListArg::getNodes(), and tuttle::host::graph::ProcessGraph::setup().
void tuttle::host::Graph::connect | ( | const std::string & | outNode, |
const std::string & | inNode, | ||
const std::string & | inAttr = kOfxSimpleSourceAttributeName |
||
) |
Connect nodes (using there unique name in this graph).
Definition at line 166 of file Graph.cpp.
References getNode().
Referenced by addConnectedNodes(), BOOST_AUTO_TEST_CASE(), connect(), and replaceNodeConnections().
void tuttle::host::Graph::connect | ( | const std::list< std::string > & | nodes | ) |
Definition at line 189 of file Graph.cpp.
References connect(), and tuttle::host::INode::getSingleInputAttribute().
void tuttle::host::Graph::connect | ( | const std::list< Node * > & | nodes | ) |
void tuttle::host::Graph::connect | ( | const std::vector< Node * > & | nodes | ) |
Definition at line 233 of file Graph.cpp.
References _graph, tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::connect(), tuttle::host::attribute::Attribute::getName(), tuttle::host::INode::getName(), and tuttle::host::attribute::Attribute::getNode().
Definition at line 238 of file Graph.cpp.
References _graph, tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::connect(), tuttle::host::attribute::Attribute::getName(), tuttle::host::INode::getName(), and tuttle::host::attribute::Attribute::getNode().
InputBufferWrapper tuttle::host::Graph::createInputBuffer | ( | ) |
Create a new input node in the current graph, to give an input buffer.
Definition at line 27 of file Graph.cpp.
References createNode().
Graph::Node & tuttle::host::Graph::createNode | ( | const std::string & | id | ) |
Create a new node in the graph.
id | is the plugin unique string identification (e.g. "tuttle.blur"). |
Definition at line 43 of file Graph.cpp.
References addNode().
Referenced by BOOST_AUTO_TEST_CASE(), createInputBuffer(), createOutputBuffer(), and tuttle::host::io::getBestReader().
OutputBufferWrapper tuttle::host::Graph::createOutputBuffer | ( | ) |
Create a new output buffer node in the current graph, wrapped up for easy use.
Definition at line 35 of file Graph.cpp.
References createNode().
void tuttle::host::Graph::deleteNode | ( | Node & | node | ) |
Delete a node from the current graph. This will remove all the connections.
Definition at line 137 of file Graph.cpp.
References _nodesMap, tuttle::host::INode::getName(), and removeFromInternalGraph().
Referenced by deleteUnconnectedNodes().
std::size_t tuttle::host::Graph::deleteUnconnectedNodes | ( | const Node & | node | ) |
Delete all unconnected nodes from the current graph.
node,: | delete all unconnected nodes from this node. |
Definition at line 149 of file Graph.cpp.
References _graph, deleteNode(), tuttle::host::INode::getName(), tuttle::host::graph::IVertex::getProcessNode(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getUnconnectedVertices(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getVertexDescriptor(), and tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::instance().
void tuttle::host::Graph::exportDot | ( | const std::string & | filename, |
const EDotExportLevel | level = eDotExportLevelSimple |
||
) | const |
Definition at line 477 of file Graph.cpp.
References _graph, eDotExportLevelDetailed, eDotExportLevelSimple, and tuttle::host::graph::exportAsDOT().
std::vector< Graph::Node * > tuttle::host::Graph::getConnectedNodes | ( | const Node & | node | ) |
Definition at line 405 of file Graph.cpp.
References _graph, tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getConnectedVertices(), tuttle::host::INode::getName(), tuttle::host::graph::IVertex::getProcessNode(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getVertexDescriptor(), and tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::instance().
const InternalGraphImpl& tuttle::host::Graph::getGraph | ( | ) | const [inline] |
Definition at line 184 of file Graph.hpp.
References _graph.
Referenced by tuttle::host::operator<<(), and tuttle::host::graph::ProcessGraph::updateGraph().
const InstanceCountMap& tuttle::host::Graph::getInstanceCount | ( | ) | const [inline] |
Definition at line 205 of file Graph.hpp.
References _instanceCount.
std::size_t tuttle::host::Graph::getNbConnections | ( | ) | const [inline] |
Definition at line 196 of file Graph.hpp.
References _graph, and tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getEdgeCount().
std::size_t tuttle::host::Graph::getNbInputConnections | ( | const Node & | node | ) | const |
Definition at line 311 of file Graph.cpp.
References _graph, tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getInDegree(), tuttle::host::INode::getName(), and tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getVertexDescriptor().
Referenced by BOOST_AUTO_TEST_CASE().
std::size_t tuttle::host::Graph::getNbNodes | ( | ) | const [inline] |
std::size_t tuttle::host::Graph::getNbOutputConnections | ( | const Node & | node | ) | const |
Definition at line 316 of file Graph.cpp.
References _graph, tuttle::host::INode::getName(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getOutDegree(), and tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getVertexDescriptor().
Referenced by BOOST_AUTO_TEST_CASE().
const Node& tuttle::host::Graph::getNode | ( | const std::string & | name | ) | const [inline] |
Definition at line 202 of file Graph.hpp.
References _nodesMap.
Referenced by BOOST_AUTO_TEST_CASE(), and connect().
Node& tuttle::host::Graph::getNode | ( | const std::string & | name | ) | [inline] |
Definition at line 203 of file Graph.hpp.
References getNodesMap().
std::vector< const Graph::Node * > tuttle::host::Graph::getNodes | ( | ) | const |
Definition at line 379 of file Graph.cpp.
References getNodesMap().
std::vector< Graph::Node * > tuttle::host::Graph::getNodes | ( | ) |
Definition at line 392 of file Graph.cpp.
References getNodesMap().
std::vector< Graph::Node * > tuttle::host::Graph::getNodesByContext | ( | const std::string & | type | ) |
Definition at line 433 of file Graph.cpp.
References tuttle::host::INode::asImageEffectNode(), tuttle::host::ofx::imageEffect::OfxhImageEffectNode::getContext(), and getNodesMap().
std::vector< Graph::Node * > tuttle::host::Graph::getNodesByPlugin | ( | const std::string & | pluginId | ) |
Definition at line 455 of file Graph.cpp.
References tuttle::host::INode::asImageEffectNode(), tuttle::host::ofx::OfxhPluginDesc::getIdentifier(), getNodesMap(), and tuttle::host::ofx::imageEffect::OfxhImageEffectNode::getPlugin().
Referenced by BOOST_AUTO_TEST_CASE().
const NodeMap& tuttle::host::Graph::getNodesMap | ( | ) | const [inline] |
Definition at line 186 of file Graph.hpp.
References _nodesMap.
Referenced by getNode(), getNodes(), getNodesByContext(), and getNodesByPlugin().
NodeMap& tuttle::host::Graph::getNodesMap | ( | ) | [inline] |
std::vector< Graph::Node * > tuttle::host::Graph::getUnconnectedNodes | ( | const Node & | node | ) |
Definition at line 419 of file Graph.cpp.
References _graph, tuttle::host::INode::getName(), tuttle::host::graph::IVertex::getProcessNode(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getUnconnectedVertices(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getVertexDescriptor(), and tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::instance().
void tuttle::host::Graph::init | ( | ) |
void tuttle::host::Graph::removeFromInternalGraph | ( | Node & | node | ) | [private] |
Definition at line 130 of file Graph.cpp.
References _graph, tuttle::host::INode::getName(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getVertexDescriptor(), and tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::removeVertex().
Referenced by deleteNode(), and renameNode().
void tuttle::host::Graph::renameNode | ( | Graph::Node & | node, |
const std::string & | newUniqueName | ||
) |
Rename a node in the current graph.
newUniqueName | is the new unique node name. |
Definition at line 86 of file Graph.cpp.
References _nodesMap, addToInternalGraph(), tuttle::host::INode::getName(), tuttle::quotes(), removeFromInternalGraph(), tuttle::host::INode::setName(), TUTTLE_INFO, and TUTTLE_TLOG.
Definition at line 281 of file Graph.cpp.
References _graph, connect(), tuttle::host::INode::getAttribute(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getInEdges(), tuttle::host::INode::getName(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getOutEdges(), tuttle::host::graph::IVertex::getProcessNode(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getVertexDescriptor(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::instance(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::sourceInstance(), tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::targetInstance(), and unconnect().
Referenced by BOOST_AUTO_TEST_CASE().
void tuttle::host::Graph::setup | ( | ) |
Definition at line 321 of file Graph.cpp.
References tuttle::host::core(), and tuttle::host::graph::ProcessGraph::setup().
Referenced by tuttle::host::io::getBestReader(), and tuttle::host::loadAndGenerateThumbnail().
void tuttle::host::Graph::setupAtTime | ( | const OfxTime | time, |
const NodeListArg & | nodes = NodeListArg() |
||
) |
Definition at line 329 of file Graph.cpp.
References tuttle::host::core(), tuttle::host::Core::getMemoryCache(), tuttle::host::NodeListArg::getNodes(), and tuttle::host::graph::ProcessGraph::setupAtTime().
Referenced by tuttle::host::io::getBestReader().
Definition at line 243 of file Graph.cpp.
References _graph, tuttle::host::attribute::Attribute::getName(), tuttle::host::INode::getName(), tuttle::host::attribute::Attribute::getNode(), and tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::unconnect().
Referenced by BOOST_AUTO_TEST_CASE(), and replaceNodeConnections().
void tuttle::host::Graph::unconnect | ( | const Node & | node | ) |
Definition at line 276 of file Graph.cpp.
References _graph, tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::clearVertex(), tuttle::host::INode::getName(), and tuttle::host::graph::InternalGraph< VERTEX, EDGE, OutEdgeList, VertexList, EdgeList >::getVertexDescriptor().
std::ostream& operator<< | ( | std::ostream & | os, |
const Graph & | g | ||
) | [friend] |
InternalGraphImpl tuttle::host::Graph::_graph [private] |
Definition at line 217 of file Graph.hpp.
Referenced by addToInternalGraph(), clear(), compute(), connect(), deleteUnconnectedNodes(), exportDot(), getConnectedNodes(), getGraph(), getNbConnections(), getNbInputConnections(), getNbOutputConnections(), getUnconnectedNodes(), init(), removeFromInternalGraph(), replaceNodeConnections(), and unconnect().
used to assign a unique name to each node
Definition at line 219 of file Graph.hpp.
Referenced by addNode(), clear(), and getInstanceCount().
NodeMap tuttle::host::Graph::_nodesMap [private] |
Definition at line 218 of file Graph.hpp.
Referenced by addNode(), clear(), deleteNode(), getNbNodes(), getNode(), getNodesMap(), and renameNode().