Cable.hpp
1 #pragma once
2 #include <State/Address.hpp>
3 
4 #include <Process/Dataflow/CableData.hpp>
5 
6 #include <score/model/IdentifiedObject.hpp>
7 #include <score/model/path/Path.hpp>
8 #include <score/selection/Selectable.hpp>
9 
10 #include <score_lib_process_export.h>
11 
12 #include <verdigris>
13 
14 namespace ossia
15 {
16 class graph_node;
17 struct outlet;
18 struct inlet;
19 struct graph_edge;
20 using node_ptr = std::shared_ptr<graph_node>;
21 using outlet_ptr = outlet*;
22 using inlet_ptr = inlet*;
23 using edge_ptr = std::shared_ptr<graph_edge>;
24 }
25 namespace Dataflow
26 {
27 class DocumentPlugin;
28 }
29 namespace Process
30 {
31 class Node;
32 class Port;
33 class Outlet;
34 class Inlet;
35 class Cable;
36 
37 class SCORE_LIB_PROCESS_EXPORT Cable final : public IdentifiedObject<Cable>
38 {
39  W_OBJECT(Cable)
40  SCORE_SERIALIZE_FRIENDS
41 
42 public:
43  Selectable selection{this};
44  Cable() = delete;
45  ~Cable();
46  Cable(const Cable&) = delete;
47  Cable(Id<Cable> c, QObject* parent);
48 
49  template <typename T>
50  Cable(T&& vis, QObject* parent)
51  : IdentifiedObject{vis, parent}
52  {
53  vis.writeTo(*this);
54  }
55  Cable(Id<Cable> c, const CableData& data, QObject* parent);
56 
57  void update(const CableData&);
58 
59  CableData toCableData() const;
60 
61  CableType type() const;
62  Path<Process::Outlet> source() const;
63  Path<Process::Inlet> sink() const;
64 
65  void setType(CableType type);
66  void resetCache() const noexcept override;
67 
68 public:
69  void typeChanged(CableType type) E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, typeChanged, type)
70 
71 private:
72  CableType m_type{};
73  Path<Process::Outlet> m_source;
74  Path<Process::Inlet> m_sink;
75 
76  W_PROPERTY(Path<Process::Inlet>, sink READ sink)
77 
78  W_PROPERTY(Path<Process::Outlet>, source READ source)
79 
80  W_PROPERTY(CableType, type READ type WRITE setType NOTIFY typeChanged)
81 };
82 }
83 
84 DEFAULT_MODEL_METADATA(Process::Cable, "Cable")
85 
86 W_REGISTER_ARGTYPE(Id<Process::Cable>)
87 W_REGISTER_ARGTYPE(Process::CableType)
The IdentifiedObject class.
Definition: IdentifiedObject.hpp:19
Definition: QmlObjects.hpp:51
Definition: Cable.hpp:38
The Selectable class.
Definition: Selectable.hpp:14
The id_base_t class.
Definition: Identifier.hpp:57
TreeNode< DeviceExplorerNode > Node
Definition: DeviceNode.hpp:74
Base classes and tools to implement processes and layers.
Definition: JSONVisitor.hpp:1324
Definition: CableData.hpp:18