freMediaControllerBase.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: freMediaControllerBase.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 __freMediaControllerBase_txx
00024 #define __freMediaControllerBase_txx
00025 
00026 #include "freMediaControllerBase.h"
00027 #include "freExceptions.h"
00028 
00029 namespace FREE
00030 {
00031 
00035 
00036 template <class TMedia>
00037 MediaControllerBase<TMedia>::
00038 MediaControllerBase()
00039 {
00040   this->UpdateControllerID(ControllerID::MediaControllerBase);
00041   this->m_Description = "Base class for all kind of media.";
00042 };
00043 
00044 template <class TMedia>
00045 void
00046 MediaControllerBase<TMedia>::
00047 GenerateProfile(CtrlProfile::ControllerProfile& profile, 
00048                 const SessionComponentCache* pComponentCache,
00049                 bool bRegardOldSetup) const
00050 {
00051   Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00052 
00053   profile.MediaMap().AddMedia("media",this->ControllerID(), DAGet,this->GetMediaDimension());
00054 };
00055 
00056 template <class TMedia>
00057 typename MediaControllerBase<TMedia>::ComponentPointer
00058 MediaControllerBase<TMedia>::
00059 BuildMainComponent(ComponentSetup* pComponentSetup, SessionComponentCache* pComponentCache) const
00060 {
00061   ComponentPointer component = Superclass::BuildMainComponent(pComponentSetup,pComponentCache);
00062   DirectSessionComponentAccessor::SetRepositoryElement(SessionComponentRepositoryKeys::MediaValidity("media"),ValidityTag::NewNull(),pComponentCache);
00063   return component;
00064 };
00065 
00066 template <class TMedia>
00067 bool
00068 MediaControllerBase<TMedia>::
00069 LoadMedia(SessionComponentCache* pCache) const
00070 {
00071         return false;
00072 };
00073 
00074 template <class TMedia>
00075 unsigned long
00076 MediaControllerBase<TMedia>::
00077 GetMediaDimension() const
00078 {
00079   return 0;
00080 };
00081 
00082 template <class TMedia>
00083 typename MediaControllerBase<TMedia>::GenericMediaPointer
00084 MediaControllerBase<TMedia>::
00085 GetMediaCasted(const MediaID& mediaID,
00086                ComponentType* pComponent,
00087                SessionComponentCache* pComponentCache,
00088                SessionInfo* pSessionInfo) const
00089 {
00090     if (!pComponentCache)
00091         throwCtrlExceptionMacro("", "Error; passed component cache is NULL");
00092     if (!pComponentCache->ComponentIsAssigned())
00093         throwCtrlExceptionMacro("", "Error; No component available to retrieve MediaID "<<mediaID<<". Check if session was correctly initialized.");
00094 
00095     /*by default the component is the media itself and can be retrieved
00096       via the media interface by using the ID media. Redefine this function,
00097         if you want to change that behaviour.*/
00098     if (mediaID == "media")
00099         return pComponentCache->Component();
00100 
00101     throwCtrlExceptionMacro("", "Error; mediaID "<<mediaID<<" is not known by the component/controller. Check if session was correctly initialized.");
00102 }; 
00103 
00104 
00105 template <class TMedia>
00106 void
00107 MediaControllerBase<TMedia>::
00108 SetMediaCasted(const MediaID& mediaID,
00109                               GenericMediaType* pMedia,
00110                                                                                                                   ComponentType* pComponent,
00111                               SessionComponentCache* pComponentCache,
00112                               SessionInfo* pSessionInfo) const
00113 {
00114     if (!pComponentCache)
00115         throwCtrlExceptionMacro("", "Error; passed component cache is NULL");
00116 
00117     /*by default the component is the media itself and can be set
00118       via the media interface by using the ID media. Also the validity
00119       tag will be updated. Redefine this function,
00120         if you want to change that behaviour.*/
00121     if (mediaID == "media")
00122     {
00123       this->SetGenericComponent(pMedia,pComponentCache);
00124       this->ActualizeMediaValidityTag(mediaID,pComponentCache);
00125     }
00126 
00127     throwCtrlExceptionMacro("", "Error; mediaID "<<mediaID<<" is not known by the component/controller. Check if session was correctly initialized.");
00128 }; 
00129 
00130 } //end of namespace free
00131 
00132 #endif

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