Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PluginAdaptor.h
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * PluginAdaptor.h
17  * The provides operations on a ola_device.
18  * Copyright (C) 2005-2008 Simon Newton
19  */
20 
21 #ifndef INCLUDE_OLAD_PLUGINADAPTOR_H_
22 #define INCLUDE_OLAD_PLUGINADAPTOR_H_
23 
24 #include <ola/Callback.h>
25 #include <ola/Clock.h>
26 #include <ola/ExportMap.h>
27 #include <ola/base/Macro.h>
28 #include <ola/io/SelectServerInterface.h>
29 
30 #include <string>
31 
32 namespace ola {
33 
35  public:
36  PluginAdaptor(class DeviceManager *device_manager,
37  ola::io::SelectServerInterface *select_server,
38  ExportMap *export_map,
39  class PreferencesFactory *preferences_factory,
40  class PortBrokerInterface *port_broker);
41 
42  // The following methods are part of the SelectServerInterface
43  bool AddReadDescriptor(ola::io::ReadFileDescriptor *descriptor);
44  bool AddReadDescriptor(ola::io::ConnectedDescriptor *descriptor,
45  bool delete_on_close = false);
46  bool RemoveReadDescriptor(ola::io::ReadFileDescriptor *descriptor);
47  bool RemoveReadDescriptor(ola::io::ConnectedDescriptor *descriptor);
49  bool RemoveWriteDescriptor(ola::io::WriteFileDescriptor *descriptor);
50 
51  ola::thread::timeout_id RegisterRepeatingTimeout(unsigned int ms,
52  Callback0<bool> *closure);
53  ola::thread::timeout_id RegisterRepeatingTimeout(
54  const TimeInterval &interval,
55  Callback0<bool> *closure);
56  ola::thread::timeout_id RegisterSingleTimeout(
57  unsigned int ms,
58  SingleUseCallback0<void> *closure);
59  ola::thread::timeout_id RegisterSingleTimeout(
60  const TimeInterval &interval,
61  SingleUseCallback0<void> *closure);
62  void RemoveTimeout(ola::thread::timeout_id id);
63 
64  void Execute(ola::BaseCallback0<void> *closure);
65 
66  const TimeStamp *WakeUpTime() const;
67 
68  ExportMap *GetExportMap() const {
69  return m_export_map;
70  }
71 
72  // These are the extra bits for the plugins
73  bool RegisterDevice(class AbstractDevice *device) const;
74  bool UnregisterDevice(class AbstractDevice *device) const;
75  class Preferences *NewPreference(const std::string &name) const;
76  class PortBrokerInterface *GetPortBroker() const {
77  return m_port_broker;
78  }
79 
80  private:
81  DeviceManager *m_device_manager;
83  ExportMap *m_export_map;
84  class PreferencesFactory *m_preferences_factory;
85  class PortBrokerInterface *m_port_broker;
86 
88 };
89 } // namespace ola
90 #endif // INCLUDE_OLAD_PLUGINADAPTOR_H_