freMediaBridgeController.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: freMediaBridgeController.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 "freMediaBridgeController.h"
00024 #include "freExceptions.h"
00025 
00026 namespace FREE
00027 {
00028 
00032 
00033 MediaBridgeController::GenericMediaPointer
00034 MediaBridgeController::
00035 GetMediaCasted(const MediaID& mediaID,
00036                ComponentType* pComponent,
00037                SessionComponentCache* pComponentCache,
00038                SessionInfo* pSessionInfo) const
00039 {
00040   if (!pComponentCache) throwCtrlExceptionMacro("","Passed component cache is NULL.");
00041   if (!pSessionInfo) throwCtrlExceptionMacro("","Passed session info is NULL.");
00042 
00043   ComponentMediaLink::Pointer smpLink = pComponentCache->Setup()->MediaLinks().GetElement(mediaID);
00044   if (smpLink.IsNotNull())
00045   { //there is a link for the media, so get it
00046     try
00047     {
00048       GenericMediaPointer smpMedia = SessionAccessor::GetLinkedMedia(mediaID, pComponentCache, pSessionInfo);
00049       return smpMedia;
00050     }
00051     catchAllNPassMacro("Error while getting bridged media. Media ID: "<<mediaID<<" ; link: "<<smpLink->GetSourceIDPath().ToStr());
00052   }
00053   else
00054   {
00055     return Superclass::GetMediaCasted(mediaID, pComponent, pComponentCache, pSessionInfo);
00056   }
00057 }; 
00058 
00059 void
00060 MediaBridgeController::
00061 SetMediaCasted(const MediaID& mediaID, GenericMediaType* pMedia, ComponentType* pComponent,
00062                SessionComponentCache* pComponentCache,
00063                SessionInfo* pSessionInfo) const
00064 {
00065   if (!pComponentCache) throwCtrlExceptionMacro("","Passed component cache is NULL.");
00066   if (!pSessionInfo) throwCtrlExceptionMacro("","Passed session info is NULL.");
00067 
00068   ComponentMediaLink::Pointer smpLink = pComponentCache->Setup()->MediaLinks().GetElement(mediaID);
00069   if (smpLink.IsNotNull())
00070   { //there is a link for the media, so set it
00071     try
00072     {
00073       GenericMediaPointer smpMedia = pMedia;
00074       SessionAccessor::SetMedia(smpLink->GetSourceIDPath(), smpMedia, pSessionInfo);
00075     }
00076     catchAllNPassMacro("Error while setting bridged media. Media ID: "<<mediaID<<" ; link: "<<smpLink->GetSourceIDPath().ToStr());
00077   }
00078   else
00079   {
00080     Superclass::SetMediaCasted(mediaID, pMedia, pComponent, pComponentCache, pSessionInfo);
00081   }
00082 }; 
00083 
00084 MediaBridgeController::
00085 MediaBridgeController()
00086 {
00087   this->UpdateControllerID(ControllerID::MediaBridgeController);
00088   this->m_Description = "Media bridge offering the possibility of logical bridges/stubs (e.g. used as final media repository).";
00089 };
00090 
00091 ValidityTag::Pointer
00092 MediaBridgeController::
00093 GetMediaValidityTag(const MediaID& mediaID, SessionComponentCache* pComponentCache) const
00094 {
00095   if (!pComponentCache) throwCtrlExceptionMacro("","Passed component cache is NULL.");
00096 
00097   ComponentMediaLink::Pointer smpLink = pComponentCache->Setup()->MediaLinks().GetElement(mediaID);
00098   if (smpLink.IsNotNull())
00099   { //there is a link for the media, so get the validity tag
00100     try
00101     {
00102       return SessionAccessor::GetValidityTag(smpLink->GetSourceIDPath(),pComponentCache);
00103     }
00104     catchAllNPassMacro("Error while retrieving validity tag. Media ID: "<<mediaID<<" ; link: "<<smpLink->GetSourceIDPath().ToStr());
00105   }
00106   else
00107   {
00108     return Superclass::GetMediaValidityTag(mediaID, pComponentCache);
00109   }
00110 }; 
00111 
00112 ValidityTag::Pointer
00113 MediaBridgeController::
00114 GetMediaValidityTagRequirement(const MediaID& mediaID, SessionComponentCache* pComponentCache) const
00115 {
00116   if (!pComponentCache) throwCtrlExceptionMacro("","Passed component cache is NULL.");
00117 
00118   ComponentMediaLink::Pointer smpLink = pComponentCache->Setup()->MediaLinks().GetElement(mediaID);
00119   if (smpLink.IsNotNull())
00120   { //there is a link for the media, so get the validity tag requirement
00121     try
00122     {
00123       return SessionAccessor::GetValidityTagRequirement(smpLink->GetSourceIDPath(),pComponentCache);
00124     }
00125     catchAllNPassMacro("Error while retrieving validity tag requirement. Media ID: "<<mediaID<<" ; link: "<<smpLink->GetSourceIDPath().ToStr());
00126   }
00127   else
00128   {
00129     return Superclass::GetMediaValidityTagRequirement(mediaID, pComponentCache);
00130   }
00131 }; 
00132 
00133 std::string
00134 MediaBridgeController::
00135 GetMediaControllerID(const MediaID& mediaID, SessionComponentCache* pComponentCache) const
00136 {
00137   if (!pComponentCache) throwCtrlExceptionMacro("","Passed component cache is NULL.");
00138 
00139   ComponentMediaLink::Pointer smpLink = pComponentCache->Setup()->MediaLinks().GetElement(mediaID);
00140   if (smpLink.IsNotNull())
00141   { //there is a link for the media, so get controller id
00142     try
00143     {
00144       return SessionAccessor::GetMediaControllerID(smpLink->GetSourceIDPath(),pComponentCache);
00145     }
00146     catchAllNPassMacro("Error while retrieving controller id. Media ID: "<<mediaID<<" ; link: "<<smpLink->GetSourceIDPath().ToStr());
00147   }
00148 
00149         return csUndefinedController;
00150 }; 
00151 
00152 } //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