MT Showcase SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
ScheduleComponent.hpp
1 #pragma once
2 
3 #include "UIComponent.hpp"
4 #include "scheduling/ScheduledEvent.hpp"
5 
6 #include <QDateTime>
7 
8 namespace Showcase
9 {
11  class SHOWCASE_API ScheduleInstance : public UIComponentInstance
12  {
13  public:
14  ScheduleInstance(ComponentPtr component, ScheduledEventPtr instance);
15  virtual ~ScheduleInstance();
16 
17  virtual void removeInstance() override;
18 
19  virtual ScheduledEventPtr eventInstance();
20 
21  virtual void propertyReceived(const PropertyKey & key,
22  const PropertyValue & value) override;
23  virtual void propertyLost(const PropertyKey & key,
24  const PropertyValue & value) override;
25 
26  void setHostComponent(UIComponentPtr comp);
27 
28  private:
29  ScheduledEventWeakPtr m_instanceEvent;
30  ScheduledEventPtr m_strongRef;
31  };
32  typedef std::shared_ptr<ScheduleInstance> ScheduleInstancePtr;
33  typedef std::weak_ptr<ScheduleInstance> ScheduleInstanceWeakPtr;
34 
36 
38  class SHOWCASE_API ScheduleComponent : public UIComponent
39  {
40  public:
41  typedef std::function<ScheduledEventPtr(void)> CreateFunction;
42 
43  ScheduleComponent(CreateFunction create);
44  ScheduledEventPtr createEvent();
45 
46  protected:
47  virtual ComponentInstancePtr instanceImpl() override;
48 
49  private:
50  CreateFunction m_createFunc;
51  };
52  typedef std::shared_ptr<ScheduleComponent> ScheduleComponentPtr;
53 }
54 
55 #define SHOWCASE_SCHEDULE_COMPONENT(name, type) \
56 namespace {\
57 Showcase::FactoryRegistrant<Showcase::ScheduleComponent> MW_PLUGIN_CONCAT(component, __LINE__) \
58 (name, [] { return std::make_shared<Showcase::ScheduleComponent>(\
59  [] { return std::make_shared<type>(); } ); }); \
60 }