28 std::vector<BaseDevice> result;
29 for (
const auto &it :
data)
31 result.push_back(it.second.device);
38 auto it =
data.find(name);
44 auto &it =
data[name];
45 if (!it.device.isValid())
47 it.device = constructor();
48 it.device.setDeviceName(name);
78 data[deviceName].newDeviceCallback = callback;
84 data[deviceName].properties.insert(propertyName);
94 for (
auto &deviceInfo :
data)
102 for (
auto it =
data.begin(); it !=
data.end();)
104 if (it->second.device ==
device)
118 if (!deviceName.isValid() || deviceName.toString() ==
"" || !
isDeviceWatched(deviceName))
127 if (deviceInfo.properties.size() != 0)
130 if (it == deviceInfo.properties.end())
134 static const std::set<std::string> defVectors{
135 "defTextVector",
"defNumberVector",
"defSwitchVector",
136 "defLightVector",
"defBLOBVector"
139 if (defVectors.find(root.
tagName()) != defVectors.end())
141 return deviceInfo.device.buildProp(root, errmsg);
144 static const std::set<std::string> setVectors{
145 "setTextVector",
"setNumberVector",
"setSwitchVector",
146 "setLightVector",
"setBLOBVector"
149 if (setVectors.find(root.
tagName()) != setVectors.end())
151 return deviceInfo.device.setValue(root, errmsg);
Class to provide basic INDI device functionality.
std::string tagName() const
LilXmlAttribute getAttribute(const char *name) const
std::string toString() const
The class is used to create device instances. Class copying is not allowed. When an object is destroy...
void watchProperty(const std::string &deviceName, const std::string &propertyName)
bool isDeviceWatched(const char *deviceName) const
checks if the device is being watched by something
std::vector< BaseDevice > getDevices() const
DeviceInfo & ensureDeviceByName(const char *name, const std::function< ParentDevice()> &constructor)
std::map< std::string, DeviceInfo > data
BaseDevice getDeviceByName(const char *name)
std::set< std::string > watchedDevice
void watchDevice(const std::string &deviceName)
int processXml(const INDI::LilXmlElement &root, char *errmsg, const std::function< ParentDevice()> &constructor=[] { return ParentDevice(ParentDevice::Valid);})
bool deleteDevice(const BaseDevice &device)
Namespace to encapsulate INDI client, drivers, and mediator classes.