Lumiverse  2.5
A framework for creating lighting control applications
Public Member Functions | Private Attributes | List of all members
Lumiverse::DynamicDeviceSet Class Reference

A DynamicDeviceSet is a set of devices specified by a query string. More...

#include <DynamicDeviceSet.h>

Collaboration diagram for Lumiverse::DynamicDeviceSet:
Collaboration graph
[legend]

Public Member Functions

 DynamicDeviceSet ()
 Default constructor. More...
 
 DynamicDeviceSet (Rig *rig, string query)
 Constructs a DynamicDeviceSet. More...
 
 DynamicDeviceSet (Rig *rig, JSONNode data)
 Constructs a DynamicDeviceSet from a JSON Node. More...
 
 DynamicDeviceSet (const DynamicDeviceSet &dc)
 Copy a DynamicDeviceSet. More...
 
 ~DynamicDeviceSet ()
 Destructor for the DeviceSet.
 
std::ostream & operator<< (std::ostream &str)
 Override for steam output. More...
 
DeviceSet getDeviceSet ()
 Gets a DeviceSet containing the devices that match the query at the time this function is called.
 
void setQuery (string query)
 Sets the query string of this DynamicDeviceSet. More...
 
string getQuery ()
 Gets the query string.
 
bool isQueryNull ()
 Returns true if the query string is empty.
 
void reset ()
 Resets all the parameters in each Device in the device set. More...
 
void setParam (string param, float val)
 Sets the value of a LumiverseFloat parameter on every device in the group. More...
 
void setParam (string param, string val, float val2=-1.0f)
 Sets the value of a LumiverseEnum parameter on every device in the group. More...
 
void setParam (string param, string channel, double val)
 Sets the value of a LumiverseColor parameter. More...
 
void setParam (string param, string val, float val2, LumiverseEnum::Mode mode, LumiverseEnum::InterpolationMode interpMode)
 Sets the value of a LumiverseEnum parameter. More...
 
void setParam (string param, double x, double y, double weight=1.0)
 Sets the value of a LumiverseColor parameter using LumiverseColor::setxy() More...
 
void setColorRGBRaw (string param, double r, double g, double b, double weight=1.0)
 Sets the value of a LumiverseColor parameter. More...
 
void setColorRGB (string param, double r, double g, double b, double weight=1.0, RGBColorSpace cs=sRGB)
 Sets the value of a LumiverseColor parameter. More...
 
const set< Device * > & getDevices ()
 Gets the devices managed by this set. More...
 
vector< string > getIds ()
 Gets a copy of the list of the IDs contained by this DynamicDeviceSet.
 
set< string > getAllParams ()
 Gets a copy of the set of all the parameters used by devices in this set. More...
 
set< string > getAllMetadata ()
 Gets a copy of the set of all the metadata keys used by devices in this set.
 
set< string > getAllMetadataForKey (string key)
 Gets a copy of the set of all metadata values used by a particular key.
 
string info ()
 Returns a string containing info about the DynamicDeviceSet. More...
 
size_t size ()
 Returns the number of devices in the DynamicDeviceSet. More...
 
bool hasSameIds (DynamicDeviceSet &devices)
 Returns true if the device sets have the same number of devices and contain the same set of IDs. More...
 
bool hasSameDevices (DynamicDeviceSet &devices)
 Returns true if the device sets have the same number of devices and point to the same Devices. More...
 
bool contains (Device *d)
 Checks to see if a device is in the device set. More...
 
bool contains (string id)
 Checks to see if a device is in the device set. More...
 
JSONNode toJSON (string name)
 Saves the device set as a JSON object with the given name. More...
 

Private Attributes

string m_query
 Query string.
 
Rigm_rig
 Pointer to the rig for accessing indexes and devices.
 

Detailed Description

A DynamicDeviceSet is a set of devices specified by a query string.

DynamicDeviceSets are constructed with the standard query syntax (https://github.com/ebshimizu/Lumiverse/wiki/Query-Syntax-Notes) and each time they're accessed, the set of devices matching the query will be selected for use. Note that this class is really a wrapper around DeviceSets and may be slow for repeated use of large queries.

See also
Device, DeviceSet

Constructor & Destructor Documentation

Lumiverse::DynamicDeviceSet::DynamicDeviceSet ( )
inline

Default constructor.

Like the default constructor for DeviceSet, this isn't particularly useful.

Lumiverse::DynamicDeviceSet::DynamicDeviceSet ( Rig rig,
string  query 
)

Constructs a DynamicDeviceSet.

Similar to a copy constructor.

Parameters
rigPointer to a Rig to get devices from.
queryQuery string to associate with this DynamicDeviceSet
See also
DeviceSet(Rig*), Device, Rig, DeviceSet
Lumiverse::DynamicDeviceSet::DynamicDeviceSet ( Rig rig,
JSONNode  data 
)

Constructs a DynamicDeviceSet from a JSON Node.

Parameters
rigPointer to the rig to get devices from.
dataJSON data to load from.
Lumiverse::DynamicDeviceSet::DynamicDeviceSet ( const DynamicDeviceSet dc)

Copy a DynamicDeviceSet.

Parameters
dcDynamicDeviceSet to copy data from

Member Function Documentation

bool Lumiverse::DynamicDeviceSet::contains ( Device d)

Checks to see if a device is in the device set.

This version of the contains function takes a pointer and checks to see if the exact same device is in the set. This function is faster than contains(string).

bool Lumiverse::DynamicDeviceSet::contains ( string  id)

Checks to see if a device is in the device set.

This version of the contains function takes a device ID and checks if a device with the same id is in the set.

set< string > Lumiverse::DynamicDeviceSet::getAllParams ( )

Gets a copy of the set of all the parameters used by devices in this set.

Set means no duplicates

const set<Device *>& Lumiverse::DynamicDeviceSet::getDevices ( )
inline

Gets the devices managed by this set.

Returns
Set of Device* contained by the DynamicDeviceSet
bool Lumiverse::DynamicDeviceSet::hasSameDevices ( DynamicDeviceSet devices)

Returns true if the device sets have the same number of devices and point to the same Devices.

This actually just checks to see if the pointers in the set of devices managed by the device set are pointing to the same things.

bool Lumiverse::DynamicDeviceSet::hasSameIds ( DynamicDeviceSet devices)

Returns true if the device sets have the same number of devices and contain the same set of IDs.

Note that even if this returns true, the device sets could refer to different objects, as they store pointers to the devices they contain. This function is currently very slow.

string Lumiverse::DynamicDeviceSet::info ( )

Returns a string containing info about the DynamicDeviceSet.

Returns
DynamicDeviceSet as a string. String contains the number of devices contained by the set and the IDs of each device in the set.
std::ostream& Lumiverse::DynamicDeviceSet::operator<< ( std::ostream &  str)
inline

Override for steam output.

Converts DynamicDeviceSet to a string representation and outputs it to a stream.

Returns
ostream object containing the DynamicDeviceSet string appended to it.
See also
info()
void Lumiverse::DynamicDeviceSet::reset ( )

Resets all the parameters in each Device in the device set.

See also
Device::reset()
void Lumiverse::DynamicDeviceSet::setColorRGB ( string  param,
double  r,
double  g,
double  b,
double  weight = 1.0,
RGBColorSpace  cs = sRGB 
)
void Lumiverse::DynamicDeviceSet::setColorRGBRaw ( string  param,
double  r,
double  g,
double  b,
double  weight = 1.0 
)

Sets the value of a LumiverseColor parameter.

Not gonna work terribly well if you're mixing fixtures that don't have RGB for some reason in your selection. Proxy for LumiverseColor::setRGBRaw().

See also
LumiverseColor::setRGBRaw(), LumiverseColor, LumiverseType
void Lumiverse::DynamicDeviceSet::setParam ( string  param,
float  val 
)

Sets the value of a LumiverseFloat parameter on every device in the group.

This function will only set the value of an existing parameter. If the parameter doesn't exist, it will not be created by this function.

Parameters
paramParameter to modify
valValue of the parameter
See also
Device::setParam(string, float)
void Lumiverse::DynamicDeviceSet::setParam ( string  param,
string  val,
float  val2 = -1.0f 
)

Sets the value of a LumiverseEnum parameter on every device in the group.

This function will only set the value of an existing parameter. If the parameter doesn't exist, it will not be created by this function.

Parameters
paramParameter to modify
valValue of the enumeration
val2The tweak value of the LumiverseEnum
See also
Device::setParam(string, string, float)
void Lumiverse::DynamicDeviceSet::setParam ( string  param,
string  channel,
double  val 
)

Sets the value of a LumiverseColor parameter.

LumiverseColors present a bit of a challenge for group selections. Every light has differen color representations, so not every function will work for every group. This function will call the corresponding set param function for each device, but not every device may react to it.

Parameters
paramParameter name
channelColor channel name
valValue of the color channel
See also
LumiverseColor, LumiverseType
void Lumiverse::DynamicDeviceSet::setParam ( string  param,
string  val,
float  val2,
LumiverseEnum::Mode  mode,
LumiverseEnum::InterpolationMode  interpMode 
)

Sets the value of a LumiverseEnum parameter.

See also
Device::setParam()
void Lumiverse::DynamicDeviceSet::setParam ( string  param,
double  x,
double  y,
double  weight = 1.0 
)

Sets the value of a LumiverseColor parameter using LumiverseColor::setxy()

x and y are chromaticity coordinates in the xyY color space. Ideally this function would be the unifying function for all devices in a Rig. However, it only works if you know the XYZ values for each color of LED in a light, and it doesn't work with CMY fixtures at the moment.

Parameters
paramParameter name.
xx coordinate
yy coordinate
See also
LumiverseColor, LumiverseType, setParam(string, string, double)
void Lumiverse::DynamicDeviceSet::setQuery ( string  query)

Sets the query string of this DynamicDeviceSet.

Parameters
queryNew query string to use.
size_t Lumiverse::DynamicDeviceSet::size ( )
inline

Returns the number of devices in the DynamicDeviceSet.

Returns
Number of devices in the set.
JSONNode Lumiverse::DynamicDeviceSet::toJSON ( string  name)

Saves the device set as a JSON object with the given name.

This serializes to a list of IDs that can be used to reconstruct the DynamicDeviceSet if it's given the same Rig as it currently has.

Parameters
nameNode name.

The documentation for this class was generated from the following files: