freControllerEvents.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freControllerEvents.cxx,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020 
00021 =========================================================================*/
00022 
00023 
00024 #include "freControllerEvents.h"
00025 
00026 namespace FREE
00027 {
00028 
00032 
00033 
00034 CallbackCtrlEventBase::
00035 CallbackCtrlEventBase(CallEvent pCE)
00036 {
00037         this->m_CallEvent = pCE;
00038         this->m_ACR = NULL;
00039 };
00040 
00041 CallbackCtrlEventBase::
00042 CallbackCtrlEventBase()
00043 {
00044         m_CallEvent = NULL;
00045         this->m_ACR = NULL;
00046 };
00047 
00048 bool
00049 CallbackCtrlEventBase::
00050 Execute(const IDPath& senderID, CallbackType callbackID,
00051         void* pData, SessionComponentCache* pSender,
00052         long threadID)
00053 {
00054   if (!m_CallEvent) return false;
00055 
00056   bool result = false;
00057 
00058   if (this->IsLegalSender(pSender))
00059   {
00060     this->m_ExecutionMutex.Lock();
00061             result = (*m_CallEvent)(senderID, callbackID, pData, pSender, threadID);
00062     this->m_ExecutionMutex.Unlock();
00063   }
00064 
00065   return result;
00066 };
00067 
00068 void
00069 CallbackCtrlEventBase::
00070 SetACR(SessionComponentCache* pCache)
00071 {
00072   if (pCache)
00073   {
00074     this->m_ACR = pCache->GetRootCache();
00075   }
00076   else
00077   {
00078     this->m_ACR = 0;
00079   }
00080 };
00081 
00082 SessionComponentCache*
00083 CallbackCtrlEventBase::
00084 GetACR()
00085 {
00086   return this->m_ACR;
00087 }
00088 
00089 bool
00090 CallbackCtrlEventBase::
00091 IsLegalSender(SessionComponentCache* pSender)
00092 {
00093   if (!this->m_ACR) return true;
00094   if (!pSender) return false;
00095 
00096   m_ACRMutex.Lock();
00097     bool result = this->m_ACR == pSender->GetRootCache();
00098   m_ACRMutex.Unlock();
00099 
00100   return result;
00101 };
00102 
00103 
00107 
00108 
00109 ProgressCtrlEventBase::
00110 ProgressCtrlEventBase(ProgEvent pPE)
00111 {
00112         m_ProgressEvent = pPE;
00113         this->m_ACR = NULL;
00114 };
00115 
00116 ProgressCtrlEventBase::
00117 ProgressCtrlEventBase()
00118 {
00119         m_ProgressEvent = NULL;
00120         this->m_ACR = NULL;
00121 };
00122 
00123 void
00124 ProgressCtrlEventBase::
00125 Execute(const IDPath& senderID, const StatusID status,
00126         const std::string& sComment, SessionComponentCache* pSender,
00127         long threadID)
00128 {
00129   if (!m_ProgressEvent) return;
00130 
00131   if (this->IsLegalSender(pSender))
00132   {
00133     this->m_ExecutionMutex.Lock();
00134           (*m_ProgressEvent)(senderID, status, sComment, pSender, threadID);
00135     this->m_ExecutionMutex.Unlock();
00136   }
00137 };
00138 
00139 void
00140 ProgressCtrlEventBase::
00141 SetACR(SessionComponentCache* pCache)
00142 {
00143   if (pCache)
00144   {
00145     this->m_ACR = pCache->GetRootCache();
00146   }
00147   else
00148   {
00149     this->m_ACR = 0;
00150   }
00151 };
00152 
00153 SessionComponentCache*
00154 ProgressCtrlEventBase::
00155 GetACR()
00156 {
00157   return this->m_ACR;
00158 }
00159 
00160 bool
00161 ProgressCtrlEventBase::
00162 IsLegalSender(SessionComponentCache* pSender)
00163 {
00164   if (!this->m_ACR) return true;
00165   if (!pSender) return false;
00166   
00167   m_ACRMutex.Lock();
00168     bool result = this->m_ACR == pSender->GetRootCache();
00169   m_ACRMutex.Unlock();
00170 
00171   return result;
00172 };
00173 
00174 } //end of namespace free

Generated at Sat Oct 13 15:39:55 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000