hueplusplus  1.0.0
Public Member Functions | Protected Member Functions | List of all members
hueplusplus::SensorList Class Reference

Handles a list of Sensors with type specific getters. More...

#include <hueplusplus/SensorList.h>

+ Inheritance diagram for hueplusplus::SensorList:
+ Collaboration diagram for hueplusplus::SensorList:

Public Member Functions

template<typename T >
getAsType (int id)
 Get sensor specified by id, convert to T. More...
 
template<typename T >
std::vector< T > getAllByType ()
 Get all sensors of type T. More...
 
- Public Member Functions inherited from hueplusplus::CreateableResourceList< SearchableResourceList< Sensor >, CreateSensor >
SearchableResourceList< Sensor > ::IdType create (const CreateSensor &params)
 Create a new resource. More...
 
- Public Member Functions inherited from hueplusplus::SearchableResourceList< Sensor >
void search (const std::vector< std::string > &deviceIds={})
 Start search for new devices. More...
 
NewDeviceList getNewDevices () const
 Get devices found in last search. More...
 
- Public Member Functions inherited from hueplusplus::ResourceList< Sensor, int >
 ResourceList (std::shared_ptr< APICache > baseCache, const std::string &cacheEntry, std::chrono::steady_clock::duration refreshDuration, bool sharedState=false, const std::function< Sensor(IdType, const nlohmann::json &, const std::shared_ptr< APICache > &)> &factory=nullptr)
 Construct ResourceList using a base cache and optional factory function. More...
 
 ResourceList (const HueCommandAPI &commands, const std::string &path, std::chrono::steady_clock::duration refreshDuration, const std::function< Sensor(IdType, const nlohmann::json &, const std::shared_ptr< APICache > &)> &factory=nullptr)
 Construct ResourceList with a separate cache and optional factory function. More...
 
 ResourceList (const ResourceList &)=delete
 Deleted copy constructor. More...
 
ResourceListoperator= (const ResourceList &)=delete
 Deleted copy assignment. More...
 
void refresh ()
 Refreshes internal state now. More...
 
void setRefreshDuration (std::chrono::steady_clock::duration refreshDuration)
 Sets custom refresh interval for this list and all resources created. More...
 
std::vector< SensorgetAll ()
 Get all resources that exist. More...
 
Sensor get (const IdType &id)
 Get resource specified by id. More...
 
bool exists (const IdType &id)
 Checks whether resource with id exists. More...
 
bool exists (const IdType &id) const
 Checks whether resource with id exists. More...
 
bool remove (const IdType &id)
 Removes the resource. More...
 

Protected Member Functions

 SensorList (SensorList &&)=default
 Protected defaulted move constructor. More...
 
SensorListoperator= (SensorList &&)=default
 Protected defaulted move assignment. More...
 
- Protected Member Functions inherited from hueplusplus::CreateableResourceList< SearchableResourceList< Sensor >, CreateSensor >
 CreateableResourceList (CreateableResourceList &&)=default
 Protected defaulted move constructor. More...
 
CreateableResourceListoperator= (CreateableResourceList &&)=default
 Protected defaulted move assignment. More...
 
- Protected Member Functions inherited from hueplusplus::SearchableResourceList< Sensor >
 SearchableResourceList (SearchableResourceList &&)=default
 Protected defaulted move constructor. More...
 
SearchableResourceListoperator= (SearchableResourceList &&)=default
 Protected defaulted move assignment. More...
 
- Protected Member Functions inherited from hueplusplus::ResourceList< Sensor, int >
 ResourceList (ResourceList &&)=default
 Protected defaulted move constructor. More...
 
ResourceListoperator= (ResourceList &&)=default
 Protected defaulted move assignment. More...
 
Sensor construct (const IdType &id, const nlohmann::json &state)
 Constructs resource using factory or constructor, if available. More...
 

Additional Inherited Members

- Public Types inherited from hueplusplus::ResourceList< Sensor, int >
using ResourceType = Sensor
 
using IdType = int
 
- Static Protected Member Functions inherited from hueplusplus::ResourceList< Sensor, int >
static IdType maybeStoi (const std::string &key)
 Calls std::stoi if IdType is int. More...
 
static std::string maybeToString (const IdType &id)
 Calls std::to_string if IdType is int. More...
 
- Protected Attributes inherited from hueplusplus::ResourceList< Sensor, int >
std::shared_ptr< APICachestateCache
 
std::function< Sensor(IdType, const nlohmann::json &, const std::shared_ptr< APICache > &)> factory
 
std::string path
 
bool sharedState
 

Detailed Description

Handles a list of Sensors with type specific getters.

Allows to directly get the requested sensor type or all sensors of a given type.

Constructor & Destructor Documentation

◆ SensorList()

hueplusplus::SensorList::SensorList ( SensorList &&  )
protecteddefault

Protected defaulted move constructor.

Member Function Documentation

◆ getAllByType()

template<typename T >
std::vector<T> hueplusplus::SensorList::getAllByType ( )
inline

Get all sensors of type T.

Template Parameters
TSensor type to get (from Sensors)
Returns
All sensors matching the type
Exceptions
HueExceptionwhen response contains no body
std::system_errorwhen system or socket operations fail
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

◆ getAsType()

template<typename T >
T hueplusplus::SensorList::getAsType ( int  id)
inline

Get sensor specified by id, convert to T.

Parameters
idSensor id
Template Parameters
TSensor type to convert to (from Sensors)
Returns
The sensor matching the id and type
Exceptions
HueExceptionwhen id does not exist or type does not match
std::system_errorwhen system or socket operations fail
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

◆ operator=()

SensorList& hueplusplus::SensorList::operator= ( SensorList &&  )
protecteddefault

Protected defaulted move assignment.


The documentation for this class was generated from the following file: