libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
mediagraph.h
Go to the documentation of this file.
1
8#pragma once
9
12#include <promeki/core/error.h>
13#include <promeki/core/list.h>
14#include <promeki/core/string.h>
17
19
32class MediaGraph : public ObjectBase {
33 PROMEKI_OBJECT(MediaGraph, ObjectBase)
34 public:
40
42 virtual ~MediaGraph();
43
50
61
63 const List<MediaNode *> &nodes() const { return _nodes; }
64
70 MediaNode *node(const String &name) const;
71
79
89
99 MediaNode *sink, const String &inputName);
100
107
115
117 const MediaLink::PtrList &links() const { return _links; }
118
128
137
143
149
155 void clear();
156
157 private:
158 List<MediaNode *> _nodes;
159 MediaLink::PtrList _links;
160
161 bool ownsNode(MediaNode *node) const;
162 bool hasCycle() const;
163};
164
Lightweight error code wrapper for the promeki library.
Definition error.h:39
Dynamic array container wrapping std::vector.
Definition list.h:40
Directed acyclic graph of MediaNodes connected by MediaLinks.
Definition mediagraph.h:32
Error disconnect(MediaPort::Ptr output, MediaPort::Ptr input)
Disconnects the link between two specific ports.
MediaLink::Ptr connect(MediaPort::Ptr output, MediaPort::Ptr input)
Connects an output port to an input port.
Error disconnect(MediaLink::Ptr link)
Disconnects a link.
MediaNode * node(const String &name) const
Finds a node by name.
MediaGraph(ObjectBase *parent=nullptr)
Constructs an empty graph.
virtual ~MediaGraph()
Destructor. Deletes all owned nodes.
List< MediaNode * > topologicalSort() const
Returns nodes in topological order (dependencies first).
void clear()
Removes all nodes and links.
List< MediaNode * > sourceNodes() const
Returns nodes with no input connections (source nodes).
Error removeNode(MediaNode *node)
Removes a node from the graph.
MediaLink::Ptr connect(MediaNode *source, const String &outputName, MediaNode *sink, const String &inputName)
Connects nodes by port name.
Error addNode(MediaNode *node)
Adds a node to the graph. Takes ownership.
const List< MediaNode * > & nodes() const
Returns all nodes in the graph.
Definition mediagraph.h:63
Error validate() const
Validates the graph topology.
MediaLink::Ptr connect(MediaNode *source, int outputIndex, MediaNode *sink, int inputIndex)
Connects nodes by port index.
List< MediaNode * > sinkNodes() const
Returns nodes with no output connections (sink nodes).
const MediaLink::PtrList & links() const
Returns all links in the graph.
Definition mediagraph.h:117
Base class for all pipeline processing nodes.
Definition medianode.h:81
Base object for promeki.
Definition objectbase.h:129
ObjectBase * parent() const
Returns the parent object, if one. nullptr if none.
Definition objectbase.h:258
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19