Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OlaDevice.h
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library 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 GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * OlaDevice.h
17  * Interface to the OLA Client Device class
18  * Copyright (C) 2005-2006 Simon Newton
19  */
20 
21 #ifndef OLA_OLADEVICE_H_
22 #define OLA_OLADEVICE_H_
23 
24 #include <olad/PortConstants.h>
25 #include <string>
26 #include <vector>
27 
28 namespace ola {
29 
30 using std::string;
31 using std::vector;
32 
33 
34 enum PatchAction {PATCH, UNPATCH};
35 enum RegisterAction {REGISTER, UNREGISTER};
36 enum PortDirection {INPUT_PORT, OUTPUT_PORT};
37 
38 
39 /*
40  * Represents a Plugin
41  */
42 class OlaPlugin {
43  public:
44  OlaPlugin(unsigned int id, const string &name, bool active):
45  m_id(id),
46  m_name(name),
47  m_active(active) {}
48  ~OlaPlugin() {}
49 
50  unsigned int Id() const { return m_id; }
51  string Name() const { return m_name; }
52  bool IsActive() const { return m_active; }
53 
54  bool operator<(const OlaPlugin &other) const {
55  return m_id < other.m_id;
56  }
57  private:
58  unsigned int m_id; // id of this plugin
59  string m_name; // plugin name
60  bool m_active;
61 };
62 
63 
64 /*
65  * Represents a port
66  */
67 class OlaPort {
68  public:
69  OlaPort(unsigned int port_id,
70  unsigned int universe,
71  bool active,
72  const string &description,
73  port_priority_capability capability,
74  port_priority_mode mode,
75  uint8_t priority,
76  bool supports_rdm):
77  m_id(port_id),
78  m_universe(universe),
79  m_active(active),
80  m_description(description),
81  m_priority_capability(capability),
82  m_priority_mode(mode),
83  m_priority(priority),
84  m_supports_rdm(supports_rdm) {}
85  virtual ~OlaPort() {}
86 
87  unsigned int Id() const { return m_id; }
88 
89  unsigned int Universe() const { return m_universe; }
90  bool IsActive() const { return m_active; }
91  string Description() const { return m_description; }
92 
93  port_priority_capability PriorityCapability() const {
94  return m_priority_capability;
95  }
96  port_priority_mode PriorityMode() const {
97  return m_priority_mode;
98  }
99  uint8_t Priority() const { return m_priority; }
100 
101  bool SupportsRDM() const { return m_supports_rdm; }
102 
103  private:
104  unsigned int m_id; // id of this port
105  unsigned int m_universe; // universe
106  bool m_active; // active
107  string m_description;
108  port_priority_capability m_priority_capability;
109  port_priority_mode m_priority_mode;
110  uint8_t m_priority;
111  bool m_supports_rdm;
112 };
113 
114 
115 class OlaInputPort: public OlaPort {
116  public:
117  OlaInputPort(unsigned int port_id,
118  unsigned int universe,
119  bool active,
120  const string &description,
121  port_priority_capability capability,
122  port_priority_mode mode,
123  uint8_t priority,
124  bool supports_rdm):
125  OlaPort(port_id, universe, active, description,
126  capability, mode, priority, supports_rdm) {
127  }
128 };
129 
130 
131 class OlaOutputPort: public OlaPort {
132  public:
133  OlaOutputPort(unsigned int port_id,
134  unsigned int universe,
135  bool active,
136  const string &description,
137  port_priority_capability capability,
138  port_priority_mode mode,
139  uint8_t priority,
140  bool supports_rdm):
141  OlaPort(port_id, universe, active, description,
142  capability, mode, priority, supports_rdm) {
143  }
144 };
145 
146 
147 /*
148  * Represents a device
149  */
150 class OlaDevice {
151  public:
152  OlaDevice(const string &id,
153  unsigned int alias,
154  const string &name,
155  int plugin_id,
156  const vector<OlaInputPort> &input_ports,
157  const vector<OlaOutputPort> &output_ports):
158  m_id(id),
159  m_alias(alias),
160  m_name(name),
161  m_plugin_id(plugin_id),
162  m_input_ports(input_ports),
163  m_output_ports(output_ports) {}
164  ~OlaDevice() {}
165 
166  string Id() const { return m_id; }
167  unsigned int Alias() const { return m_alias; }
168  string Name() const { return m_name; }
169  int PluginId() const { return m_plugin_id; }
170 
171  const vector<OlaInputPort> &InputPorts() const { return m_input_ports; }
172  const vector<OlaOutputPort> &OutputPorts() const { return m_output_ports; }
173 
174  bool operator<(const OlaDevice &other) const {
175  return m_alias < other.m_alias;
176  }
177 
178  private:
179  string m_id; // device id
180  unsigned int m_alias; // device alias
181  std::string m_name; // device name
182  int m_plugin_id; // parent plugin id
183  std::vector<OlaInputPort> m_input_ports;
184  std::vector<OlaOutputPort> m_output_ports;
185 };
186 
187 
188 /*
189  * Represents a universe
190  */
191 class OlaUniverse {
192  public:
193  enum merge_mode {
194  MERGE_HTP,
195  MERGE_LTP,
196  };
197 
198  OlaUniverse(unsigned int id,
199  merge_mode m,
200  const string &name,
201  unsigned int input_port_count,
202  unsigned int output_port_count,
203  unsigned int rdm_device_count):
204  m_id(id),
205  m_merge_mode(m),
206  m_name(name),
207  m_input_port_count(input_port_count),
208  m_output_port_count(output_port_count),
209  m_rdm_device_count(rdm_device_count) {}
210  ~OlaUniverse() {}
211 
212  unsigned int Id() const { return m_id;}
213  merge_mode MergeMode() const { return m_merge_mode; }
214  string Name() const { return m_name;}
215  unsigned int InputPortCount() const { return m_input_port_count; }
216  unsigned int OutputPortCount() const { return m_output_port_count; }
217  unsigned int RDMDeviceCount() const { return m_rdm_device_count; }
218 
219  private:
220  unsigned int m_id; // id of this universe
221  merge_mode m_merge_mode; // merge mode
222  string m_name; // universe name
223  unsigned int m_input_port_count;
224  unsigned int m_output_port_count;
225  unsigned int m_rdm_device_count;
226 };
227 } // namespace ola
228 #endif // OLA_OLADEVICE_H_