bea_MediumMemory Class Reference
[IVD Back-End Agent]

#include <bea_mediummemory.h>

Inheritance diagram for bea_MediumMemory:

Inheritance graph
[legend]
Collaboration diagram for bea_MediumMemory:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 30 of file bea_mediummemory.h.


Public Member Functions

 bea_MediumMemory (scsi_IO *const a_scsiIO_p)
virtual ~bea_MediumMemory ()
bool IsDetected () const
bool IsValid () const
virtual void Detect ()=0
df_TCMMedium_t GetMediumRecord () const
df_TCMMediaVolume_t GetVolumeRecord (UInt32_t a_medVolNum) const
void IncLoadCount ()
virtual void ClearRecords ()
void Refresh (UInt32_t m_numVolumes)
void UpdateAccess (UInt32_t a_medVolNum)
void UpdateAppend (UInt32_t a_medVolNum)
void UpdateOverwrite (UInt32_t a_medVolNum)
void UpdateMediumRecord (const df_TCMMedium_t &a_medMC)
void UpdateVolumeRecord (UInt32_t a_medVolNum, const df_TCMMediaVolume_t &a_medVolMC)
virtual UInt16_t GetAvailable ()=0
virtual string GetSerialNumber ()=0
virtual string GetManufacturer ()=0
virtual UInt8_t GetSecondaryID ()=0
virtual UInt8_t GetChecksum ()=0
virtual void Read ()=0
virtual void Write ()=0

Protected Member Functions

UInt32_t GetNeededSpace ()

Protected Attributes

df_TCMMedium_t m_tcmmedium
vector< df_TCMMediaVolume_tm_tcmmedia_vol
scsi_IO *const m_scsiIO_p
UInt32_t m_numVolumes
bool m_detected

Private Attributes

 log_CLASSID_m

Constructor & Destructor Documentation

bea_MediumMemory::bea_MediumMemory ( scsi_IO *const   a_scsiIO_p  ) 

Definition at line 34 of file bea_mediummemory.cpp.

References log_FUNC_m.

00035   : m_scsiIO_p(a_scsiIO_p),
00036     m_numVolumes(0),
00037     m_detected(false) {
00038 
00039     log_FUNC_m(bea_MediumMemory);
00040 }

bea_MediumMemory::~bea_MediumMemory (  )  [virtual]

Definition at line 43 of file bea_mediummemory.cpp.

References log_FUNC_m.

00043                                     {
00044     log_FUNC_m(~bea_MediumMemory);
00045 }


Member Function Documentation

bool bea_MediumMemory::IsDetected (  )  const

Definition at line 48 of file bea_mediummemory.cpp.

References m_detected.

Referenced by bea_Medium::IsMediumMemDetected().

00048                                         {
00049     return m_detected;
00050 }

Here is the caller graph for this function:

bool bea_MediumMemory::IsValid (  )  const

Definition at line 55 of file bea_mediummemory.cpp.

References df_TCMMedium_t::CheckCookie(), dbg_DETAIL, log_DBG_m, log_FUNC_m, log_WRN_m, m_detected, m_tcmmedium, and df_TCMMedium_t::mediumNoteSize.

Referenced by IncLoadCount(), bea_Medium::IsMediumMemValid(), UpdateAccess(), UpdateAppend(), and UpdateOverwrite().

00055                                      {
00056     log_FUNC_m(IsValid);
00057 
00058     if (!m_detected) {
00059         log_DBG_m(dbg_DETAIL, "CM is not detected --> not valid.");
00060         return false;
00061     };
00062 
00063     if (m_tcmmedium.mediumNoteSize != sizeof(df_TCMMedium_t)) {
00064         log_WRN_m(
00065                "MIC medium note size does not match sizeof(df_TCMMedium_t) "
00066             << m_tcmmedium.mediumNoteSize << " != " << sizeof(df_TCMMedium_t) );
00067 
00068         return false;
00069     };
00070 
00071     return m_tcmmedium.CheckCookie();
00072 }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void bea_MediumMemory::Detect (  )  [pure virtual]

Implemented in bea_MicMemory, and bea_MamMemory.

Referenced by Refresh().

Here is the caller graph for this function:

df_TCMMedium_t bea_MediumMemory::GetMediumRecord (  )  const

Definition at line 75 of file bea_mediummemory.cpp.

References m_tcmmedium, and df_TCMMedium_t::NetToHost().

Referenced by IncLoadCount(), and bea_Medium::SetBarcode().

00075                                                         {
00076 
00077     df_TCMMedium_t medMedData = m_tcmmedium;
00078     medMedData.NetToHost();
00079     return medMedData;
00080 }

Here is the call graph for this function:

Here is the caller graph for this function:

df_TCMMediaVolume_t bea_MediumMemory::GetVolumeRecord ( UInt32_t  a_medVolNum  )  const

Definition at line 84 of file bea_mediummemory.cpp.

References ie_INVALID_ARG, ivd_Error, log_FUNC_A_m, m_tcmmedia_vol, and df_TCMMediaVolume_t::NetToHost().

Referenced by bea_Volume::ReadVolInfoFromMediumMem(), UpdateAccess(), UpdateAppend(), and UpdateOverwrite().

00084                                                                                 {
00085 
00086     log_FUNC_A_m(GetVolumeRecord, "vol: " << a_medVolNum);
00087 
00088     if (a_medVolNum < 1) {
00089         throw ivd_Error(ie_INVALID_ARG, "Medium volume numbers start with 1!");
00090     };
00091 
00092     if (a_medVolNum > m_tcmmedia_vol.size()) {
00093         throw ivd_Error(ie_INVALID_ARG, "Medium volume index larger than vector.");
00094     };
00095 
00096     df_TCMMediaVolume_t medVolData;
00097     medVolData = m_tcmmedia_vol[a_medVolNum - 1];
00098     medVolData.NetToHost();
00099     return medVolData;
00100 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_MediumMemory::IncLoadCount (  ) 

Definition at line 111 of file bea_mediummemory.cpp.

References dbg_NORM, GetMediumRecord(), IsValid(), df_TCMMedium_t::loadCount, log_DBG_m, log_FUNC_m, log_WRN_m, and UpdateMediumRecord().

Referenced by i_BackEndAgent_i::UseResources().

00111                                     {
00112     log_FUNC_m(IncLoadCount);
00113 
00114     if (!IsValid()) {
00115         return;
00116     }
00117 
00118     try {
00119         df_TCMMedium_t med = GetMediumRecord();
00120         med.loadCount++;
00121         log_DBG_m(dbg_NORM, "New load count: " << med.loadCount);
00122 
00123         UpdateMediumRecord(med);
00124     }
00125     catch (ivd_Exception &ie) {
00126         log_WRN_m("Error updating MAM with new load count." <<
00127             endl << " Error: " << ie);
00128     }
00129     catch (...) {
00130         log_WRN_m("Error updating MAM with new load count.");
00131     }
00132 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_MediumMemory::ClearRecords (  )  [virtual]

Definition at line 259 of file bea_mediummemory.cpp.

References df_TCMMedium_t::Erase(), log_FUNC_m, m_numVolumes, m_tcmmedia_vol, and m_tcmmedium.

Referenced by Refresh().

00259                                     {
00260     log_FUNC_m(ClearRecords);
00261 
00262     m_tcmmedia_vol.clear();
00263     m_tcmmedium.Erase();
00264     m_tcmmedia_vol.resize(m_numVolumes);
00265 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_MediumMemory::Refresh ( UInt32_t  m_numVolumes  ) 

Definition at line 269 of file bea_mediummemory.cpp.

References ClearRecords(), dbg_DETAIL, dbg_LOW, Detect(), ivd_BaseException::GetFriendly(), log_DBG_m, log_FUNC_A_m, log_WRN_m, m_detected, m_numVolumes, m_tcmmedia_vol, and Read().

00269                                                     {
00270     log_FUNC_A_m(Refresh, "Volumes: " << a_numVolumes);
00271 
00272     m_numVolumes = a_numVolumes;
00273 
00274     ClearRecords();
00275     m_detected = false;
00276 
00277     Detect();
00278     if (!m_detected) {
00279         log_DBG_m(dbg_LOW, "Cartridge memory not detected! ");
00280         return;
00281     };
00282 
00283     m_tcmmedia_vol.resize(m_numVolumes);
00284     log_DBG_m(dbg_LOW, "m_tcmmedia_vol.size()= " << m_tcmmedia_vol.size());
00285     try {
00286         log_DBG_m(dbg_LOW, "Reading Cartridge memory contents.");
00287         Read();
00288     }
00289     catch (const ivd_BaseException &ie) {
00290         ClearRecords();
00291         log_DBG_m(dbg_DETAIL, ie);
00292         log_WRN_m(
00293                 "Cartridge memory contents can't be read. Assuming no Cartridge memory is available.." <<
00294                 " Error: " << ie.GetFriendly());
00295     }
00296     catch (...) {
00297         ClearRecords();
00298         log_WRN_m("... Cartridge memory contents can't be read. Assuming no Cartridge memory is available.");
00299     };
00300 }

Here is the call graph for this function:

void bea_MediumMemory::UpdateAccess ( UInt32_t  a_medVolNum  ) 

Definition at line 138 of file bea_mediummemory.cpp.

References dbg_NORM, GetVolumeRecord(), IsValid(), log_DBG_m, log_FUNC_A_m, log_WRN_m, NULL, df_TCMMediaVolume_t::numAccesses, df_TCMMediaVolume_t::timeAccess, and UpdateVolumeRecord().

Referenced by bea_FRI::ReadFRI(), and bea_RecallThread::Recall().

00138                                                         {
00139     log_FUNC_A_m(UpdateAccess, "vol: " << a_medVolNum);
00140 
00141     if (!IsValid()) {
00142         return;
00143     }
00144     try {
00145         df_TCMMediaVolume_t mv = GetVolumeRecord(a_medVolNum);
00146         ivd_Time_t now = (ivd_Time_t)time(NULL);
00147         mv.timeAccess = now;
00148         mv.numAccesses++;
00149         log_DBG_m(dbg_NORM, "New access count: " << mv.numAccesses);
00150 
00151         UpdateVolumeRecord(a_medVolNum, mv);
00152     }
00153     catch (ivd_Exception &ie) {
00154         log_WRN_m("Error updating MIC with new access data. Med. volume: " << a_medVolNum <<
00155             endl << " Error: " << ie);
00156     }
00157     catch (...) {
00158         log_WRN_m("Error updating MIC with new access data. Med. volume: " << a_medVolNum);
00159     };
00160 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_MediumMemory::UpdateAppend ( UInt32_t  a_medVolNum  ) 

Definition at line 164 of file bea_mediummemory.cpp.

References dbg_NORM, GetVolumeRecord(), IsValid(), log_DBG_m, log_FUNC_A_m, log_WRN_m, NULL, df_TCMMediaVolume_t::numAccesses, df_TCMMediaVolume_t::numAppends, df_TCMMediaVolume_t::timeAccess, df_TCMMediaVolume_t::timeWrite, and UpdateVolumeRecord().

Referenced by i_BackEndAgent_i::UpdateVolumeUsed().

00164                                                         {
00165     log_FUNC_A_m(UpdateAppend, "volume: " << a_medVolNum);
00166 
00167     if (!IsValid()) {
00168         return;
00169     }
00170 
00171     try {
00172         df_TCMMediaVolume_t mv = GetVolumeRecord(a_medVolNum);
00173         ivd_Time_t now = (ivd_Time_t)time(NULL);
00174         mv.timeAccess = now;
00175         mv.numAccesses++;
00176         mv.timeWrite = now;
00177         mv.numAppends++;
00178         log_DBG_m(dbg_NORM,
00179             "New access count: " << mv.numAccesses << endl <<
00180             "New append count: " << mv.numAppends);
00181         UpdateVolumeRecord(a_medVolNum, mv);
00182     }
00183     catch (ivd_Exception &ie) {
00184         log_WRN_m("Error updating MIC with new append data. Med. volume: " << a_medVolNum <<
00185             endl << " Error: " << ie);
00186     }
00187     catch (...) {
00188         log_WRN_m("Error updating MIC with new append data. Med. volume: " << a_medVolNum);
00189     }
00190 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_MediumMemory::UpdateOverwrite ( UInt32_t  a_medVolNum  ) 

Definition at line 194 of file bea_mediummemory.cpp.

References dbg_NORM, GetVolumeRecord(), IsValid(), log_DBG_m, log_FUNC_A_m, log_WRN_m, NULL, df_TCMMediaVolume_t::numAccesses, df_TCMMediaVolume_t::numOverwrites, df_TCMMediaVolume_t::timeAccess, df_TCMMediaVolume_t::timeOverwrite, and UpdateVolumeRecord().

00194                                                            {
00195     log_FUNC_A_m(UpdateOverwrite, "volume: " << a_medVolNum);
00196 
00197     if (!IsValid()) {
00198         return;
00199     }
00200 
00201     try {
00202         df_TCMMediaVolume_t mv = GetVolumeRecord(a_medVolNum);
00203         ivd_Time_t now = (ivd_Time_t)time(NULL);
00204         mv.timeAccess = now;
00205         mv.numAccesses++;
00206         mv.timeOverwrite = now;
00207         mv.numOverwrites++;
00208         log_DBG_m(dbg_NORM,
00209             "New access count: " << mv.numAccesses << endl <<
00210             "New overwrite count: " << mv.numOverwrites);
00211 
00212         UpdateVolumeRecord(a_medVolNum, mv);
00213     }
00214     catch (ivd_Exception &ie) {
00215         log_WRN_m("Error updating CM with new overwrite data. Med. volume: " << a_medVolNum <<
00216             endl << " Error: " << ie);
00217     }
00218     catch (...) {
00219         log_WRN_m("Error updating CM with new overwrite data. Med. volume: " << a_medVolNum);
00220     }
00221 }

Here is the call graph for this function:

void bea_MediumMemory::UpdateMediumRecord ( const df_TCMMedium_t a_medMC  ) 

Definition at line 225 of file bea_mediummemory.cpp.

References df_TCMMedium_t::barcode, cmn_Num2Str(), dbg_DETAIL, df_TCMMedium_t::HostToNet(), df_TCMMedium_t::loadCount, log_DBG_m, log_FUNC_m, m_tcmmedium, df_TCMMedium_t::mediumNoteSize, df_TCMMedium_t::medVolNoteSize, df_TCMMedium_t::productID, df_TCMMedium_t::revisionID, df_TCMMedium_t::serialNumber, df_TCMMedium_t::vendorID, df_TCMMedium_t::verMajor, and df_TCMMedium_t::verMinor.

Referenced by IncLoadCount(), bea_Medium::SetBarcode(), and bea_Volume::UpdateMediumMem().

00225                                                                        {
00226     log_FUNC_m(UpdateMediumRecord);
00227 
00228     // implement ostream operator for df_TCMMedium_t
00229     log_DBG_m(dbg_DETAIL, "** Medium record **" <<
00230         endl << "verMajor       " << cmn_Num2Str(a_medMC.verMajor)  <<
00231         endl << "verMinor       " << cmn_Num2Str(a_medMC.verMinor)  <<
00232         endl << "mediumNoteSize " << a_medMC.mediumNoteSize  <<
00233         endl << "medVolNoteSize " << a_medMC.medVolNoteSize  <<
00234         endl << "loadCount      " << a_medMC.loadCount  <<
00235         endl << "barcode        " << a_medMC.barcode  <<
00236         endl << "vendorID       " << a_medMC.vendorID  <<
00237         endl << "productID      " << a_medMC.productID  <<
00238         endl << "revisionID     " << a_medMC.revisionID  <<
00239         endl << "serialNumber   " << a_medMC.serialNumber  <<
00240         endl);
00241 
00242     m_tcmmedium = a_medMC;
00243     m_tcmmedium.HostToNet();
00244 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_MediumMemory::UpdateVolumeRecord ( UInt32_t  a_medVolNum,
const df_TCMMediaVolume_t a_medVolMC 
)

Definition at line 248 of file bea_mediummemory.cpp.

References log_FUNC_A_m, and m_tcmmedia_vol.

Referenced by UpdateAccess(), UpdateAppend(), bea_Volume::UpdateMediumMem(), and UpdateOverwrite().

00249                                                                  {
00250 
00251     log_FUNC_A_m(UpdateVolumeRecord, "vol: " << a_medVolNum);
00252 
00253     // implement ostream operator for df_TCMMediaVolume_t
00254     m_tcmmedia_vol[a_medVolNum-1] = a_medVolMC;
00255     m_tcmmedia_vol[a_medVolNum-1].HostToNet();
00256 }

Here is the caller graph for this function:

virtual UInt16_t bea_MediumMemory::GetAvailable (  )  [pure virtual]

Implemented in bea_MicMemory, and bea_MamMemory.

virtual string bea_MediumMemory::GetSerialNumber (  )  [pure virtual]

Implemented in bea_MicMemory, and bea_MamMemory.

virtual string bea_MediumMemory::GetManufacturer (  )  [pure virtual]

Implemented in bea_MicMemory, and bea_MamMemory.

virtual UInt8_t bea_MediumMemory::GetSecondaryID (  )  [pure virtual]

Implemented in bea_MicMemory, and bea_MamMemory.

virtual UInt8_t bea_MediumMemory::GetChecksum (  )  [pure virtual]

Implemented in bea_MicMemory, and bea_MamMemory.

virtual void bea_MediumMemory::Read (  )  [pure virtual]

Implemented in bea_MicMemory, and bea_MamMemory.

Referenced by Refresh().

Here is the caller graph for this function:

virtual void bea_MediumMemory::Write (  )  [pure virtual]

Implemented in bea_MicMemory, and bea_MamMemory.

Referenced by bea_TapeDrive::Close().

Here is the caller graph for this function:

UInt32_t bea_MediumMemory::GetNeededSpace (  )  [protected]

Definition at line 103 of file bea_mediummemory.cpp.

References m_numVolumes.

Referenced by bea_MicMemory::Read(), and bea_MicMemory::Write().

00103                                           {
00104     return
00105         sizeof(df_TCMMedium_t) +
00106         m_numVolumes * sizeof(df_TCMMediaVolume_t);
00107 }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 72 of file bea_mediummemory.h.

Referenced by ClearRecords(), GetNeededSpace(), and Refresh().

bool bea_MediumMemory::m_detected [protected]

Reimplemented in bea_MicMemory, and bea_MamMemory.

Definition at line 77 of file bea_mediummemory.h.


The documentation for this class was generated from the following files:

Generated on Mon Feb 27 18:59:56 2012 for OPENARCHIVE by  doxygen 1.5.6