hueplusplus  1.0.0
BaseDevice.h
Go to the documentation of this file.
1 
23 #ifndef INCLUDE_HUEPLUSPLUS_HUE_THING_H
24 #define INCLUDE_HUEPLUSPLUS_HUE_THING_H
25 
26 #include <memory>
27 
28 #include "APICache.h"
29 
30 #include "json/json.hpp"
31 
32 namespace hueplusplus
33 {
36 {
37 public:
39  virtual ~BaseDevice() = default;
40 
44  virtual int getId() const;
45 
49  virtual std::string getType() const;
50 
58  virtual std::string getName();
59 
64  virtual std::string getName() const;
65 
69  virtual std::string getModelId() const;
70 
75  virtual std::string getUId() const;
76 
81  virtual std::string getManufacturername() const;
82 
87  virtual std::string getProductname() const;
88 
96  virtual std::string getSwVersion();
97 
102  virtual std::string getSwVersion() const;
103 
111  virtual bool setName(const std::string& name);
112 
120  virtual void refresh(bool force = false);
121 
124  virtual void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration);
125 
126 protected:
130  BaseDevice(int id, const std::shared_ptr<APICache>& baseCache);
138  BaseDevice(int id, const HueCommandAPI& commands, const std::string& path,
139  std::chrono::steady_clock::duration refreshDuration, const nlohmann::json& currentState);
140 
151  virtual nlohmann::json sendPutRequest(const std::string& subPath, const nlohmann::json& request, FileInfo fileInfo);
152 
153 protected:
154  int id;
156 };
157 } // namespace hueplusplus
158 
159 #endif
Definition: HueCommandAPI.h:37
int id
holds the id of the device
Definition: BaseDevice.h:154
virtual int getId() const
Const function that returns the id of this device.
Definition: BaseDevice.cpp:34
Namespace for the hueplusplus library.
Definition: Action.h:27
virtual std::string getManufacturername() const
Const function that returns the manufacturername of the device.
Definition: BaseDevice.cpp:64
Caches API GET requests and refreshes regularly.
Definition: APICache.h:37
virtual std::string getUId() const
Const function that returns the uniqueid of the device.
Definition: BaseDevice.cpp:59
Base class for physical devices connected to the bridge (sensor or light).
Definition: BaseDevice.h:35
virtual std::string getProductname() const
Const function that returns the productname of the device.
Definition: BaseDevice.cpp:69
virtual std::string getName()
Function that returns the name of the device.
Definition: BaseDevice.cpp:44
Contains information about error location, use CURRENT_FILE_INFO to create.
Definition: HueException.h:34
APICache state
holds the current state of the device
Definition: BaseDevice.h:155
virtual void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration)
Sets custom refresh interval for this device.
Definition: BaseDevice.cpp:123
virtual std::string getSwVersion()
Function that returns the software version of the device.
Definition: BaseDevice.cpp:74
virtual std::string getType() const
Const function that returns the device type.
Definition: BaseDevice.cpp:39
virtual ~BaseDevice()=default
Virtual destructor.
virtual void refresh(bool force=false)
Refreshes internal cached state.
Definition: BaseDevice.cpp:111
virtual std::string getModelId() const
Const function that returns the modelid of the device.
Definition: BaseDevice.cpp:54
virtual bool setName(const std::string &name)
Function that sets the name of the device.
Definition: BaseDevice.cpp:84
BaseDevice(int id, const std::shared_ptr< APICache > &baseCache)
Protected ctor that is used by subclasses, construct with shared cache.
Definition: BaseDevice.cpp:94
virtual nlohmann::json sendPutRequest(const std::string &subPath, const nlohmann::json &request, FileInfo fileInfo)
Utility function to send a put request to the device.
Definition: BaseDevice.cpp:106