Loading...
Searching...
No Matches
PortFactory.hpp
1#pragma once
2#include <Process/Dataflow/Port.hpp>
3
4#include <score/graphics/TextItem.hpp>
5#include <score/plugins/Interface.hpp>
6#include <score/plugins/InterfaceList.hpp>
8class QGraphicsItem;
9namespace Inspector
10{
11class Layout;
12}
13namespace Dataflow
14{
15class PortItem;
16}
17namespace Process
18{
19struct Context;
21{
22 QGraphicsItem* container{};
23 Dataflow::PortItem* port_item{};
24 QGraphicsItem* control{};
25 score::SimpleTextItem* label{};
26 // QRectF itemRect;
27};
28
29class SCORE_LIB_PROCESS_EXPORT PortFactory : public score::InterfaceBase
30{
31 SCORE_INTERFACE(Process::Port, "4d461658-5c27-4a12-ba97-3d9392561ece")
32public:
33 ~PortFactory() override;
34
35 virtual Process::Port* load(const VisitorVariant&, QObject* parent) = 0;
36
37 // Just the port
38 virtual Dataflow::PortItem* makePortItem(
39 Process::Inlet& port, const Process::Context& ctx, QGraphicsItem* parent,
40 QObject* context);
41 virtual Dataflow::PortItem* makePortItem(
42 Process::Outlet& port, const Process::Context& ctx, QGraphicsItem* parent,
43 QObject* context);
44
45 // Just the control
46 virtual QGraphicsItem* makeControlItem(
48 QGraphicsItem* parent, QObject* context);
49 virtual QGraphicsItem* makeControlItem(
51 QGraphicsItem* parent, QObject* context);
52
53 // Port + control + text
54 ControlLayout makeFullItem(
55 Process::ControlInlet& port, const Process::Context& ctx, QGraphicsItem* parent,
56 QObject* context);
57 ControlLayout makeFullItem(
58 Process::ControlOutlet& port, const Process::Context& ctx, QGraphicsItem* parent,
59 QObject* context);
60
61 // Widget stuff
62 virtual void setupInletInspector(
63 const Process::Inlet& port, const score::DocumentContext& ctx, QWidget* parent,
64 Inspector::Layout& lay, QObject* context);
65 virtual void setupOutletInspector(
66 const Process::Outlet& port, const score::DocumentContext& ctx, QWidget* parent,
67 Inspector::Layout& lay, QObject* context);
68
69 virtual PortItemLayout defaultLayout() const noexcept;
70};
71
72class SCORE_LIB_PROCESS_EXPORT PortFactoryList final
73 : public score::InterfaceList<PortFactory>
74{
75public:
78 Process::Port* loadMissing(const VisitorVariant& vis, QObject* parent) const;
79};
80
81template <typename Model_T>
83{
84public:
85 ~PortFactory_T() override = default;
86
87private:
88 UuidKey<Process::Port> concreteKey() const noexcept override
89 {
91 }
92
93 Model_T* load(const VisitorVariant& vis, QObject* parent) override
94 {
95 return score::deserialize_dyn(vis, [&](auto&& deserializer) {
96 return new Model_T{deserializer, parent};
97 });
98 }
99};
100
101SCORE_LIB_PROCESS_EXPORT
102void readPorts(
103 DataStreamReader& wr, const Process::Inlets& ins, const Process::Outlets& outs);
104
105SCORE_LIB_PROCESS_EXPORT
106void readPorts(
107 JSONReader& obj, const Process::Inlets& ins, const Process::Outlets& outs);
108
109SCORE_LIB_PROCESS_EXPORT
110void writePorts(
112 Process::Outlets& outs, QObject* parent);
113
114SCORE_LIB_PROCESS_EXPORT
115void writePorts(
116 const JSONWriter& obj, const Process::PortFactoryList& pl, Process::Inlets& ins,
117 Process::Outlets& outs, QObject* parent);
118}
Definition DataStreamVisitor.hpp:27
Definition DataStreamVisitor.hpp:202
Definition score-lib-process/Process/Dataflow/PortItem.hpp:39
Definition lib/score/widgets/Layout.hpp:29
Definition JSONVisitor.hpp:52
Definition JSONVisitor.hpp:423
Definition Port.hpp:203
Definition Port.hpp:425
Definition Port.hpp:177
Definition Port.hpp:273
Definition PortFactory.hpp:83
Definition PortFactory.hpp:30
Definition PortFactory.hpp:74
Definition Port.hpp:102
Definition UuidKey.hpp:343
Base class for plug-in interfaces.
Definition Interface.hpp:52
InterfaceList Default implementation of InterfaceListBase.
Definition InterfaceList.hpp:80
Definition TextItem.hpp:28
Classes used for making and extending the inspector (default right panel).
Definition lib/score/widgets/Layout.hpp:27
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
Static metadata implementation.
Definition lib/score/tools/Metadata.hpp:36
Definition ProcessContext.hpp:12
Definition PortFactory.hpp:21
Definition PortForward.hpp:23
Definition PortForward.hpp:27
Definition Port.hpp:90
The VisitorVariant struct.
Definition VisitorInterface.hpp:26
Definition DocumentContext.hpp:18