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: freSessionProcessor.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 #include "freSessionProcessor.h" 00023 00024 namespace FREE 00025 { 00026 00027 void 00028 SessionProcessor:: 00029 SetSetup(Setup* pSetup) 00030 { 00031 if (m_pSetup != pSetup) 00032 { 00033 ResetSession(); 00034 m_pSetup = pSetup; 00035 } 00036 }; 00037 00038 void 00039 SessionProcessor:: 00040 SetStatistic(Statistics* pStatistic) 00041 { 00042 if (m_pStatistic != pStatistic) m_pStatistic = pStatistic; 00043 }; 00044 00045 void 00046 SessionProcessor:: 00047 DefineOutput(const std::string& sOutputID, const IDPath& idPath) 00048 { 00049 00050 typedef std::pair< std::string, IDPath > ValueType; 00051 typedef std::pair< MediaIDMapType::iterator, bool > PositionType; 00052 00053 PositionType pos = this->m_MediaMap.insert( ValueType(sOutputID, idPath)); 00054 00055 if (pos.second == false) 00056 { //Key already exists so replace component 00057 (pos.first)->second = idPath; 00058 } 00059 }; 00060 00061 void 00062 SessionProcessor:: 00063 ResetOutputs() 00064 { 00065 this->m_MediaMap.clear(); 00066 }; 00067 00068 SessionProcessor::GenericMediaPointer 00069 SessionProcessor:: 00070 GetOutput(const std::string& sOutputID) 00071 { 00072 MediaIDMapType::const_iterator pos = this->m_MediaMap.find(sOutputID); 00073 if (pos==this->m_MediaMap.end()) throwExceptionMacro("Error; unkown output id. OutputID: "<<sOutputID); 00074 00075 IDPath path = pos->second; 00076 00077 return GetOutput(path); 00078 }; 00079 00080 SessionProcessor::GenericMediaPointer 00081 SessionProcessor:: 00082 GetOutput(const IDPath& idPath) 00083 { 00084 if (!m_bInitialized) InitializeSession(); 00085 00086 return SessionAccessor::GetMedia(idPath,m_smpSessionInfo); 00087 }; 00088 00089 void 00090 SessionProcessor:: 00091 InitializeSession() 00092 { 00093 ResetSession(); 00094 00095 m_smpSessionInfo = SessionBuilder::BuildSession(m_pSetup); 00096 m_smpSessionInfo->SetStatistic(m_pStatistic); 00097 00098 m_bInitialized = true; 00099 }; 00100 00101 void 00102 SessionProcessor:: 00103 Update() 00104 { 00105 }; 00106 00107 void 00108 SessionProcessor:: 00109 ResetSession() 00110 { 00111 m_bInitialized = false; 00112 m_smpSessionInfo = 0; 00113 }; 00114 00115 SessionProcessor:: 00116 SessionProcessor() 00117 { 00118 ResetSession(); 00119 m_pStatistic = 0; 00120 }; 00121 00122 SessionProcessor:: 00123 ~SessionProcessor() 00124 { 00125 ResetSession(); 00126 }; 00127 00128 } 00129 //End of namespace FREE
1.5.3 written by Dimitri van Heesch,
© 1997-2000