DeviceList.h
Go to the documentation of this file.
1 
20 #pragma once
21 
22 #include "Device.h"
23 #include <WVector.h>
24 
25 namespace Hue
26 {
28 
30 {
31 public:
32  DeviceListEnumerator(DeviceList& list) : list(list)
33  {
34  }
35 
37  {
38  return new DeviceListEnumerator(*this);
39  }
40 
41  void reset() override
42  {
43  index = 0;
44  }
45 
46  Device* current() override
47  {
48  return (size_t(index) < list.count()) ? &list[index] : nullptr;
49  }
50 
51  Device* next() override
52  {
53  return (size_t(index) < list.count()) ? &list[index++] : nullptr;
54  }
55 
56 private:
57  DeviceList& list;
58  int index{-1};
59 };
60 
61 } // namespace Hue
Definition: Bridge.h:29
void reset() override
Definition: DeviceList.h:41
Definition: DeviceList.h:29
Vector class template.
Definition: WVector.h:30
Definition: Libraries/HueEmulator/src/include/Hue/Device.h:92
unsigned int count() const override
Definition: WVector.h:105
Device * current() override
Definition: DeviceList.h:46
DeviceListEnumerator(DeviceList &list)
Definition: DeviceList.h:32
Device * next() override
Definition: DeviceList.h:51
Device::Enumerator * clone() override
Definition: DeviceList.h:36
Abstract class to manage a list of devices.
Definition: Libraries/HueEmulator/src/include/Hue/Device.h:125