Commit ec62511413e83ebf8bab64e33142a77e61bd9ba8

Authored by Jojo-1000
Committed by Moritz Wirger
1 parent ea867228

Update documentation for changed light access.

README.md
... ... @@ -61,15 +61,15 @@ hueplusplus::Hue bridge("192.168.2.102", 80, "<username>", handler);
61 61  
62 62 ### Controlling lights
63 63 If you have your Bridge all set up, you can now control its lights.
64   -For that create a new HueLight object and call getLight(\<id\>) on your bridge object to get a reference to a specific light, where id
  64 +For that create a new HueLight object and call lights().get(\<id\>) on your bridge object to get a reference to a specific light, where id
65 65 is the id of the light set internally by the Hue Bridge.
66 66 ```C++
67   -hueplusplus::HueLight light1 = bridge.getLight(1);
  67 +hueplusplus::HueLight light1 = bridge.lights().get(1);
68 68 ```
69 69 If you don't know the id of a specific light or want to get an overview over all lights that are controlled by your bridge,
70   -you can get a vector containing them by calling getAllLights() on your bridge object. If no lights are found the vector will be empty.
  70 +you can get a vector containing them by calling getAll(). If no lights are found the vector will be empty.
71 71 ```C++
72   -std::vector<std::reference_wrapper<hueplusplus::HueLight>> lights = bridge.getAllLights();
  72 +std::vector<std::reference_wrapper<hueplusplus::HueLight>> lights = bridge.lights().getAll();
73 73 ```
74 74 If you now want to control a light, call a specific function of it.
75 75 ```C++
... ...
doc/markdown/Mainpage.md
... ... @@ -57,15 +57,15 @@ hueplusplus::Hue bridge(&quot;192.168.2.102&quot;, 80, &quot;&lt;username&gt;&quot;, handler);
57 57  
58 58 ### Controlling lights
59 59 If you have your Bridge all set up, you can now control its lights.
60   -For that create a new HueLight object and call [getLight(\<id\>)](@ref hueplusplus::Hue::getLight) on your bridge object to get a reference to a specific light, where id
  60 +For that create a new HueLight object and call [lights().get(\<id\>)](@ref hueplusplus::ResourceList::get) on your bridge object to get a reference to a specific light, where id
61 61 is the id of the light set internally by the Hue Bridge.
62 62 ```{.cpp}
63   -hueplusplus::HueLight light1 = bridge.getLight(1);
  63 +hueplusplus::HueLight light1 = bridge.lights().get(1);
64 64 ```
65 65 If you don't know the id of a specific light or want to get an overview over all lights that are controlled by your bridge,
66   -you can get a vector containing them by calling [getAllLights()](@ref hueplusplus::Hue::getAllLights) on your bridge object. If no lights are found the vector will be empty.
  66 +you can get a vector containing them by calling [getAll()](@ref hueplusplus::ResourceList::getAll) on your bridge object. If no lights are found the vector will be empty.
67 67 ```{.cpp}
68   -std::vector<std::reference_wrapper<hueplusplus::HueLight>> lights = bridge.getAllLights();
  68 +std::vector<std::reference_wrapper<hueplusplus::HueLight>> lights = bridge.lights().getAll();
69 69 ```
70 70 If you now want to control a light, call a specific function of it.
71 71 ```{.cpp}
... ...
include/hueplusplus/Hue.h
... ... @@ -151,11 +151,13 @@ public:
151 151 Hue(const std::string& ip, const int port, const std::string& username, std::shared_ptr<const IHttpHandler> handler,
152 152 std::chrono::steady_clock::duration refreshDuration = std::chrono::seconds(10));
153 153  
  154 + //! \brief Refreshes the bridge state.
  155 + //!
  156 + //! Should only be called rarely, as a full refresh is costly and usually not necessary.
  157 + //! Instead refresh only the parts you are interested in or rely on periodic refreshes
  158 + //! that happen automatically when calling non-const methods.
154 159 void refresh();
155 160  
156   - //! \name Configuration
157   - ///@{
158   -
159 161 //! \brief Function to get the ip address of the hue bridge
160 162 //!
161 163 //! \return string containing ip
... ... @@ -193,28 +195,46 @@ public:
193 195 //! "192.168.2.1:8080"
194 196 void setPort(const int port);
195 197  
196   - //! \brief Function that sets the HttpHandler and updates the HueCommandAPI.
197   - //!
198   - //! The HttpHandler and HueCommandAPI are used for bridge communication
199   - //! \param handler a HttpHandler of type \ref IHttpHandler
200   - void setHttpHandler(std::shared_ptr<const IHttpHandler> handler);
201   -
  198 + //! \brief Provides access to the configuration of the bridge.
202 199 BridgeConfig& config();
  200 + //! \brief Provides access to the configuration of the bridge.
  201 + //! \note Does not refresh state.
203 202 const BridgeConfig& config() const;
204   -
  203 +
  204 + //! \brief Provides access to the HueLight%s on the bridge.
205 205 LightList& lights();
  206 + //! \brief Provides access to the HueLight%s on the bridge.
  207 + //! \note Does not refresh state.
206 208 const LightList& lights() const;
207 209  
  210 + //! \brief Provides access to the Group%s on the bridge.
208 211 GroupList& groups();
  212 + //! \brief Provides access to the Group%s on the bridge.
  213 + //! \note Does not refresh state.
209 214 const GroupList& groups() const;
210 215  
  216 + //! \brief Provides access to the Schedule%s on the bridge.
211 217 ScheduleList& schedules();
  218 + //! \brief Provides access to the Schedule%s on the bridge.
  219 + //! \note Does not refresh state.
212 220 const ScheduleList& schedules() const;
213 221  
  222 + //! \brief Provides access to the Scene%s on the bridge.
214 223 SceneList& scenes();
  224 + //! \brief Provides access to the Scene%s on the bridge.
  225 + //! \note Does not refresh state.
215 226 const SceneList& scenes() const;
216 227  
217 228 private:
  229 + //! \brief Function that sets the HttpHandler and updates the HueCommandAPI.
  230 + //! \param handler a HttpHandler of type \ref IHttpHandler
  231 + //!
  232 + //! The HttpHandler and HueCommandAPI are used for bridge communication.
  233 + //! Resetting the HttpHandler should only be done when the username is first set,
  234 + //! before Hue is used.
  235 + //! Resets all caches and resource lists.
  236 + void setHttpHandler(std::shared_ptr<const IHttpHandler> handler);
  237 +private:
218 238 std::string ip; //!< IP-Address of the hue bridge in dotted decimal notation
219 239 //!< like "192.168.2.1"
220 240 std::string username; //!< Username that is ussed to access the hue bridge
... ...