MT Showcase SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Schema.hpp
1 #pragma once
2 
3 #include <QString>
4 #include <QVariant>
5 
6 #include <set>
7 #include <unordered_map>
8 #include <unordered_set>
9 
10 #include "Export.hpp"
11 
12 #include "Hashes.hpp"
13 #include "SchemaAttribute.hpp"
14 #include "Slot.hpp"
15 
16 #include <boost/expected/expected.hpp>
17 
18 namespace Showcase
19 {
20  enum class EventDirection
21  {
22  EVENT_IN,
23  EVENT_OUT
24  };
25  typedef std::unordered_set<QByteArray> Events;
26 
29  class SHOWCASE_API Schema
30  {
31  public:
32  Schema();
33  ~Schema();
34 
35  const std::unordered_set<QByteArray>& roles() const;
36  const Slots& componentSlots() const;
37  QByteArray subtype() const;
40  const Events & events(EventDirection type) const;
41 
44  bool passEvents(EventDirection type) const;
45 
46  void parse(const QString& path);
47  void parseSlots(const QVariantMap& slotMap);
48 
49  void addSlot(const Slot& slot);
50 
51  static void parseSchemaAttributes(SchemaAttributeMap& attrs, const QVariantList &list);
52 
53  const SchemaAttributeMap & attributes() const;
54 
55  bool isValidAttribute(const QByteArray & name) const;
56 
57  bool dataGatheringEnabled() const;
58 
59  private:
60  void includeSchema(const QString & path);
61 
62  std::unordered_set<QByteArray> m_roles;
63 
64  QByteArray m_subtype;
65 
66  Events m_eventsIn;
67  Events m_eventsOut;
68 
69  boost::expected<bool> m_passEventsIn;
70  boost::expected<bool> m_passEventsOut;
71  boost::expected<bool> m_dataGathering;
72 
73  Slots m_slots;
74  SchemaAttributeMap m_attributes;
75  };
76 
77 }