Open Lighting Architecture  Latest Git
SPIDMXPlugin.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * SPIDMXPlugin.h
17  * This looks for possible SPI devices to instantiate and is managed by OLAD.
18  * Copyright (C) 2017 Florian Edelmann
19  */
20 
21 #ifndef PLUGINS_SPIDMX_SPIDMXPLUGIN_H_
22 #define PLUGINS_SPIDMX_SPIDMXPLUGIN_H_
23 
24 #include <set>
25 #include <string>
26 #include <vector>
27 
28 #include "olad/Plugin.h"
29 #include "ola/plugin_id.h"
30 
31 #include "plugins/spidmx/SPIDMXDevice.h"
32 
33 namespace ola {
34 namespace plugin {
35 namespace spidmx {
36 
37 class SPIDMXPlugin : public Plugin {
38  public:
39  explicit SPIDMXPlugin(PluginAdaptor *plugin_adaptor)
40  : Plugin(plugin_adaptor),
41  m_plugin_adaptor(plugin_adaptor) {
42  }
43 
44  ola_plugin_id Id() const { return OLA_PLUGIN_SPIDMX; }
45  std::string Name() const { return PLUGIN_NAME; }
46  std::string PluginPrefix() const { return PLUGIN_PREFIX; }
47 
48  // This plugin is disabled unless explicitly enabled by a user.
49  bool DefaultMode() const { return false; }
50 
51  std::string Description() const;
52 
53  private:
54  typedef std::vector<SPIDMXDevice*> SPIDMXDeviceVector;
55  SPIDMXDeviceVector m_devices;
56 
57  PluginAdaptor *m_plugin_adaptor;
58 
59  void AddDevice(SPIDMXDevice *device);
60  bool StartHook();
61  bool StopHook();
62  bool SetDefaultPreferences();
63 
64  static const char PLUGIN_NAME[];
65  static const char PLUGIN_PREFIX[];
66  static const char PREF_DEVICE_PREFIX_DEFAULT[];
67  static const char PREF_DEVICE_PREFIX_KEY[];
68 
69  DISALLOW_COPY_AND_ASSIGN(SPIDMXPlugin);
70 };
71 
72 } // namespace spidmx
73 } // namespace plugin
74 } // namespace ola
75 #endif // PLUGINS_SPIDMX_SPIDMXPLUGIN_H_
Definition: SPIDMXPlugin.h:37
std::string Description() const
Definition: SPIDMXPlugin.cpp:101
Definition: Plugin.h:118
Definition: PluginAdaptor.h:41
ola_plugin_id Id() const
Get the plugin ID of this plugin.
Definition: SPIDMXPlugin.h:44
std::string Name() const
Get the plugin name.
Definition: SPIDMXPlugin.h:45
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
std::string PluginPrefix() const
The prefix to use for storing configuration files.
Definition: SPIDMXPlugin.h:46
Definition: SPIDMXDevice.h:37