RTXI  2.4
The Real-Time eXperiment Interface Documentation
plugin.h
Go to the documentation of this file.
1 /*
2  The Real-Time eXperiment Interface (RTXI)
3  Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 
20 #ifndef PLUGIN_H
21 #define PLUGIN_H
22 
23 #include <list>
24 #include <mutex.h>
25 #include <settings.h>
26 #include <string>
27 #include <sys/types.h>
28 #include <QObject>
29 #include <QtWidgets>
30 
32 
35 namespace Plugin
36 {
37 
38 class Object;
39 
40 static const QEvent::Type CloseEvent = QEvent::User;
41 
46 class RTXIEvent : public QEvent
47 {
48 
49 public:
50  RTXIEvent() : QEvent((QEvent::Type) CloseEvent) {}
51  void *data;
52 };
53 
57 class Manager : public QObject
58 {
59 
60  Q_OBJECT
61 
62  friend class Object;
63 
64 public:
65 
72  static Manager *getInstance(void);
73 
82  Object *load(const QString &library);
83 
89  void unload(Object *object);
90 
94  void unloadAll(void);
95 
106  void foreachPlugin(void (*callback)(Plugin::Object *,void *),void *param);
107 
108 public slots:
109 
113  void customEvent(QEvent *);
114 
115 private:
116 
117  /*****************************************************************
118  * The constructor, destructor, and assignment operator are made *
119  * private to control instantiation of the class. *
120  *****************************************************************/
121 
122  Manager(void) : mutex(Mutex::RECURSIVE) {};
123  ~Manager(void) {};
124  Manager(const Manager &) : QObject() {};
125  Manager &operator=(const Manager &)
126  {
127  return *getInstance();
128  };
129 
130  static Manager *instance;
131 
132  void insertPlugin(Object *);
133  void removePlugin(Object *);
134 
135  //static const QEvent::Type CloseEvent = QEvent::User;
136 
137  Mutex mutex;
138  std::list<Object *> pluginList;
139 
140 }; // class Manager
141 
145 class Object : public virtual Settings::Object
146 {
147 
148  friend class Manager;
149 
150 public:
151 
152  Object(void);
153  virtual ~Object(void);
154 
160  std::string getLibrary(void) const;
161 
166  void unload(void);
167 
168 private:
169 
170  static const u_int32_t MAGIC_NUMBER = 0xCA24CB3F;
171  u_int32_t magic_number;
172  std::string library;
173  void *handle;
174 
175 }; // class Object
176 
177 }; // namespace Plugin
178 
179 #endif // PLUGIN_H
Plugin::Manager::unload
void unload(Object *object)
Definition: plugin.cpp:100
Plugin::Object::~Object
virtual ~Object(void)
Definition: plugin.cpp:31
Plugin::Manager::load
Object * load(const QString &library)
Definition: plugin.cpp:46
settings.h
Plugin::Object
Definition: plugin.h:145
Plugin::Manager::Object
friend class Object
Definition: plugin.h:62
Plugin::RTXIEvent
Definition: plugin.h:46
Plugin::Object::Object
Object(void)
Definition: plugin.cpp:26
Plugin::Manager
Definition: plugin.h:57
Mutex
Definition: mutex.h:28
Plugin::RTXIEvent::data
void * data
Definition: plugin.h:51
mutex.h
Settings::Object
Definition: settings.h:43
Plugin
Classes associated with the loading/unloading of binaries at run-time.
Definition: plugin.h:35
Plugin::Manager::getInstance
static Manager * getInstance(void)
Definition: plugin.cpp:188
Plugin::Manager::foreachPlugin
void foreachPlugin(void(*callback)(Plugin::Object *, void *), void *param)
Definition: plugin.cpp:132
Plugin::Manager::customEvent
void customEvent(QEvent *)
Definition: plugin.cpp:164
Plugin::Manager::unloadAll
void unloadAll(void)
Definition: plugin.cpp:117
Plugin::Object::unload
void unload(void)
Definition: plugin.cpp:41
Plugin::RTXIEvent::RTXIEvent
RTXIEvent()
Definition: plugin.h:50
Plugin::Object::getLibrary
std::string getLibrary(void) const
Definition: plugin.cpp:36