hueplusplus  1.0.0
Schedule.h
Go to the documentation of this file.
1 
22 #ifndef INCLUDE_HUEPLUSPLUS_SCHEDULE_H
23 #define INCLUDE_HUEPLUSPLUS_SCHEDULE_H
24 
25 #include "APICache.h"
26 #include "Action.h"
27 #include "TimePattern.h"
28 
29 namespace hueplusplus
30 {
34 class Schedule
35 {
36 public:
40  Schedule(int id, const std::shared_ptr<APICache>& baseCache);
46  Schedule(int id, const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration, const nlohmann::json& currentState);
47 
53  void refresh();
54 
57  void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration);
58 
60  int getId() const;
61 
65  std::string getName() const;
67  std::string getDescription() const;
69  Action getCommand() const;
72  time::TimePattern getTime() const;
74  bool isEnabled() const;
79  bool getAutodelete() const;
87 
95  void setName(const std::string& name);
102  void setDescription(const std::string& description);
109  void setCommand(const Action& command);
116  void setTime(const time::TimePattern& timePattern);
125  void setEnabled(bool enabled);
132  void setAutodelete(bool autodelete);
133 
134 private:
140  void sendPutRequest(const nlohmann::json& request, FileInfo fileInfo);
141 
142 private:
143  int id;
144  APICache state;
145 };
146 
151 {
152 public:
155  CreateSchedule& setName(const std::string& name);
158  CreateSchedule& setDescription(const std::string& description);
161  CreateSchedule& setCommand(const Action& command);
167  CreateSchedule& setStatus(bool enabled);
170  CreateSchedule& setAutodelete(bool autodelete);
174  CreateSchedule& setRecycle(bool recycle);
175 
178  nlohmann::json getRequest() const;
179 
180 private:
181  nlohmann::json request;
182 };
183 
184 } // namespace hueplusplus
185 
186 #endif
void setName(const std::string &name)
Set schedule name.
Definition: Schedule.cpp:98
Parameters for creating a new Schedule.
Definition: Schedule.h:150
Definition: HueCommandAPI.h:37
Schedule stored in the bridge.
Definition: Schedule.h:34
void refresh()
Refreshes internal cached state.
Definition: Schedule.cpp:37
Action executed by the bridge, e.g. as a Schedule command.
Definition: Action.h:35
std::string getName() const
Get schedule name.
Definition: Schedule.cpp:52
Namespace for the hueplusplus library.
Definition: Action.h:27
void setCommand(const Action &command)
Set schedule command.
Definition: Schedule.cpp:110
Caches API GET requests and refreshes regularly.
Definition: APICache.h:37
time::AbsoluteTime getStartTime() const
Get start time for timers.
Definition: Schedule.cpp:93
Holds different time representations.
Definition: TimePattern.h:351
Contains information about error location, use CURRENT_FILE_INFO to create.
Definition: HueException.h:34
time::AbsoluteTime getCreated() const
Get created time.
Definition: Schedule.cpp:88
One-time, absolute time point.
Definition: TimePattern.h:72
time::TimePattern getTime() const
Get time when the event(s) will occur.
Definition: Schedule.cpp:67
void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration)
Sets custom refresh interval for this schedule.
Definition: Schedule.cpp:42
Action getCommand() const
Get schedule command.
Definition: Schedule.cpp:62
void setTime(const time::TimePattern &timePattern)
Set new time when the event will occur.
Definition: Schedule.cpp:116
Schedule(int id, const std::shared_ptr< APICache > &baseCache)
Creates schedule with shared cache.
Definition: Schedule.cpp:27
void setEnabled(bool enabled)
Enable or disable schedule.
Definition: Schedule.cpp:130
std::string getDescription() const
Get schedule description.
Definition: Schedule.cpp:57
bool isEnabled() const
Check whether schedule is enabled or disabled.
Definition: Schedule.cpp:74
void setDescription(const std::string &description)
Set schedule description.
Definition: Schedule.cpp:104
int getId() const
Get schedule identifier.
Definition: Schedule.cpp:47
bool getAutodelete() const
Get autodelete.
Definition: Schedule.cpp:83
void setAutodelete(bool autodelete)
Set autodelete.
Definition: Schedule.cpp:136