freMediaContainerController.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: freMediaContainerController.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 #include "freMediaContainerController.h"
00024 #include "freExceptions.h"
00025 
00026 namespace FREE
00027 {
00028 
00032 
00033 MediaContainerController::GenericMediaPointer
00034 MediaContainerController::
00035 GetMediaCasted(const MediaID& mediaID,
00036                ComponentType* pComponent,
00037                SessionComponentCache* pComponentCache,
00038                SessionInfo* pSessionInfo) const
00039 {
00040   SessionComponentCache* pMediaCache = pComponentCache->SubCaches().GetElement(mediaID);
00041   if (!pMediaCache) throwCtrlExceptionMacro("","Specified media component does not exist (mediaID: "<<mediaID<<"). Cannot get media.");
00042 
00043   GenericMediaPointer media = pMediaCache->Controller()->GetMedia("media",pMediaCache,pSessionInfo);
00044         return media;
00045 }; 
00046 
00047 void
00048 MediaContainerController::
00049 SetMediaCasted(const MediaID& mediaID, GenericMediaType* pMedia,
00050                ComponentType* pComponent,
00051                SessionComponentCache* pComponentCache,
00052                SessionInfo* pSessionInfo) const
00053 {
00054   SessionComponentCache* pMediaCache = pComponentCache->SubCaches().GetElement(mediaID);
00055   if (!pMediaCache) throwCtrlExceptionMacro("","Specified media component does not exist (mediaID: "<<mediaID<<"). Cannot set media.");
00056 
00057   pMediaCache->Controller()->SetMedia("media",pMedia,pMediaCache,pSessionInfo);
00058 }; 
00059 
00060 MediaContainerController::
00061 MediaContainerController()
00062 {
00063   this->UpdateControllerID(ControllerID::MediaContainerController);
00064   this->m_Description = "Media container offering sub containers or media needed within the registration.";
00065 };
00066 
00067 MediaContainerController::GenericComponentType*
00068 MediaContainerController::
00069 GetSubComponentCasted(ComponentType* pMainComponent, const ComponentID& compID,
00070                       SessionComponentCache* pMainComponentCache) const
00071 {
00072   SessionComponentCache* pSubCache = pMainComponentCache->SubCaches().GetElement(compID);
00073   if (!pSubCache) throwCtrlExceptionMacro("","Specified subcomponent does not exist (component ID: "<<compID<<"). Cannot get subcomponent.");
00074 
00075   if (!pSubCache->ControllerIsAssigned()) throwCtrlExceptionMacro("","Controller for specified subcomponent does not exist (component ID: "<<compID<<"). Cannot get subcomponent.");
00076  
00077   return pSubCache->Controller()->GetGenericComponent(pSubCache);
00078 }; 
00079 
00080 void
00081 MediaContainerController::
00082 SetSubComponentCasted(GenericComponentType* pSubComponent, ComponentType* pMainComponent, const ComponentID compID,
00083                       SessionComponentCache* pMainComponentCache) const
00084 {
00085   SessionComponentCache* pSubCache = pMainComponentCache->SubCaches().GetElement(compID);
00086   if (!pSubCache) throwCtrlExceptionMacro("","Specified subcomponent does not exist (component ID: "<<compID<<"). Cannot set subcomponent.");
00087 
00088   if (!pSubCache->ControllerIsAssigned()) throwCtrlExceptionMacro("","Controller for specified subcomponent does not exist (component ID: "<<compID<<"). Cannot set subcomponent.");
00089  
00090   pSubCache->Controller()->SetGenericComponent(pSubComponent, pSubCache);
00091 }; 
00092 
00093 ValidityTag::Pointer
00094 MediaContainerController::
00095 GetMediaValidityTag(const MediaID& mediaID, SessionComponentCache* pComponentCache) const
00096 {
00097         if (!pComponentCache) throwCtrlExceptionMacro("", "Error; passed component cache is NULL");
00098         
00099   SessionComponentCache* pMediaCache = pComponentCache->SubCaches().GetElement(mediaID);
00100   if (!pMediaCache) throwCtrlExceptionMacro("","Cannot retrieve ValidityTag. Specified media component does not exist (mediaID: "<<mediaID<<")");
00101 
00102   if (!pMediaCache->ControllerIsAssigned()) throwCtrlExceptionMacro("", "Error; validity tag for "<<mediaID<<" cannot retrieved; controller missing. Please, check if session is properly initialized.");
00103         
00104   try
00105   {
00106     return pMediaCache->Controller()->GetMediaValidityTag("media",pMediaCache);
00107   }
00108   catchAllNPassMacro("Error while retrieving ValidityTag of subcomponent.")
00109 }; 
00110 
00111 ValidityTag::Pointer
00112 MediaContainerController::
00113 GetMediaValidityTagRequirement(const MediaID& mediaID, SessionComponentCache* pComponentCache) const
00114 {
00115         if (!pComponentCache) throwCtrlExceptionMacro("", "Error; passed component cache is NULL");
00116         
00117   SessionComponentCache* pMediaCache = pComponentCache->SubCaches().GetElement(mediaID);
00118   if (!pMediaCache) throwCtrlExceptionMacro("","Cannot retrieve ValidityTag. Specified media component does not exist (mediaID: "<<mediaID<<")");
00119 
00120   if (!pMediaCache->ControllerIsAssigned()) throwCtrlExceptionMacro("", "Error; validity tag for "<<mediaID<<" cannot retrieved; controller missing. Please, check if session is properly initialized.");
00121         
00122   try
00123   {
00124     return pMediaCache->Controller()->GetMediaValidityTagRequirement("media",pMediaCache);
00125   }
00126   catchAllNPassMacro("Error while retrieving ValidityTag of subcomponent.")
00127 }; 
00128 
00129 std::string
00130 MediaContainerController::
00131 GetMediaControllerID(const MediaID& mediaID, SessionComponentCache* pComponentCache) const
00132 {
00133         if (!pComponentCache) throwCtrlExceptionMacro("", "Error; passed component cache is NULL");
00134         if (!pComponentCache->SetupIsAssigned()) throwCtrlExceptionMacro("", "Error; validity tag for "<<mediaID<<" cannot be retrieved. No setup avaible to check media links. Check if session was correctly initialized.");
00135 
00136         ComponentSetup* pMediaSetup = pComponentCache->Setup()->Components().GetElement(mediaID);
00137 
00138         if (pMediaSetup)
00139         { //there is a media within the media container
00140                 return pMediaSetup->GetControllerID();
00141         }
00142 
00143         return csUndefinedController;
00144 }; 
00145 
00146 } //end of namespace free

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