Cable.hpp
1 #pragma once
2 #include <State/Address.hpp>
3 
4 #include <score/model/IdentifiedObject.hpp>
5 #include <score/model/path/Path.hpp>
6 #include <score/selection/Selectable.hpp>
7 
8 #include <QUuid>
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 enum class CableType
37 {
38  ImmediateGlutton,
39  ImmediateStrict,
40  DelayedGlutton,
41  DelayedStrict
42 };
43 
44 struct SCORE_LIB_PROCESS_EXPORT CableData
45 {
46  CableType type{};
47  Path<Process::Port> source, sink;
48 
49  SCORE_LIB_PROCESS_EXPORT
50  friend bool operator==(const CableData& lhs, const CableData& rhs);
51 };
52 
53 class SCORE_LIB_PROCESS_EXPORT Cable final : public IdentifiedObject<Cable>
54 {
55  W_OBJECT(Cable)
56  SCORE_SERIALIZE_FRIENDS
57 
58 public:
59  Selectable selection{this};
60  Cable() = delete;
61  ~Cable();
62  Cable(const Cable&) = delete;
63  Cable(Id<Cable> c, QObject* parent);
64 
65  template <typename T>
66  Cable(T&& vis, QObject* parent)
67  : IdentifiedObject{vis, parent}
68  {
69  vis.writeTo(*this);
70  }
71  Cable(Id<Cable> c, const CableData& data, QObject* parent);
72 
73  void update(const CableData&);
74 
75  CableData toCableData() const;
76 
77  CableType type() const;
78  Path<Process::Outlet> source() const;
79  Path<Process::Inlet> sink() const;
80 
81  void setType(CableType type);
82  void resetCache() const noexcept override;
83 
84 public:
85  void typeChanged(CableType type) E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, typeChanged, type)
86 
87 private:
88  CableType m_type{};
89  Path<Process::Outlet> m_source;
90  Path<Process::Inlet> m_sink;
91 
92  W_PROPERTY(Path<Process::Inlet>, sink READ sink)
93 
94  W_PROPERTY(Path<Process::Outlet>, source READ source)
95 
96  W_PROPERTY(CableType, type READ type WRITE setType NOTIFY typeChanged)
97 };
98 }
99 
100 DEFAULT_MODEL_METADATA(Process::Cable, "Cable")
101 
102 W_REGISTER_ARGTYPE(Id<Process::Cable>)
103 W_REGISTER_ARGTYPE(Process::CableType)
The IdentifiedObject class.
Definition: IdentifiedObject.hpp:19
Definition: QmlObjects.hpp:46
Definition: Cable.hpp:54
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: Cable.hpp:45