Lumiverse  2.5
A framework for creating lighting control applications
DynamicDeviceSet.h
Go to the documentation of this file.
1 
4 #ifndef _DYNAMICDEVICESET_H_
5 #define _DYNAMICDEVICESET_H_
6 
7 #pragma once
8 
9 #include <sstream>
10 #include <set>
11 #include <regex>
12 #include <functional>
13 
14 #include "Logger.h"
15 #include "Device.h"
16 #include "Rig.h"
17 #include "DeviceSet.h"
18 
19 namespace Lumiverse {
20  class Rig;
21  class LumiverseType;
22 
35  {
36  public:
43 
52  DynamicDeviceSet(Rig* rig, string query);
53 
59  DynamicDeviceSet(Rig* rig, JSONNode data);
60 
67 
72 
80  std::ostream & operator<< (std::ostream &str) {
81  str << info();
82  return str;
83  };
84 
90 
95  void setQuery(string query);
96 
100  string getQuery();
101 
102 
106  bool isQueryNull();
107 
112  void reset();
113 
114  // These must mirror the device setparam functions.
115 
125  void setParam(string param, float val);
126 
137  void setParam(string param, string val, float val2 = -1.0f);
138 
150  void setParam(string param, string channel, double val);
151 
157  void setParam(string param, string val, float val2, LumiverseEnum::Mode mode, LumiverseEnum::InterpolationMode interpMode);
158 
170  void setParam(string param, double x, double y, double weight = 1.0);
171 
179  void setColorRGBRaw(string param, double r, double g, double b, double weight = 1.0);
180 
186  void setColorRGB(string param, double r, double g, double b, double weight = 1.0, RGBColorSpace cs = sRGB);
187 
193  inline const set<Device *>& getDevices() { return m_rig->select(m_query).getDevices(); }
194 
198  vector<string> getIds();
199 
205  set<string> getAllParams();
206 
210  set<string> getAllMetadata();
211 
215  set<string> getAllMetadataForKey(string key);
216 
223  string info();
224 
229  inline size_t size() { return m_rig->select(m_query).size(); }
230 
239  bool hasSameIds(DynamicDeviceSet& devices);
240 
248  bool hasSameDevices(DynamicDeviceSet& devices);
249 
256  bool contains(Device* d);
257 
264  bool contains(string id);
265 
273  JSONNode toJSON(string name);
274 
275  private:
279  string m_query;
280 
285  };
286 }
287 
288 #endif
Represents a physical lighting Device in Lumiverse.
vector< string > getIds()
Gets a copy of the list of the IDs contained by this DynamicDeviceSet.
Definition: DynamicDeviceSet.cpp:57
DynamicDeviceSet()
Default constructor.
Definition: DynamicDeviceSet.h:42
The Rig contains information about the state of the lighting system.
bool isQueryNull()
Returns true if the query string is empty.
Definition: DynamicDeviceSet.cpp:123
DeviceSet getDeviceSet()
Gets a DeviceSet containing the devices that match the query at the time this function is called...
Definition: DynamicDeviceSet.cpp:21
string getQuery()
Gets the query string.
Definition: DynamicDeviceSet.cpp:119
void setQuery(string query)
Sets the query string of this DynamicDeviceSet.
Definition: DynamicDeviceSet.cpp:115
const set< Device * > & getDevices()
Gets the devices managed by this set.
Definition: DeviceSet.h:473
Definition: LumiverseColorLib.h:30
RGBColorSpace
Selects a RGB color space to use in color conversion functions.
Definition: LumiverseColorLib.h:29
A DeviceSet is a set of devices.
Definition: DeviceSet.h:41
set< string > getAllMetadata()
Gets a copy of the set of all the metadata keys used by devices in this set.
Definition: DynamicDeviceSet.cpp:65
bool contains(Device *d)
Checks to see if a device is in the device set.
Definition: DynamicDeviceSet.cpp:99
InterpolationMode
Sets the interpolation mode when transitioning between two LumiverseEnums.
Definition: LumiverseEnum.h:71
JSONNode toJSON(string name)
Saves the device set as a JSON object with the given name.
Definition: DynamicDeviceSet.cpp:107
const set< Device * > & getDevices()
Gets the devices managed by this set.
Definition: DynamicDeviceSet.h:193
bool hasSameDevices(DynamicDeviceSet &devices)
Returns true if the device sets have the same number of devices and point to the same Devices...
Definition: DynamicDeviceSet.cpp:94
size_t size()
Returns the number of devices in the DynamicDeviceSet.
Definition: DynamicDeviceSet.h:229
bool hasSameIds(DynamicDeviceSet &devices)
Returns true if the device sets have the same number of devices and contain the same set of IDs...
Definition: DynamicDeviceSet.cpp:89
Contains functions for logging information to console or file.
~DynamicDeviceSet()
Destructor for the DeviceSet.
Definition: DynamicDeviceSet.cpp:17
Mode
When you select an enumeration, mode determines where in the range the calculated value will fall...
Definition: LumiverseEnum.h:56
DeviceSet select(string q)
Gets a DeviceSet based on a query string.
Definition: Rig.cpp:496
void setParam(string param, float val)
Sets the value of a LumiverseFloat parameter on every device in the group.
Definition: DynamicDeviceSet.cpp:29
Rig * m_rig
Pointer to the rig for accessing indexes and devices.
Definition: DynamicDeviceSet.h:284
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
string info()
Returns a string containing info about the DynamicDeviceSet.
Definition: DynamicDeviceSet.cpp:73
A DynamicDeviceSet is a set of devices specified by a query string.
Definition: DynamicDeviceSet.h:34
set< string > getAllMetadataForKey(string key)
Gets a copy of the set of all metadata values used by a particular key.
Definition: DynamicDeviceSet.cpp:69
The Rig contains information about the state of the lighting system.
Definition: Rig.h:58
A Device in Lumiverse maintains information about a lighting device.
Definition: Device.h:55
void setColorRGBRaw(string param, double r, double g, double b, double weight=1.0)
Sets the value of a LumiverseColor parameter.
Definition: DynamicDeviceSet.cpp:49
string m_query
Query string.
Definition: DynamicDeviceSet.h:279
set< string > getAllParams()
Gets a copy of the set of all the parameters used by devices in this set.
Definition: DynamicDeviceSet.cpp:61
size_t size()
Returns the number of devices in the DeviceSet.
Definition: DeviceSet.h:509
void setColorRGB(string param, double r, double g, double b, double weight=1.0, RGBColorSpace cs=sRGB)
Sets the value of a LumiverseColor parameter.
Definition: DynamicDeviceSet.cpp:53
void reset()
Resets all the parameters in each Device in the device set.
Definition: DynamicDeviceSet.cpp:25
std::ostream & operator<<(std::ostream &str)
Override for steam output.
Definition: DynamicDeviceSet.h:80
A Set of Devices.