MT Showcase SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
SynchronousGenerators.hpp
1 #ifndef SYNCHRONOUSGENERATORS_HPP
2 #define SYNCHRONOUSGENERATORS_HPP
3 
4 #include "Export.hpp"
5 #include "GraphGenerators.hpp"
6 
7 namespace Showcase
8 {
9  class SHOWCASE_API SynchronousGraphGenerator : public SynchronousGenerator<GraphGenerator>
10  {
11  protected:
12  virtual NodeEvent generateNextItem() override;
13 
14  private:
15  virtual void queryNewItems(std::vector<QString> & to) = 0;
16  virtual NodeEvent createEvent(const QString & item, bool found = true) const = 0;
17  virtual NodeId createNodeId() const = 0;
18 
19  NodeEvent updateCache();
20 
21  std::vector<QString> m_prevItemsFound; // paths to children
22  std::vector<QString> m_itemsFound;
23  std::vector<QString> m_itemsRemoved;
24  };
25 
26  //--------------------------------------------------------------------
27 
28  class SHOWCASE_API SynchronousPropertyGenerator : public SynchronousGenerator<PropertyGenerator>
29  {
30  public:
31  SynchronousPropertyGenerator();
32 
33  virtual bool init(const GraphNode & n) override;
34  virtual bool init(const GraphEdge & e) override;
35 
36  virtual void queryProperties(PropertyMap & ) = 0;
37 
38  EdgeId queryIdentifier() const { return m_queryIdentifier; }
39  bool isEdgeQuery() const { return m_isEdgeQuery; }
40 
41  protected:
42  virtual PropertyEvent generateNextItem() override;
43 
44  private:
45  PropertyEvent createEvent(PropertyMap & props, PropertyEventType type);
46  PropertyEvent updateCache();
47 
48  EdgeId m_queryIdentifier;
49  bool m_isEdgeQuery;
50 
51  PropertyMap m_prevItems;
52 
53  PropertyMap m_itemsFound;
54  PropertyMap m_itemsRemoved;
55  PropertyMap m_itemsChanged;
56  };
57 }
58 
59 #endif // SYNCHRONOUSGENERATORS_HPP