Open Lighting Architecture  0.9.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Attributes | List of all members
ola::DeviceManager Class Reference

Detailed Description

Keeps track of OLA's devices.

Devices can be identified in one of two ways, by device-id or by alias. device-ids are strings and are persistent across restarting olad and reload the plugins. device-ids are the keys used in preference containers to identify devices.

Device aliases are unsigned integers and are only valid for the lifetime of the DeviceManager object. Device aliases are used by users when patching / controlling a device. since '1' is easier to understand / type than 5-02050016. If a device is registered, then unregistered, then registered again, it'll have the same device alias.

Public Member Functions

 DeviceManager (PreferencesFactory *prefs_factory, class PortManager *port_manager)
 Create a new DeviceManager.
 ~DeviceManager ()
 Destructor.
bool RegisterDevice (AbstractDevice *device)
 Register a device.
bool UnregisterDevice (const std::string &device_id)
 Unregister a device by id.
bool UnregisterDevice (const AbstractDevice *device)
 Unregister a device by pointer.
unsigned int DeviceCount () const
 Return the number of devices.
std::vector< device_alias_pairDevices () const
 Return a list of all devices and their aliases.
AbstractDeviceGetDevice (unsigned int alias) const
 Lookup a device using the device alias.
device_alias_pair GetDevice (const std::string &unique_id) const
 Lookup a device using the device id.
void UnregisterAllDevices ()
 Remove all devices.
void SendTimeCode (const ola::timecode::TimeCode &timecode)
 Send timecode to all ports which support timecode.

Static Public Attributes

static const unsigned int MISSING_DEVICE_ALIAS = 0

Constructor & Destructor Documentation

ola::DeviceManager::DeviceManager ( PreferencesFactory prefs_factory,
class PortManager port_manager 
)

Create a new DeviceManager.

Parameters
prefs_factorythe PreferencesFactory to use, ownership is not transferred.
port_managerthe PortManager to use, ownership is not transferred.

Member Function Documentation

unsigned int ola::DeviceManager::DeviceCount ( ) const

Return the number of devices.

Returns
the number of devices.
vector< device_alias_pair > ola::DeviceManager::Devices ( ) const

Return a list of all devices and their aliases.

Returns
a vector of device_alias_pairs.
AbstractDevice * ola::DeviceManager::GetDevice ( unsigned int  alias) const

Lookup a device using the device alias.

Returns
a pointer to the device or NULL if the device wasn't found.
device_alias_pair ola::DeviceManager::GetDevice ( const std::string &  unique_id) const

Lookup a device using the device id.

Parameters
unique_idthe device id of the device.
Returns
a device_alias_pair, if the device isn't found the alias is set to MISSING_DEVICE_ALIAS and the device pointer is NULL.
bool ola::DeviceManager::RegisterDevice ( AbstractDevice device)

Register a device.

Parameters
deviceThe device to register, ownership is not transferred.
Returns
true on success, false on failure.

During registration, any saved port patchings for this device are restored.

void ola::DeviceManager::SendTimeCode ( const ola::timecode::TimeCode timecode)

Send timecode to all ports which support timecode.

Parameters
timecodethe TimeCode information.
bool ola::DeviceManager::UnregisterDevice ( const std::string &  device_id)

Unregister a device by id.

Parameters
device_idthe id of the device to remove
Returns
true on sucess, false on failure
bool ola::DeviceManager::UnregisterDevice ( const AbstractDevice device)

Unregister a device by pointer.

Parameters
devicea pointer to the device.
Returns
true on sucess, false on failure

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