Open Lighting Architecture: ola::plugin::karate::PluginAdaptor Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Public Member Functions | List of all members
ola::plugin::karate::PluginAdaptor Class Reference
Inheritance diagram for ola::plugin::karate::PluginAdaptor:

## Public Member Functions
| PluginAdaptor (class DeviceManager *device_manager, ola::io::SelectServerInterface *select_server, ExportMap *export_map, class PreferencesFactory *preferences_factory, class PortBrokerInterface *port_broker, const std::string *instance_name)
| Create a new PluginAdaptor.
bool | AddReadDescriptor (ola::io::ReadFileDescriptor *descriptor)
| Register a ReadFileDescriptor for read-events.
bool | AddReadDescriptor (ola::io::ConnectedDescriptor *descriptor, bool delete_on_close=false)
| Register a ConnectedDescriptor for read-events.
void | RemoveReadDescriptor (ola::io::ReadFileDescriptor *descriptor)
| Remove a ReadFileDescriptor for read-events.
void | RemoveReadDescriptor (ola::io::ConnectedDescriptor *descriptor)
| Remove a ConnectedDescriptor for read-events.
bool | AddWriteDescriptor (ola::io::WriteFileDescriptor *descriptor)
| Register a WriteFileDescriptor for write-events.
void | RemoveWriteDescriptor (ola::io::WriteFileDescriptor *descriptor)
| Remove a WriteFileDescriptor for write-events.
ola::thread::timeout_id | RegisterRepeatingTimeout (unsigned int ms, Callback0< bool > *closure)
| Execute a callback periodically.
ola::thread::timeout_id | RegisterRepeatingTimeout (const TimeInterval &interval, Callback0< bool > *closure)
| Execute a callback periodically.
ola::thread::timeout_id | RegisterSingleTimeout (unsigned int ms, SingleUseCallback0< void > *closure)
| Execute a callback after a certain time interval.
ola::thread::timeout_id | RegisterSingleTimeout (const TimeInterval &interval, SingleUseCallback0< void > *closure)
| Execute a callback after a certain time interval.
void | RemoveTimeout (ola::thread::timeout_id id)
| Cancel an existing timeout.
void | Execute (ola::BaseCallback0< void > *closure)
| Execute the supplied callback at some point in the future.
const TimeStamp * | WakeUpTime () const
| The time when this SelectServer was woken up.
const std::string | InstanceName ()
| Return the instance name for the OLA server.
ExportMap * | GetExportMap () const
bool | RegisterDevice (class AbstractDevice *device) const
| Register a device.
bool | UnregisterDevice (class AbstractDevice *device) const
| Unregister a device.
class Preferences * | NewPreference (const std::string &name) const
| Create a new preferences container.
class PortBrokerInterface * | GetPortBroker () const
void | DrainCallbacks ()
| Run all callbacks until there are none left.

## Constructor & Destructor Documentation

## ◆ PluginAdaptor()

ola::PluginAdaptor::PluginAdaptor | ( | class DeviceManager * | device_manager,
|  | ola::io::SelectServerInterface * | select_server,
|  | ExportMap * | export_map,
|  | class PreferencesFactory * | preferences_factory,
|  | class PortBrokerInterface * | port_broker,
|  | const std::string * | instance_name )

Create a new PluginAdaptor.

Parameters

  device_manager | pointer to a DeviceManager object
  select_server | pointer to the SelectServer object
  export_map | pointer to the ExportMap object
  preferences_factory | pointer to the PreferencesFactory object
  port_broker | pointer to the PortBroker object
  instance_name | the instance name of this OlaServer

## Member Function Documentation

## ◆ AddReadDescriptor() [1/2]

bool ola::PluginAdaptor::AddReadDescriptor | ( | ola::io::ConnectedDescriptor * | descriptor,
|  | bool | delete_on_close = false )
| virtual

Register a ConnectedDescriptor for read-events.

Parameters

  descriptor | the ConnectedDescriptor to add.
  delete_on_close | if true, ownership of the ConnectedDescriptor is transferred to the SelectServer.

Returns
  true if the descriptor was added, false if the descriptor was previously added.

When the descriptor is ready for reading, PerformRead() will be called. Prior to PerformRead(), IsClosed() is called. If this returns true, and delete_on_close was set, the descriptor will be deleted.

Implements ola::io::SelectServerInterface.

## ◆ AddReadDescriptor() [2/2]

bool ola::PluginAdaptor::AddReadDescriptor | ( | ola::io::ReadFileDescriptor * | descriptor | ) |
| virtual

Register a ReadFileDescriptor for read-events.

Parameters

  descriptor | the ReadFileDescriptor to add.

Returns
  true if the descriptor was added, false if the descriptor was previously added.

When the descriptor is ready for reading, PerformRead() will be called.

Implements ola::io::SelectServerInterface.

## ◆ AddWriteDescriptor()

bool ola::PluginAdaptor::AddWriteDescriptor | ( | ola::io::WriteFileDescriptor * | descriptor | ) |
| virtual

Register a WriteFileDescriptor for write-events.

Parameters

  descriptor | the WriteFileDescriptor to add.

When the descriptor is writeable, PerformWrite() is called.

Implements ola::io::SelectServerInterface.

## ◆ DrainCallbacks()

void ola::PluginAdaptor::DrainCallbacks | ( |  | ) |
| virtual

Run all callbacks until there are none left.

Implements ola::thread::ExecutorInterface.

## ◆ Execute()

void ola::PluginAdaptor::Execute | ( | ola::BaseCallback0< void > * | callback | ) |
| virtual

Execute the supplied callback at some point in the future.

Parameters

  callback | the callback to run.

This method provides the following guarantees:

- The callback will not be run immediately.
- The callback will be run at some point in the future. That is, the callback will not leak. Any remaining pending callbacks will be run during the destruction of the class implementing ExecutorInterface.
- For a given thread, callbacks will be run in the order in which they were added.

When queuing callbacks, you need to ensure that either:

- The objects used in the callback outlive the ExecutorInterface
- That the callback is run before the objects are deleted.

To achieve the latter it's common to keep track of the number of outstanding callbacks and then call DrainCallbacks() in the destructor if the number of outstanding callbacks is non-0.

Implements ola::thread::ExecutorInterface.

## ◆ InstanceName()

const std::string ola::PluginAdaptor::InstanceName | ( |  | ) |

Return the instance name for the OLA server.

Returns
  a string which is the instance name

## ◆ NewPreference()

Preferences * ola::PluginAdaptor::NewPreference | ( | const std::string & | name | ) | const

Create a new preferences container.

Returns
  a Preferences object

## ◆ RegisterDevice()

bool ola::PluginAdaptor::RegisterDevice | ( | class AbstractDevice * | device | ) | const

Register a device.

Parameters

  device | the device to register

Returns
  true on success, false on error

## ◆ RegisterRepeatingTimeout() [1/2]

timeout_id ola::PluginAdaptor::RegisterRepeatingTimeout | ( | const TimeInterval & | period,
|  | Callback0< bool > * | callback )
| virtual

Execute a callback periodically.

Parameters

  period | the time interval between each execution of the callback.
  callback | the callback to run. Ownership is transferred.

Returns
  a timeout_id which can be used later to cancel the timeout.

Returning false from the callback will cause it to be cancelled.

Implements ola::io::SelectServerInterface.

## ◆ RegisterRepeatingTimeout() [2/2]

timeout_id ola::PluginAdaptor::RegisterRepeatingTimeout | ( | unsigned int | period,
|  | Callback0< bool > * | callback )
| virtual

Execute a callback periodically.

Parameters

  period | the number of milliseconds between each execution of the callback.
  callback | the callback to run. Ownership is transferred.

Returns
  a timeout_id which can be used later to cancel the timeout.

Deprecated
  Use the version that takes a TimeInterval instead.

Returning false from the callback will cause it to be cancelled.

Implements ola::io::SelectServerInterface.

## ◆ RegisterSingleTimeout() [1/2]

timeout_id ola::PluginAdaptor::RegisterSingleTimeout | ( | const TimeInterval & | delay,
|  | SingleUseCallback0< void > * | callback )
| virtual

Execute a callback after a certain time interval.

Parameters

  delay | the time interval to wait before the callback is executed.
  callback | the callback to run. Ownership is transferred.

Returns
  a timeout_id which can be used later to cancel the timeout.

Implements ola::io::SelectServerInterface.

## ◆ RegisterSingleTimeout() [2/2]

timeout_id ola::PluginAdaptor::RegisterSingleTimeout | ( | unsigned int | delay,
|  | SingleUseCallback0< void > * | callback )
| virtual

Execute a callback after a certain time interval.

Parameters

  delay | the number of milliseconds before the callback is executed.
  callback | the callback to run. Ownership is transferred.

Returns
  a timeout_id which can be used later to cancel the timeout.

Deprecated
  Use the version that takes a TimeInterval instead.

Implements ola::io::SelectServerInterface.

## ◆ RemoveReadDescriptor() [1/2]

void ola::PluginAdaptor::RemoveReadDescriptor | ( | ola::io::ConnectedDescriptor * | descriptor | ) |
| virtual

Remove a ConnectedDescriptor for read-events.

Parameters

  descriptor | the descriptor to remove.

Warning
  Descriptors must be removed from the SelectServer before they are closed. Not doing so will result in hard to debug failures.

Implements ola::io::SelectServerInterface.

## ◆ RemoveReadDescriptor() [2/2]

void ola::PluginAdaptor::RemoveReadDescriptor | ( | ola::io::ReadFileDescriptor * | descriptor | ) |
| virtual

Remove a ReadFileDescriptor for read-events.

Parameters

  descriptor | the descriptor to remove.

Warning
  Descriptors must be removed from the SelectServer before they are closed. Not doing so will result in hard to debug failures.

Implements ola::io::SelectServerInterface.

## ◆ RemoveTimeout()

void ola::PluginAdaptor::RemoveTimeout | ( | ola::thread::timeout_id | id | ) |
| virtual

Cancel an existing timeout.

Parameters

  id | the timeout_id returned by a call to RegisterRepeatingTimeout or RegisterSingleTimeout.

Implements ola::io::SelectServerInterface.

## ◆ RemoveWriteDescriptor()

void ola::PluginAdaptor::RemoveWriteDescriptor | ( | ola::io::WriteFileDescriptor * | descriptor | ) |
| virtual

Remove a WriteFileDescriptor for write-events.

Parameters

  descriptor | the descriptor to remove.

Warning
  Descriptors must be removed from the SelectServer before they are closed. Not doing so will result in hard to debug failures.

Implements ola::io::SelectServerInterface.

## ◆ UnregisterDevice()

bool ola::PluginAdaptor::UnregisterDevice | ( | class AbstractDevice * | device | ) | const

Unregister a device.

Parameters

  device | the device to unregister

Returns
  true on success, false on error

## ◆ WakeUpTime()

const TimeStamp * ola::PluginAdaptor::WakeUpTime | ( |  | ) | const
| virtual

The time when this SelectServer was woken up.

Returns
  The TimeStamp of when the SelectServer was woken up.

If running within the same thread as the SelectServer, this is a efficient way to get the current time.

Implements ola::io::SelectServerInterface.

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

- include/olad/PluginAdaptor.h
- olad/plugin_api/PluginAdaptor.cpp