Open Lighting Architecture
 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/Clock.h>
25 #include <ola/Callback.h>
26 #include <ola/ExportMap.h>
27 #include <ola/io/SelectServerInterface.h>
28 
29 #include <string>
30 
31 namespace ola {
32 
33 using ola::thread::timeout_id;
34 
36  public:
37  PluginAdaptor(class DeviceManager *device_manager,
38  ola::io::SelectServerInterface *select_server,
39  ExportMap *export_map,
40  class PreferencesFactory *preferences_factory,
41  class PortBrokerInterface *port_broker);
42 
43  // The following methods are part of the SelectServerInterface
44  bool AddReadDescriptor(ola::io::ReadFileDescriptor *descriptor);
45  bool AddReadDescriptor(ola::io::ConnectedDescriptor *descriptor,
46  bool delete_on_close = false);
47  bool RemoveReadDescriptor(ola::io::ReadFileDescriptor *descriptor);
48  bool RemoveReadDescriptor(ola::io::ConnectedDescriptor *descriptor);
50  bool RemoveWriteDescriptor(ola::io::WriteFileDescriptor *descriptor);
51 
52  timeout_id RegisterRepeatingTimeout(unsigned int ms,
53  Callback0<bool> *closure);
54  timeout_id RegisterRepeatingTimeout(const TimeInterval &interval,
55  Callback0<bool> *closure);
56  timeout_id RegisterSingleTimeout(unsigned int ms,
57  SingleUseCallback0<void> *closure);
58  timeout_id RegisterSingleTimeout(const TimeInterval &interval,
59  SingleUseCallback0<void> *closure);
60  void RemoveTimeout(timeout_id id);
61 
62  void Execute(ola::BaseCallback0<void> *closure);
63 
64  const TimeStamp *WakeUpTime() const;
65 
66  ExportMap *GetExportMap() const {
67  return m_export_map;
68  }
69 
70  // These are the extra bits for the plugins
71  bool RegisterDevice(class AbstractDevice *device) const;
72  bool UnregisterDevice(class AbstractDevice *device) const;
73  class Preferences *NewPreference(const std::string &name) const;
74  class PortBrokerInterface *GetPortBroker() const {
75  return m_port_broker;
76  }
77 
78  private:
80  PluginAdaptor& operator=(const PluginAdaptor&);
81 
82  DeviceManager *m_device_manager;
84  ExportMap *m_export_map;
85  class PreferencesFactory *m_preferences_factory;
86  class PortBrokerInterface *m_port_broker;
87 };
88 } // namespace ola
89 #endif // INCLUDE_OLAD_PLUGINADAPTOR_H_