Loading...
Searching...
No Matches
BaseDevice.h
Go to the documentation of this file.
#ifndef INCLUDE_HUEPLUSPLUS_HUE_THING_H
#define INCLUDE_HUEPLUSPLUS_HUE_THING_H
#include <memory>
#include "APICache.h"
#include <nlohmann/json.hpp>
namespace hueplusplus
{
class BaseDevice
{
public:
virtual ~BaseDevice() = default;
virtual int getId() const;
virtual std::string getType() const;
virtual std::string getName();
virtual std::string getName() const;
virtual std::string getModelId() const;
virtual std::string getUId() const;
virtual std::string getManufacturername() const;
virtual std::string getProductname() const;
virtual std::string getSwVersion();
virtual std::string getSwVersion() const;
virtual bool setName(const std::string& name);
virtual void refresh(bool force = false);
virtual void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration);
protected:
BaseDevice(int id, const std::shared_ptr<APICache>& baseCache);
BaseDevice(int id, const HueCommandAPI& commands, const std::string& path,
std::chrono::steady_clock::duration refreshDuration, const nlohmann::json& currentState);
virtual nlohmann::json sendPutRequest(const std::string& subPath, const nlohmann::json& request, FileInfo fileInfo);
protected:
int id;
APICache state;
};
} // namespace hueplusplus
#endif
APICache.h
hueplusplus::APICache
Caches API GET requests and refreshes regularly.
Definition APICache.h:38
hueplusplus::BaseDevice::getId
virtual int getId() const
Const function that returns the id of this device.
Definition BaseDevice.cpp:34
hueplusplus::BaseDevice::BaseDevice
BaseDevice(int id, const std::shared_ptr< APICache > &baseCache)
Protected ctor that is used by subclasses, construct with shared cache.
Definition BaseDevice.cpp:94
hueplusplus::BaseDevice::state
APICache state
holds the current state of the device
Definition BaseDevice.h:155
hueplusplus::BaseDevice::getName
virtual std::string getName()
Function that returns the name of the device.
Definition BaseDevice.cpp:44
hueplusplus::BaseDevice::getProductname
virtual std::string getProductname() const
Const function that returns the productname of the device.
Definition BaseDevice.cpp:69
hueplusplus::BaseDevice::setRefreshDuration
virtual void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration)
Sets custom refresh interval for this device.
Definition BaseDevice.cpp:123
hueplusplus::BaseDevice::getType
virtual std::string getType() const
Const function that returns the device type.
Definition BaseDevice.cpp:39
hueplusplus::BaseDevice::getUId
virtual std::string getUId() const
Const function that returns the uniqueid of the device.
Definition BaseDevice.cpp:59
hueplusplus::BaseDevice::id
int id
holds the id of the device
Definition BaseDevice.h:154
hueplusplus::BaseDevice::refresh
virtual void refresh(bool force=false)
Refreshes internal cached state.
Definition BaseDevice.cpp:111
hueplusplus::BaseDevice::getModelId
virtual std::string getModelId() const
Const function that returns the modelid of the device.
Definition BaseDevice.cpp:54
hueplusplus::BaseDevice::~BaseDevice
virtual ~BaseDevice()=default
Virtual destructor.
hueplusplus::BaseDevice::setName
virtual bool setName(const std::string &name)
Function that sets the name of the device.
Definition BaseDevice.cpp:84
hueplusplus::BaseDevice::sendPutRequest
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
hueplusplus::BaseDevice::getManufacturername
virtual std::string getManufacturername() const
Const function that returns the manufacturername of the device.
Definition BaseDevice.cpp:64
hueplusplus::BaseDevice::getSwVersion
virtual std::string getSwVersion()
Function that returns the software version of the device.
Definition BaseDevice.cpp:74
hueplusplus::HueCommandAPI
Definition HueCommandAPI.h:38
hueplusplus
Namespace for the hueplusplus library.
Definition Action.h:28
hueplusplus::FileInfo
Contains information about error location, use CURRENT_FILE_INFO to create.
Definition HueException.h:35