Components/SetupOptimization/BasicControllers/freRegistrationProcessEventHandler.txx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.0.7.2
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freRegistrationProcessEventHandler.txx,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 #ifndef __freRegistrationProcessEventHandler_txx
00024 #define __freRegistrationProcessEventHandler_txx
00025 
00026 #include "freRegistrationProcessEventHandler.h"
00027 
00028 namespace FREE
00029 {
00030 
00031 template <class TRegistrationProcessor>
00032 void
00033 RegistrationProcessEventHandler<TRegistrationProcessor>::
00034 SetSessionInfo(SessionInfo* pSessionInfo)
00035 {
00036   m_pSessionInfo = pSessionInfo;
00037 };
00038 
00039 template <class TRegistrationProcessor>
00040 void
00041 RegistrationProcessEventHandler<TRegistrationProcessor>::
00042 SetOnProgress(ProgressCtrlEventBase* onProgress)
00043 {
00044   m_OnProgress = onProgress;
00045 };
00046 
00047 template <class TRegistrationProcessor>
00048 void
00049 RegistrationProcessEventHandler<TRegistrationProcessor>::
00050 SetOnCallback(CallbackCtrlEventBase* onCallback)
00051 {
00052   m_OnCallback = onCallback;
00053 };
00054 
00055 template <class TRegistrationProcessor>
00056 void
00057 RegistrationProcessEventHandler<TRegistrationProcessor>::
00058 SetComponentCache(SessionComponentCache* pCache)
00059 {
00060   m_pCache = pCache;
00061   if (!m_pCache)
00062   {
00063     m_pProcessor = 0;
00064   }
00065   else
00066   {
00067     try
00068     {
00069       m_pProcessor = dynamic_cast<TRegistrationProcessor*>(m_pCache->Component().GetPointer());
00070     }
00071     catchAllNPassMacro("Error. Cache component is no registration processor.");
00072     if (!m_pProcessor) throwExceptionMacro("Error. Cache component is no registration processor. IDPath: " << m_pCache->GetIDPath().ToStr());
00073 
00074     m_pProcessor->fnOnNextLevel = m_LevelEvent;
00075     m_pProcessor->fnOnNextIteration = m_IterationEvent;
00076     m_pProcessor->fnOnProgress = m_RegistrationProgressEvent;
00077   }
00078 };
00079 
00080 template <class TRegistrationProcessor>
00081 RegistrationProcessEventHandler<TRegistrationProcessor>::
00082 RegistrationProcessEventHandler()
00083 {
00084   this->m_IterationEvent = IterationEvent<Self>::New(this, &Self::OnNextIteration);
00085   this->m_LevelEvent = LevelEvent<Self>::New(this, &Self::OnNextLevel);
00086   this->m_RegistrationProgressEvent = RegistrationProgressEvent<Self>::New(this, &Self::OnRegistrationProgressEvent);
00087 };
00088 
00089 template <class TRegistrationProcessor>
00090 void
00091 RegistrationProcessEventHandler<TRegistrationProcessor>::
00092 OnNextLevel(const unsigned int iLevel, void* pSender)
00093 {
00094         if (m_pCache)
00095         {
00096     if (m_pSessionInfo->GetStatistic())
00097     { //statisitc object is defined, so gather statistics
00098                   SectionStatistic* pSection = m_pSessionInfo->GetStatistic()->GetActualSection();
00099                   if (!pSection) pSection = m_pSessionInfo->GetStatistic()->m_Data.AddNewSection();
00100                   pSection->AddNewLevel();
00101     }
00102     PipeControllerCentral::TriggerControllerProgressEvent(m_pCache->GetIDPath(),2,"Added new registration level: "+Convert::ToStr(iLevel), m_pCache);
00103     //TODO
00104     //if (m_OnProgress.IsNotNull()) m_OnProgress->Execute(m_pCache->GetIDPath(),2,"Added new registration level: "+Convert::ToStr(iLevel), m_pCache);
00105         };
00106 };
00107 
00108 template <class TRegistrationProcessor>
00109 void
00110 RegistrationProcessEventHandler<TRegistrationProcessor>::
00111 OnNextIteration(const long lIteration, Statistics* pStatistic, void* pSender)
00112 {
00113         if (m_pCache)
00114         {
00115     if (m_pSessionInfo->GetStatistic())
00116     { //statisitc object is defined, so gather statistics
00117                   PipeBuilder::SetStepStatistic(m_pCache, m_pSessionInfo);
00118     }
00119     PipeControllerCentral::TriggerControllerProgressEvent(m_pCache->GetIDPath(),3,Convert::ToStr(lIteration), m_pCache);
00120     //TODO
00121     //if (m_OnProgress.IsNotNull()) m_OnProgress->Execute(m_pCache->GetIDPath(),3,Convert::ToStr(lIteration), m_pCache);
00122         };
00123 };
00124 
00125 template <class TRegistrationProcessor>
00126 void
00127 RegistrationProcessEventHandler<TRegistrationProcessor>::
00128 OnRegistrationProgressEvent(const RegistrationStatusType status, void* pSender,
00129                                                                                                          const std::string  sComment)
00130 {
00131         if (m_pCache)
00132         {
00133     PipeControllerCentral::TriggerControllerProgressEvent(m_pCache->GetIDPath(),1000+status,sComment, m_pCache);
00134     //TODO
00135     //if (m_OnProgress.IsNotNull()) m_OnProgress->Execute(m_pCache->GetIDPath(),1000+status,sComment, m_pCache);
00136         };
00137 };
00138 
00139 
00140 } //end of namespace free
00141 #endif

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