MT Showcase SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Slot.hpp
1 #pragma once
2 
3 #include "Export.hpp"
4 #include "SchemaAttribute.hpp"
5 
6 #include <memory>
7 #include <set>
8 #include <utility>
9 
10 namespace Showcase
11 {
12  class Slot;
13  typedef std::set<Slot> Slots;
14 
16  class SHOWCASE_API Slot
17  {
18  public:
19  typedef std::map<QByteArray, Range<unsigned> > SlotRanges;
20 
21  struct Hasher
22  {
23  size_t operator()(const Slot& slot) const
24  {
25  return std::hash<QByteArray>()(slot.name());
26  }
27  };
28 
30  enum class SlotType {
32  GRAPH,
34  UI_COMPONENT,
36  TRIGGER_COMPONENT,
37 
38  SCHEDULE_COMPONENT,
39 
40  INVALID
41  };
42 
43  Slot();
44  Slot(const Slot& slot);
45  Slot(SlotType type);
46  Slot & operator=(const Slot & slot);
47 
48 
49  SlotType type() const;
50  void setType(SlotType type);
51 
52  void setName(const QByteArray& name);
53  const QByteArray& name() const;
54 
55  void setRange(Range<unsigned> r);
56  void setRange(Range<unsigned> r, const QByteArray & keyword);
57  void setRange(const SlotRanges & ranges);
58  Range<unsigned> range() const;
59  Range<unsigned> range(const QByteArray & keyword) const;
60 
61  static Slot parse(const QVariantMap& map);
62  static SlotType stringTotype(const QString& type);
63 
64 
65  const SchemaAttributeMap& attributes() const;
66  const Slots& nodeSlots() const;
67 
68  // -------- Support for std::containers -----------------
69  // @note comparisons care only about the name of the slot
70  bool operator<(const Slot& slot) const;
71  bool operator==(const Slot& slot) const;
72 
73  private:
74  QByteArray m_name;
75  SlotType m_slotType;
76  std::map<QByteArray, Range<unsigned> > m_range;
77  Range<unsigned> m_defaultRange;
78 
80  SchemaAttributeMap m_nodeAttributes;
81 
84  std::unique_ptr<Slots> m_nodeSlots{new Slots()};
85  };
86 
87 }
88