RTXI  2.4
The Real-Time eXperiment Interface Documentation
system_control.cpp
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 #include <debug.h>
21 #include <main_window.h>
22 #include <mutex.h>
23 #include <system_control.h>
24 #include <system_control_panel.h>
25 
26 extern "C" Plugin::Object *createRTXIPlugin(void *)
27 {
29 }
30 
31 SystemControl::SystemControl(void)
32 {
33  MainWindow::getInstance()->createSystemMenuItem("Control Panel",this,SLOT(createControlPanel(void)));
34 }
35 
36 SystemControl::~SystemControl(void)
37 {
38  while(panelList.size())
39  delete panelList.front();
40  instance = 0;
41 }
42 
44 {
45  SystemControlPanel *panel = new SystemControlPanel(MainWindow::getInstance()->centralWidget());
46  panelList.push_back(panel);
47 }
48 
49 void SystemControl::removeControlPanel(SystemControlPanel *panel)
50 {
51  panelList.remove(panel);
52 }
53 
54 static Mutex mutex;
55 SystemControl *SystemControl::instance = 0;
56 
58 {
59  if(instance)
60  return instance;
61 
62  /*************************************************************************
63  * Seems like alot of hoops to jump through, but allocation isn't *
64  * thread-safe. So effort must be taken to ensure mutual exclusion. *
65  *************************************************************************/
66 
67  Mutex::Locker lock(&::mutex);
68  if(!instance)
69  instance = new SystemControl();
70 
71  return instance;
72 }
system_control_panel.h
SystemControlPanel
Definition: system_control_panel.h:27
MainWindow::createSystemMenuItem
QAction * createSystemMenuItem(const QString &label, const QObject *handler, const char *slot)
Definition: main_window.cpp:253
SystemControl::createControlPanel
void createControlPanel(void)
Definition: system_control.cpp:43
system_control.h
Plugin::Object
Definition: plugin.h:145
SystemControl::getInstance
static SystemControl * getInstance(void)
Definition: system_control.cpp:57
createRTXIPlugin
Plugin::Object * createRTXIPlugin(void *)
Definition: system_control.cpp:26
SystemControl
Definition: system_control.h:27
Mutex
Definition: mutex.h:28
SystemControl::SystemControlPanel
friend class SystemControlPanel
Definition: system_control.h:32
mutex.h
Mutex::Locker
Definition: mutex.h:36
MainWindow::getInstance
static MainWindow * getInstance(void)
Definition: main_window.cpp:454
debug.h
main_window.h