00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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)
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 }
00128
00129 #endif