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

#include <hueplusplus/HueDeviceTypes.h>

Public Member Functions

 LightFactory (const HueCommandAPI &commands, std::chrono::steady_clock::duration refreshDuration)
 Create a factory for Lights. More...
 
Light createLight (const nlohmann::json &lightState, int id, const std::shared_ptr< APICache > &baseCache={})
 Create a Light with the correct type from the JSON state. More...
 

Constructor & Destructor Documentation

◆ LightFactory()

hueplusplus::LightFactory::LightFactory ( const HueCommandAPI commands,
std::chrono::steady_clock::duration  refreshDuration 
)

Create a factory for Lights.

Parameters
commandsHueCommandAPI for communication with the bridge
refreshDurationTime between refreshing the cached light state.

Member Function Documentation

◆ createLight()

Light hueplusplus::LightFactory::createLight ( const nlohmann::json &  lightState,
int  id,
const std::shared_ptr< APICache > &  baseCache = {} 
)

Create a Light with the correct type from the JSON state.

Parameters
lightStateLight JSON as returned from the bridge (not only the "state" part of it).
idLight id.
baseCacheOptional shared cache for the light.
Returns
Light with matching id, strategies and ColorType.
Exceptions
std::system_errorwhen system or socket operations fail
HueExceptionwhen light type is unknown
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

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