score-plugin-dataflow/Dataflow/PortItem.hpp
1 #pragma once
2 #include <Device/Widgets/AddressAccessorEditWidget.hpp>
3 
4 #include <Process/Dataflow/PortFactory.hpp>
5 #include <Process/Dataflow/PortItem.hpp>
6 
7 #include <Inspector/InspectorWidgetFactoryInterface.hpp>
8 
9 #include <score/command/Dispatchers/CommandDispatcher.hpp>
10 #include <score/plugins/SerializableHelpers.hpp>
11 
12 #include <score_plugin_dataflow_export.h>
13 namespace Scenario
14 {
15 class IntervalModel;
16 }
17 namespace Dataflow
18 {
19 class CableItem;
20 
21 class SCORE_PLUGIN_DATAFLOW_EXPORT AutomatablePortItem : public PortItem
22 {
23 public:
24  using PortItem::PortItem;
25  ~AutomatablePortItem() override;
26 
27  void setupMenu(QMenu&, const score::DocumentContext& ctx) override;
28  void on_createAutomation(const score::DocumentContext& m_context);
29  virtual bool on_createAutomation(
30  const Scenario::IntervalModel& parent, std::function<void(score::Command*)> macro,
31  const score::DocumentContext& m_context);
32 
33  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
34  void dropEvent(QGraphicsSceneDragDropEvent* event) override;
35 };
36 
37 class SCORE_PLUGIN_DATAFLOW_EXPORT AutomatablePortFactory : public Process::PortFactory
38 {
39 public:
40  ~AutomatablePortFactory() override = default;
41 
42 private:
43  Dataflow::PortItem* makePortItem(
44  Process::Inlet& port, const Process::Context& ctx, QGraphicsItem* parent,
45  QObject* context) override;
46 
47  Dataflow::PortItem* makePortItem(
48  Process::Outlet& port, const Process::Context& ctx, QGraphicsItem* parent,
49  QObject* context) override;
50 };
51 
52 template <typename Model_T>
54 {
55 public:
56  ~AutomatablePortFactory_T() override = default;
57 
58 private:
59  UuidKey<Process::Port> concreteKey() const noexcept override
60  {
62  }
63 
64  Model_T* load(const VisitorVariant& vis, QObject* parent) override
65  {
66  return score::deserialize_dyn(vis, [&](auto&& deserializer) {
67  return new Model_T{deserializer, parent};
68  });
69  }
70 };
71 }
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:54
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:38
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:22
Definition: score-lib-process/Process/Dataflow/PortItem.hpp:39
Definition: Port.hpp:177
Definition: Port.hpp:273
Definition: PortFactory.hpp:30
Definition: IntervalModel.hpp:50
Definition: UuidKey.hpp:343
The Command class.
Definition: Command.hpp:34
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Static metadata implementation.
Definition: lib/score/tools/Metadata.hpp:36
Definition: ProcessContext.hpp:12
The VisitorVariant struct.
Definition: VisitorInterface.hpp:26
Definition: DocumentContext.hpp:18