freStoreableMediaControllerBase.txx

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: freStoreableMediaControllerBase.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 __freStoreableMediaControllerBase_txx
00024 #define __freStoreableMediaControllerBase_txx
00025 
00026 #include "freStoreableMediaControllerBase.h"
00027 #include "freExceptions.h"
00028 
00029 namespace FREE
00030 {
00031 
00035 
00036 template <class TMedia>
00037 StoreableMediaControllerBase<TMedia>::
00038 StoreableMediaControllerBase()
00039 {
00040   this->UpdateControllerID(ControllerID::StoreableMediaControllerBase);
00041   this->m_Description = "Base class for all kind of media that can/must be stored on disk.";
00042 };
00043 
00044 template <class TMedia>
00045 void
00046 StoreableMediaControllerBase<TMedia>::
00047 GenerateProfile(CtrlProfile::ControllerProfile& profile, 
00048                 const SessionComponentCache* pComponentCache,
00049                 bool bRegardOldSetup) const
00050 {
00051   Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00052 
00053   profile.Parameters().AddParameter(cParam_MediaFile,Parameter::PVTString,cParam_MediaFile,1,"");
00054 };
00055 
00056 template <class TMedia>
00057 bool
00058 StoreableMediaControllerBase<TMedia>::
00059 SaveMedia(std::string sMediaPath, GenericMediaType* pMedia) const
00060 {
00061         return false;
00062 };
00063 
00064 template <class TMedia>
00065 bool
00066 StoreableMediaControllerBase<TMedia>::
00067 SaveMedia(SessionComponentCache* pCache) const
00068 {
00069         return false;
00070 };
00071 
00072 template <class TMedia>
00073 void
00074 StoreableMediaControllerBase<TMedia>::
00075 SetMediaFile(const std::string& sMediaFile, SessionComponentCache* pCache) const
00076 {
00077   if (!pCache) throwCtrlExceptionMacro("","Error; Passed cache pointer is NULL; cannot set media file.");
00078   if (!pCache->SetupIsAssigned()) throwCtrlExceptionMacro("","Error; Passed component setup is not assigned; cannot set media file.");
00079 
00080   pCache->Setup()->Parameters().SetParameterValue(cParam_MediaFile,sMediaFile);
00081 };
00082 
00083 template <class TMedia>
00084 std::string
00085 StoreableMediaControllerBase<TMedia>::
00086 GetMediaFile(SessionComponentCache* pCache) const
00087 {
00088   if (!pCache) throwCtrlExceptionMacro("","Error; Passed cache pointer is NULL; cannot get media file.");
00089   if (!pCache->SetupIsAssigned()) throwCtrlExceptionMacro("","Error; Passed component setup is not assigned; cannot get media file.");
00090 
00091   std::string sFile = "";
00092   pCache->Setup()->Parameters().GetParameterValue(cParam_MediaFile,sFile);
00093 
00094   return sFile;
00095 };
00096 
00097 template <class TMedia>
00098 void
00099 StoreableMediaControllerBase<TMedia>::
00100 SetStatisticEntryMainComponent(StatisticEntry& rStatisticEntry,
00101                                ComponentType* pMainComponent,
00102                                SessionComponentCache* pMainComponentCache,
00103                                SessionInfo* pSessionInfo,
00104                                StatisticDictionary& rDictionary) const
00105 {
00106   std::string sIDPath = pMainComponentCache->GetIDPath();
00107   StatisticValueDefinition* pEntry = rDictionary.GetValueDefinitionByName(sIDPath,"MediaID");
00108     
00109   if (!pEntry) //Entry is not recorded yet, so do so.
00110   {
00111     pEntry = rDictionary.AddValueDefinition(sIDPath,"MediaID","ID of the media");
00112     rDictionary.AddValueDefinition(sIDPath,"MediaFile","File where the media will be saved");
00113   }
00114 
00115   std::string sFile;
00116 
00117   try
00118   {
00119     SessionAccessor::GetParameterValue(pMainComponentCache,cParam_MediaFile,sFile);
00120   }
00121   catchAllNPassMacro("Error while retrieving parameter values.");
00122 
00123   rStatisticEntry.AddValue(pMainComponentCache->GetComponentID(),pEntry->GetRefID());
00124   rStatisticEntry.AddValue(sFile,pEntry->GetRefID()+1);
00125 };
00126 
00127 } //end of namespace free
00128 
00129 #endif

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