Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes

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.

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

Detailed Description

Definition at line 44 of file bea_mediummemory.h.


Constructor & Destructor Documentation

bea_MediumMemory::bea_MediumMemory ( scsi_IO *const   a_scsiIO_p  ) 

Definition at line 48 of file bea_mediummemory.cpp.

References log_FUNC_m.

bea_MediumMemory::~bea_MediumMemory (  )  [virtual]

Definition at line 57 of file bea_mediummemory.cpp.

References log_FUNC_m.


Member Function Documentation

void bea_MediumMemory::ClearRecords (  )  [virtual]

Definition at line 273 of file bea_mediummemory.cpp.

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

Referenced by Refresh().

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:

virtual UInt16_t bea_MediumMemory::GetAvailable (  )  [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 string bea_MediumMemory::GetManufacturer (  )  [pure virtual]

Implemented in bea_MicMemory, and bea_MamMemory.

df_TCMMedium_t bea_MediumMemory::GetMediumRecord (  )  const

Definition at line 89 of file bea_mediummemory.cpp.

References m_tcmmedium, and df_TCMMedium_t::NetToHost().

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

                                                        {

    df_TCMMedium_t medMedData = m_tcmmedium;
    medMedData.NetToHost();
    return medMedData;
}

Here is the call graph for this function:

Here is the caller graph for this function:

UInt32_t bea_MediumMemory::GetNeededSpace (  )  [protected]

Definition at line 117 of file bea_mediummemory.cpp.

References m_numVolumes.

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

                                          {
    return
        sizeof(df_TCMMedium_t) +
        m_numVolumes * sizeof(df_TCMMediaVolume_t);
}

Here is the caller graph for this function:

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

Implemented in bea_MicMemory, and bea_MamMemory.

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

Implemented in bea_MicMemory, and bea_MamMemory.

df_TCMMediaVolume_t bea_MediumMemory::GetVolumeRecord ( UInt32_t  a_medVolNum  )  const

Definition at line 98 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().

                                                                                {

    log_FUNC_A_m(GetVolumeRecord, "vol: " << a_medVolNum);

    if (a_medVolNum < 1) {
        throw ivd_Error(ie_INVALID_ARG, "Medium volume numbers start with 1!");
    };

    if (a_medVolNum > m_tcmmedia_vol.size()) {
        throw ivd_Error(ie_INVALID_ARG, "Medium volume index larger than vector.");
    };

    df_TCMMediaVolume_t medVolData;
    medVolData = m_tcmmedia_vol[a_medVolNum - 1];
    medVolData.NetToHost();
    return medVolData;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_MediumMemory::IncLoadCount (  ) 

Definition at line 125 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().

                                    {
    log_FUNC_m(IncLoadCount);

    if (!IsValid()) {
        return;
    }

    try {
        df_TCMMedium_t med = GetMediumRecord();
        med.loadCount++;
        log_DBG_m(dbg_NORM, "New load count: " << med.loadCount);

        UpdateMediumRecord(med);
    }
    catch (ivd_Exception &ie) {
        log_WRN_m("Error updating MAM with new load count." <<
            endl << " Error: " << ie);
    }
    catch (...) {
        log_WRN_m("Error updating MAM with new load count.");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool bea_MediumMemory::IsDetected (  )  const

Definition at line 62 of file bea_mediummemory.cpp.

References m_detected.

Referenced by bea_Medium::IsMediumMemDetected().

                                        {
    return m_detected;
}

Here is the caller graph for this function:

bool bea_MediumMemory::IsValid (  )  const

Definition at line 69 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().

                                     {
    log_FUNC_m(IsValid);

    if (!m_detected) {
        log_DBG_m(dbg_DETAIL, "CM is not detected --> not valid.");
        return false;
    };

    if (m_tcmmedium.mediumNoteSize != sizeof(df_TCMMedium_t)) {
        log_WRN_m(
               "MIC medium note size does not match sizeof(df_TCMMedium_t) "
            << m_tcmmedium.mediumNoteSize << " != " << sizeof(df_TCMMedium_t) );

        return false;
    };

    return m_tcmmedium.CheckCookie();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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:

void bea_MediumMemory::Refresh ( UInt32_t  m_numVolumes  ) 

Definition at line 283 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().

                                                    {
    log_FUNC_A_m(Refresh, "Volumes: " << a_numVolumes);

    m_numVolumes = a_numVolumes;

    ClearRecords();
    m_detected = false;

    Detect();
    if (!m_detected) {
        log_DBG_m(dbg_LOW, "Cartridge memory not detected! ");
        return;
    };

    m_tcmmedia_vol.resize(m_numVolumes);
    log_DBG_m(dbg_LOW, "m_tcmmedia_vol.size()= " << m_tcmmedia_vol.size());
    try {
        log_DBG_m(dbg_LOW, "Reading Cartridge memory contents.");
        Read();
    }
    catch (const ivd_BaseException &ie) {
        ClearRecords();
        log_DBG_m(dbg_DETAIL, ie);
        log_WRN_m(
                "Cartridge memory contents can't be read. Assuming no Cartridge memory is available.." <<
                " Error: " << ie.GetFriendly());
    }
    catch (...) {
        ClearRecords();
        log_WRN_m("... Cartridge memory contents can't be read. Assuming no Cartridge memory is available.");
    };
}

Here is the call graph for this function:

void bea_MediumMemory::UpdateAccess ( UInt32_t  a_medVolNum  ) 

Definition at line 152 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().

                                                        {
    log_FUNC_A_m(UpdateAccess, "vol: " << a_medVolNum);

    if (!IsValid()) {
        return;
    }
    try {
        df_TCMMediaVolume_t mv = GetVolumeRecord(a_medVolNum);
        ivd_Time_t now = (ivd_Time_t)time(NULL);
        mv.timeAccess = now;
        mv.numAccesses++;
        log_DBG_m(dbg_NORM, "New access count: " << mv.numAccesses);

        UpdateVolumeRecord(a_medVolNum, mv);
    }
    catch (ivd_Exception &ie) {
        log_WRN_m("Error updating MIC with new access data. Med. volume: " << a_medVolNum <<
            endl << " Error: " << ie);
    }
    catch (...) {
        log_WRN_m("Error updating MIC with new access data. Med. volume: " << a_medVolNum);
    };
}

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 178 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().

                                                        {
    log_FUNC_A_m(UpdateAppend, "volume: " << a_medVolNum);

    if (!IsValid()) {
        return;
    }

    try {
        df_TCMMediaVolume_t mv = GetVolumeRecord(a_medVolNum);
        ivd_Time_t now = (ivd_Time_t)time(NULL);
        mv.timeAccess = now;
        mv.numAccesses++;
        mv.timeWrite = now;
        mv.numAppends++;
        log_DBG_m(dbg_NORM,
            "New access count: " << mv.numAccesses << endl <<
            "New append count: " << mv.numAppends);
        UpdateVolumeRecord(a_medVolNum, mv);
    }
    catch (ivd_Exception &ie) {
        log_WRN_m("Error updating MIC with new append data. Med. volume: " << a_medVolNum <<
            endl << " Error: " << ie);
    }
    catch (...) {
        log_WRN_m("Error updating MIC with new append data. Med. volume: " << a_medVolNum);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_MediumMemory::UpdateMediumRecord ( const df_TCMMedium_t a_medMC  ) 

Definition at line 239 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().

                                                                       {
    log_FUNC_m(UpdateMediumRecord);

    // implement ostream operator for df_TCMMedium_t
    log_DBG_m(dbg_DETAIL, "** Medium record **" <<
        endl << "verMajor       " << cmn_Num2Str(a_medMC.verMajor)  <<
        endl << "verMinor       " << cmn_Num2Str(a_medMC.verMinor)  <<
        endl << "mediumNoteSize " << a_medMC.mediumNoteSize  <<
        endl << "medVolNoteSize " << a_medMC.medVolNoteSize  <<
        endl << "loadCount      " << a_medMC.loadCount  <<
        endl << "barcode        " << a_medMC.barcode  <<
        endl << "vendorID       " << a_medMC.vendorID  <<
        endl << "productID      " << a_medMC.productID  <<
        endl << "revisionID     " << a_medMC.revisionID  <<
        endl << "serialNumber   " << a_medMC.serialNumber  <<
        endl);

    m_tcmmedium = a_medMC;
    m_tcmmedium.HostToNet();
}

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 208 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().

                                                           {
    log_FUNC_A_m(UpdateOverwrite, "volume: " << a_medVolNum);

    if (!IsValid()) {
        return;
    }

    try {
        df_TCMMediaVolume_t mv = GetVolumeRecord(a_medVolNum);
        ivd_Time_t now = (ivd_Time_t)time(NULL);
        mv.timeAccess = now;
        mv.numAccesses++;
        mv.timeOverwrite = now;
        mv.numOverwrites++;
        log_DBG_m(dbg_NORM,
            "New access count: " << mv.numAccesses << endl <<
            "New overwrite count: " << mv.numOverwrites);

        UpdateVolumeRecord(a_medVolNum, mv);
    }
    catch (ivd_Exception &ie) {
        log_WRN_m("Error updating CM with new overwrite data. Med. volume: " << a_medVolNum <<
            endl << " Error: " << ie);
    }
    catch (...) {
        log_WRN_m("Error updating CM with new overwrite data. Med. volume: " << a_medVolNum);
    }
}

Here is the call graph for this function:

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

Definition at line 262 of file bea_mediummemory.cpp.

References log_FUNC_A_m, and m_tcmmedia_vol.

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

                                                                 {

    log_FUNC_A_m(UpdateVolumeRecord, "vol: " << a_medVolNum);

    // implement ostream operator for df_TCMMediaVolume_t
    m_tcmmedia_vol[a_medVolNum-1] = a_medVolMC;
    m_tcmmedia_vol[a_medVolNum-1].HostToNet();
}

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:


Member Data Documentation

Reimplemented in bea_MicMemory, and bea_MamMemory.

Definition at line 91 of file bea_mediummemory.h.

bool bea_MediumMemory::m_detected [protected]

Definition at line 86 of file bea_mediummemory.h.

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


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