![]() |
RTXI 1.3
|
00001 /* 00002 Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College 00003 00004 This program is free software: you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation, either version 3 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 */ 00018 00019 #include <debug.h> 00020 #include <main_window.h> 00021 #include <mutex.h> 00022 #include <system_control.h> 00023 #include <system_control_panel.h> 00024 00025 extern "C" Plugin::Object *createRTXIPlugin(void *) { 00026 return SystemControl::getInstance(); 00027 } 00028 00029 SystemControl::SystemControl(void) { 00030 menuID = MainWindow::getInstance()->createSystemMenuItem("Control Panel",this,SLOT(createControlPanel(void))); 00031 } 00032 00033 SystemControl::~SystemControl(void) { 00034 MainWindow::getInstance()->removeSystemMenuItem(menuID); 00035 while(panelList.size()) 00036 delete panelList.front(); 00037 instance = 0; 00038 } 00039 00040 void SystemControl::createControlPanel(void) { 00041 SystemControlPanel *panel = new SystemControlPanel(MainWindow::getInstance()->centralWidget()); 00042 panelList.push_back(panel); 00043 } 00044 00045 void SystemControl::removeControlPanel(SystemControlPanel *panel) { 00046 panelList.remove(panel); 00047 } 00048 00049 static Mutex mutex; 00050 SystemControl *SystemControl::instance = 0; 00051 00052 SystemControl *SystemControl::getInstance(void) { 00053 if(instance) 00054 return instance; 00055 00056 /************************************************************************* 00057 * Seems like alot of hoops to jump through, but allocation isn't * 00058 * thread-safe. So effort must be taken to ensure mutual exclusion. * 00059 *************************************************************************/ 00060 00061 Mutex::Locker lock(&::mutex); 00062 if(!instance) 00063 instance = new SystemControl(); 00064 00065 return instance; 00066 }