SpikeStream Application Library  0.2
ConnectionManager.cpp
Go to the documentation of this file.
00001 //SpikeStream includes
00002 #include "ArchiveDao.h"
00003 #include "ConnectionManager.h"
00004 #include "Globals.h"
00005 #include "Network.h"
00006 #include "NetworkDao.h"
00007 #include "SpikeStreamException.h"
00008 using namespace spikestream;
00009 
00010 
00012 ConnectionManager::ConnectionManager() : SpikeStreamThread() {
00013 }
00014 
00015 
00017 ConnectionManager::~ConnectionManager(){
00018 }
00019 
00020 
00021 /*----------------------------------------------------------*/
00022 /*-----                 PUBLIC METHODS                 -----*/
00023 /*----------------------------------------------------------*/
00024 
00026 void ConnectionManager::deleteConnectionGroups(QList<unsigned>& connectionGroupIDs){
00027         deleteConnectionGroupIDs = connectionGroupIDs;
00028         this->start();
00029 }
00030 
00031 
00032 //Run method inherited from QThread
00033 void ConnectionManager::run(){
00034         clearError();
00035         stopThread = false;
00036 
00037         try{
00038                 //Delete the connection group
00039                 Network* currentNetwork = Globals::getNetwork();
00040                 Globals::getNetwork()->deleteConnectionGroups(deleteConnectionGroupIDs);
00041 
00042                 //Wait for network to finish adding connection groups
00043                 while(currentNetwork->isBusy()){
00044                         msleep(250);
00045                 }
00046 
00047                 //Check for errors
00048                 if(currentNetwork->isError())
00049                         setError(currentNetwork->getErrorMessage());
00050         }
00051         catch (SpikeStreamException& ex){
00052                 setError(ex.getMessage());
00053         }
00054         catch(...){
00055                 setError("An unknown error occurred.");
00056         }
00057 
00058         stopThread = true;
00059 }
00060 
 All Classes Files Functions Variables Typedefs Friends Defines