| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#pragma once |
| 22 |
|
| 23 |
#include <string> |
| 24 |
|
| 25 |
#include "DataModel/Accessory.h" |
| 26 |
#include "DataModel/Signal.h" |
| 27 |
#include "DataModel/Switch.h" |
| 28 |
#include "Hardware/AccessoryCache.h" |
| 29 |
|
| 30 |
namespace DataModel |
| 31 |
{ |
| 32 |
class AccessoryConfig |
| 33 |
{ |
| 34 |
public: |
| 35 |
inline AccessoryConfig() |
| 36 |
: controlId(ControlNone), |
| 37 |
address(AddressDefault), |
| 38 |
protocol(ProtocolNone), |
| 39 |
isInUse(false) |
| 40 |
{ |
| 41 |
} |
| 42 |
|
| 43 |
inline AccessoryConfig(const DataModel::Accessory& accessory) |
| 44 |
: controlId(accessory.GetControlID()), |
| 45 |
objectIdentifier(ObjectTypeAccessory, accessory.GetID()), |
| 46 |
address(accessory.GetAddress()), |
| 47 |
protocol(accessory.GetProtocol()), |
| 48 |
name(accessory.GetName()), |
| 49 |
matchKey(accessory.GetMatchKey()), |
| 50 |
isInUse(accessory.IsInUse()) |
| 51 |
{ |
| 52 |
} |
| 53 |
|
| 54 |
inline AccessoryConfig(const DataModel::Signal& signal) |
| 55 |
: controlId(signal.GetControlID()), |
| 56 |
objectIdentifier(ObjectTypeSignal, signal.GetID()), |
| 57 |
address(signal.GetAddress()), |
| 58 |
protocol(signal.GetProtocol()), |
| 59 |
name(signal.GetName()), |
| 60 |
matchKey(signal.GetMatchKey()), |
| 61 |
isInUse(signal.IsInUse()) |
| 62 |
{ |
| 63 |
} |
| 64 |
|
| 65 |
inline AccessoryConfig(const DataModel::Switch& mySwitch) |
| 66 |
: controlId(mySwitch.GetControlID()), |
| 67 |
objectIdentifier(ObjectTypeSwitch, mySwitch.GetID()), |
| 68 |
address(mySwitch.GetAddress()), |
| 69 |
protocol(mySwitch.GetProtocol()), |
| 70 |
name(mySwitch.GetName()), |
| 71 |
matchKey(mySwitch.GetMatchKey()), |
| 72 |
isInUse(mySwitch.IsInUse()) |
| 73 |
{ |
| 74 |
} |
| 75 |
|
| 76 |
inline AccessoryConfig(const Hardware::AccessoryCacheEntry& entry) |
| 77 |
: controlId(entry.GetControlID()), |
| 78 |
objectIdentifier(entry.GetObjectIdentifier()), |
| 79 |
address(entry.GetAddress()), |
| 80 |
protocol(entry.GetProtocol()), |
| 81 |
name(entry.GetName()), |
| 82 |
matchKey(entry.GetMatchKey()), |
| 83 |
isInUse(false) |
| 84 |
{ |
| 85 |
} |
| 86 |
|
| 87 |
inline AccessoryConfig& operator=(const DataModel::Accessory& accessory) |
| 88 |
{ |
| 89 |
controlId = accessory.GetControlID(); |
| 90 |
objectIdentifier = ObjectIdentifier(ObjectTypeAccessory, accessory.GetID()); |
| 91 |
address = accessory.GetAddress(); |
| 92 |
protocol = accessory.GetProtocol(); |
| 93 |
name = accessory.GetName(); |
| 94 |
matchKey = accessory.GetMatchKey(); |
| 95 |
isInUse = accessory.IsInUse(); |
| 96 |
return *this; |
| 97 |
} |
| 98 |
|
| 99 |
inline AccessoryConfig& operator=(const DataModel::Signal& signal) |
| 100 |
{ |
| 101 |
controlId = signal.GetControlID(); |
| 102 |
objectIdentifier = ObjectIdentifier(ObjectTypeSignal, signal.GetID()); |
| 103 |
address = signal.GetAddress(); |
| 104 |
protocol = signal.GetProtocol(); |
| 105 |
name = signal.GetName(); |
| 106 |
matchKey = signal.GetMatchKey(); |
| 107 |
isInUse = signal.IsInUse(); |
| 108 |
return *this; |
| 109 |
} |
| 110 |
|
| 111 |
inline AccessoryConfig& operator=(const DataModel::Switch& accessory) |
| 112 |
{ |
| 113 |
controlId = accessory.GetControlID(); |
| 114 |
objectIdentifier = ObjectIdentifier(ObjectTypeSwitch, accessory.GetID()); |
| 115 |
address = accessory.GetAddress(); |
| 116 |
protocol = accessory.GetProtocol(); |
| 117 |
name = accessory.GetName(); |
| 118 |
matchKey = accessory.GetMatchKey(); |
| 119 |
isInUse = accessory.IsInUse(); |
| 120 |
return *this; |
| 121 |
} |
| 122 |
|
| 123 |
inline AccessoryConfig& operator=(const Hardware::AccessoryCacheEntry& entry) |
| 124 |
{ |
| 125 |
controlId = entry.GetControlID(); |
| 126 |
objectIdentifier = entry.GetObjectIdentifier(); |
| 127 |
address = entry.GetAddress(); |
| 128 |
protocol = entry.GetProtocol(); |
| 129 |
name = entry.GetName(); |
| 130 |
matchKey = entry.GetMatchKey(); |
| 131 |
return *this; |
| 132 |
} |
| 133 |
|
| 134 |
inline ControlID GetControlId() const |
| 135 |
{ |
| 136 |
return controlId; |
| 137 |
} |
| 138 |
|
| 139 |
inline ObjectIdentifier GetObjectIdentifier() const |
| 140 |
{ |
| 141 |
return objectIdentifier; |
| 142 |
} |
| 143 |
|
| 144 |
inline Address GetAddress() const |
| 145 |
{ |
| 146 |
return address; |
| 147 |
} |
| 148 |
|
| 149 |
inline Protocol GetProtocol() const |
| 150 |
{ |
| 151 |
return protocol; |
| 152 |
} |
| 153 |
|
| 154 |
inline std::string GetName() const |
| 155 |
{ |
| 156 |
return name; |
| 157 |
} |
| 158 |
|
| 159 |
inline void SetName(const std::string& name) |
| 160 |
{ |
| 161 |
this->name = name; |
| 162 |
} |
| 163 |
|
| 164 |
inline std::string GetMatchKey() const |
| 165 |
{ |
| 166 |
return matchKey; |
| 167 |
} |
| 168 |
|
| 169 |
inline bool IsInUse() const |
| 170 |
{ |
| 171 |
return isInUse; |
| 172 |
} |
| 173 |
|
| 174 |
private: |
| 175 |
ControlID controlId; |
| 176 |
ObjectIdentifier objectIdentifier; |
| 177 |
Address address; |
| 178 |
Protocol protocol; |
| 179 |
std::string name; |
| 180 |
std::string matchKey; |
| 181 |
bool isInUse; |
| 182 |
}; |
| 183 |
} |