Open Lighting Architecture: ola::DeviceManager Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
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_pair > | Devices () const
| Return a list of all devices and their aliases.
AbstractDevice * | GetDevice (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

## ◆ DeviceManager()

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

Create a new DeviceManager.

Parameters

  prefs_factory | the PreferencesFactory to use, ownership is not transferred.
  port_manager | the PortManager to use, ownership is not transferred.

## Member Function Documentation

## ◆ DeviceCount()

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

Return the number of devices.

Returns
  the number of devices.

## ◆ 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.

## ◆ GetDevice() [1/2]

device_alias_pair ola::DeviceManager::GetDevice | ( | const std::string & | unique_id | ) | const

Lookup a device using the device id.

Parameters

  unique_id | the 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.

## ◆ GetDevice() [2/2]

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.

## ◆ RegisterDevice()

bool ola::DeviceManager::RegisterDevice | ( | AbstractDevice * | device | ) |

Register a device.

Parameters

  device | The 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.

## ◆ SendTimeCode()

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

Send timecode to all ports which support timecode.

Parameters

  timecode | the TimeCode information.

## ◆ UnregisterDevice() [1/2]

bool ola::DeviceManager::UnregisterDevice | ( | const AbstractDevice * | device | ) |

Unregister a device by pointer.

Parameters

  device | a pointer to the device.

Returns
  true on success, false on failure

## ◆ UnregisterDevice() [2/2]

bool ola::DeviceManager::UnregisterDevice | ( | const std::string & | device_id | ) |

Unregister a device by id.

Parameters

  device_id | the id of the device to remove

Returns
  true on success, false on failure

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

- olad/plugin_api/DeviceManager.h
- olad/plugin_api/DeviceManager.cpp