Open Lighting Architecture: include/olad/PluginAdaptor.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
PluginAdaptor.h
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU Library General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15 *
16 * PluginAdaptor.h
17 * The provides operations on a ola_device.
18 * Copyright (C) 2005 Simon Newton
19 */
20
26
27#ifndef INCLUDE_OLAD_PLUGINADAPTOR_H_
28#define INCLUDE_OLAD_PLUGINADAPTOR_H_
29
30#include <ola/Callback.h>
31#include <ola/Clock.h>
32#include <ola/ExportMap.h>
33#include <ola/base/Macro.h>
34#include <ola/io/SelectServerInterface.h>
35#include <olad/OlaServer.h>
36
37#include <string>
38
39namespace ola {
40
41 class PluginAdaptor: public ola::io::SelectServerInterface {
42 public:
52 PluginAdaptor(class DeviceManager *device_manager,
53 ola::io::SelectServerInterface *select_server,
54 ExportMap *export_map,
55 class PreferencesFactory *preferences_factory,
56 class PortBrokerInterface *port_broker,
57 const std::string *instance_name);
58
59 // The following methods are part of the SelectServerInterface
60 bool AddReadDescriptor(ola::io::ReadFileDescriptor *descriptor);
61
62 bool AddReadDescriptor(ola::io::ConnectedDescriptor *descriptor,
63 bool delete_on_close = false);
64
65 void RemoveReadDescriptor(ola::io::ReadFileDescriptor *descriptor);
66
67 void RemoveReadDescriptor(ola::io::ConnectedDescriptor *descriptor);
68
69 bool AddWriteDescriptor(ola::io::WriteFileDescriptor *descriptor);
70
71 void RemoveWriteDescriptor(ola::io::WriteFileDescriptor *descriptor);
72
73 ola::thread::timeout_id RegisterRepeatingTimeout(unsigned int ms,
74 Callback0<bool> *closure);
75
76 ola::thread::timeout_id RegisterRepeatingTimeout(
77 const TimeInterval &interval,
78 Callback0<bool> *closure);
79
80 ola::thread::timeout_id RegisterSingleTimeout(
81 unsigned int ms,
82 SingleUseCallback0<void> *closure);
83
84 ola::thread::timeout_id RegisterSingleTimeout(
85 const TimeInterval &interval,
86 SingleUseCallback0<void> *closure);
87
88 void RemoveTimeout(ola::thread::timeout_id id);
89
90 void Execute(ola::BaseCallback0<void> *closure);
91
92 const TimeStamp *WakeUpTime() const;
93
94 // These are the extra bits for the plugins
99 const std::string InstanceName();
100
101 ExportMap *GetExportMap() const {
102 return m_export_map;
103 }
104
110 bool RegisterDevice(class AbstractDevice *device) const;
111
117 bool UnregisterDevice(class AbstractDevice *device) const;
118
123 class Preferences *NewPreference(const std::string &name) const;
124 class PortBrokerInterface *GetPortBroker() const {
125 return m_port_broker;
126 }
127
128 void DrainCallbacks();
129
130 private:
131 DeviceManager *m_device_manager;
132 ola::io::SelectServerInterface *m_ss;
133 ExportMap *m_export_map;
134 class PreferencesFactory *m_preferences_factory;
135 class PortBrokerInterface *m_port_broker;
136 const std::string *m_instance_name;
137
138 PluginAdaptor(const PluginAdaptor &) = delete;
139 const PluginAdaptor &operator=(const PluginAdaptor &) = delete;
140};
141} // namespace ola
142#endif // INCLUDE_OLAD_PLUGINADAPTOR_H_
Callback.h
ExportMap.h
Export variables on the http server.
Macro.h
Helper macros.
ola::AbstractDevice
Definition Device.h:44
ola::BaseCallback0
The base class for all 0 argument callbacks.
Definition Callback.h:119
ola::Callback0
A 0 argument callback which can be called multiple times.
Definition Callback.h:129
ola::DeviceManager
Keeps track of OLA's devices.
Definition DeviceManager.h:61
ola::ExportMap
A container for the exported variables.
Definition ExportMap.h:324
ola::PluginAdaptor::RegisterSingleTimeout
ola::thread::timeout_id RegisterSingleTimeout(unsigned int ms, SingleUseCallback0< void > *closure)
Execute a callback after a certain time interval.
Definition PluginAdaptor.cpp:92
ola::PluginAdaptor::InstanceName
const std::string InstanceName()
Return the instance name for the OLA server.
Definition PluginAdaptor.cpp:132
ola::PluginAdaptor::AddWriteDescriptor
bool AddWriteDescriptor(ola::io::WriteFileDescriptor *descriptor)
Register a WriteFileDescriptor for write-events.
Definition PluginAdaptor.cpp:70
ola::PluginAdaptor::Execute
void Execute(ola::BaseCallback0< void > *closure)
Execute the supplied callback at some point in the future.
Definition PluginAdaptor.cpp:108
ola::PluginAdaptor::RemoveTimeout
void RemoveTimeout(ola::thread::timeout_id id)
Cancel an existing timeout.
Definition PluginAdaptor.cpp:104
ola::PluginAdaptor::UnregisterDevice
bool UnregisterDevice(class AbstractDevice *device) const
Unregister a device.
Definition PluginAdaptor.cpp:120
ola::PluginAdaptor::RemoveReadDescriptor
void RemoveReadDescriptor(ola::io::ReadFileDescriptor *descriptor)
Remove a ReadFileDescriptor for read-events.
Definition PluginAdaptor.cpp:60
ola::PluginAdaptor::RegisterRepeatingTimeout
ola::thread::timeout_id RegisterRepeatingTimeout(unsigned int ms, Callback0< bool > *closure)
Execute a callback periodically.
Definition PluginAdaptor.cpp:80
ola::PluginAdaptor::AddReadDescriptor
bool AddReadDescriptor(ola::io::ReadFileDescriptor *descriptor)
Register a ReadFileDescriptor for read-events.
Definition PluginAdaptor.cpp:49
ola::PluginAdaptor::NewPreference
class Preferences * NewPreference(const std::string &name) const
Create a new preferences container.
Definition PluginAdaptor.cpp:124
ola::PluginAdaptor::RemoveWriteDescriptor
void RemoveWriteDescriptor(ola::io::WriteFileDescriptor *descriptor)
Remove a WriteFileDescriptor for write-events.
Definition PluginAdaptor.cpp:75
ola::PluginAdaptor::WakeUpTime
const TimeStamp * WakeUpTime() const
The time when this SelectServer was woken up.
Definition PluginAdaptor.cpp:128
ola::PluginAdaptor::DrainCallbacks
void DrainCallbacks()
Run all callbacks until there are none left.
Definition PluginAdaptor.cpp:112
ola::PluginAdaptor::RegisterDevice
bool RegisterDevice(class AbstractDevice *device) const
Register a device.
Definition PluginAdaptor.cpp:116
ola::PluginAdaptor::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.
Definition PluginAdaptor.cpp:35
ola::PortBrokerInterface
Definition PortBroker.h:40
ola::PreferencesFactory
Definition Preferences.h:347
ola::Preferences
Definition Preferences.h:148
ola::SingleUseCallback0
A 0 argument callback which deletes itself after it's run.
Definition Callback.h:141
ola::TimeInterval
Definition Clock.h:126
ola::TimeStamp
Definition Clock.h:179
ola::io::ConnectedDescriptor
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition Descriptor.h:283
ola::io::ReadFileDescriptor
Represents a file descriptor that supports reading data.
Definition Descriptor.h:140
ola::io::SelectServerInterface
The interface for the SelectServer.
Definition SelectServerInterface.h:42
ola::io::WriteFileDescriptor
Represents a file descriptor that supports writing data.
Definition Descriptor.h:170
ola::plugin::karate::PluginAdaptor::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.
Definition PluginAdaptor.cpp:35
ola::thread::timeout_id
void * timeout_id
A timeout handle which can later be used to cancel a timeout.
Definition SchedulerInterface.h:34
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44