Public Member Functions | Private Member Functions | Private Attributes

bea_MamMemory Class Reference
[IVD Back-End Agent]

#include <bea_mediummemory.h>

Inheritance diagram for bea_MamMemory:
Inheritance graph
[legend]
Collaboration diagram for bea_MamMemory:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 bea_MamMemory (scsi_IO *const a_scsiIO_p)
virtual ~bea_MamMemory ()
virtual void Detect ()
virtual UInt16_t GetAvailable ()
virtual string GetSerialNumber ()
virtual string GetManufacturer ()
virtual UInt8_t GetSecondaryID ()
virtual UInt8_t GetChecksum ()
virtual void Read ()
virtual void Write ()

Private Member Functions

void ReadAttributeList (data_Attribute &a_daList)

Private Attributes

 log_CLASSID_m

Detailed Description

Definition at line 125 of file bea_mediummemory.h.


Constructor & Destructor Documentation

bea_MamMemory::bea_MamMemory ( scsi_IO *const   a_scsiIO_p  ) 

Definition at line 47 of file bea_mammemory.cpp.

References log_FUNC_m.

bea_MamMemory::~bea_MamMemory (  )  [virtual]

Definition at line 54 of file bea_mammemory.cpp.

References log_FUNC_m.


Member Function Documentation

void bea_MamMemory::Detect (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 83 of file bea_mammemory.cpp.

References cmn_GetEnvVariable(), dbg_LOW, dbg_NORM, ivd_BaseException::GetFriendly(), log_DBG_m, log_FUNC_m, bea_MediumMemory::m_detected, and ReadAttributeList().

                           {
    log_FUNC_m(Detect);

    m_detected = false;
    // Is the MAM functionality enabled at all?
    {
        static const char* const useMAM_c("HSM_USE_MAM");
        string useMAM = cmn_GetEnvVariable(useMAM_c);
        if (useMAM == "no" || useMAM == "false") {
            log_DBG_m(dbg_LOW,
                useMAM_c << " = \'" << useMAM <<
                "\'. MAM functionality explicitly disabled.");
            return;
        }
    }
    {
        static const char* const useMAM_c("HSM_USE_CM");
        string useMAM = cmn_GetEnvVariable(useMAM_c);
        if (useMAM == "no" || useMAM == "false") {
            log_DBG_m(dbg_LOW,
                useMAM_c << " = \'" << useMAM <<
                "\'. MAM functionality explicitly disabled.");
            return;
        }
    }

    try {
        // Was MAM detected by the tape drive?
        data_Attribute daList;
        ReadAttributeList(daList);
        m_detected = true;
        log_DBG_m(dbg_LOW, "MAM detected.");
    }
    catch (ivd_Exception &ie) {
        log_DBG_m(dbg_NORM, "MAM not detected: " << ie.GetFriendly());
    }
    catch (...) {
        log_DBG_m(dbg_NORM, "MAM not detected. Unknown exception.");
    }
}

Here is the call graph for this function:

UInt16_t bea_MamMemory::GetAvailable (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 71 of file bea_mammemory.cpp.

References data_Attribute::att_FREE, data_Attribute::GetMamFreeSpace(), data_Attribute::Init(), scsi_IO::IOCtl(), log_FUNC_m, and bea_MediumMemory::m_scsiIO_p.

                                     {
    log_FUNC_m(GetAvailable);

    data_Attribute attr;
    attr.Init(data_Attribute::att_FREE);
    cdb_ReadAttribute readAttr(attr);
    m_scsiIO_p->IOCtl(readAttr);
    return static_cast<UInt16_t>(attr.GetMamFreeSpace());
}

Here is the call graph for this function:

UInt8_t bea_MamMemory::GetChecksum (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 148 of file bea_mammemory.cpp.

                                  {
    return 0;
}

string bea_MamMemory::GetManufacturer (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 134 of file bea_mammemory.cpp.

References data_Attribute::att_MEDMANUF, data_Attribute::GetMediumManufact(), data_Attribute::Init(), scsi_IO::IOCtl(), and bea_MediumMemory::m_scsiIO_p.

                                      {
    data_Attribute attr;
    attr.Init(data_Attribute::att_MEDMANUF);
    cdb_ReadAttribute readAttr(attr);
    m_scsiIO_p->IOCtl(readAttr);
    return attr.GetMediumManufact();
}

Here is the call graph for this function:

UInt8_t bea_MamMemory::GetSecondaryID (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 143 of file bea_mammemory.cpp.

                                     {
    return 0;
}

string bea_MamMemory::GetSerialNumber (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 125 of file bea_mammemory.cpp.

References data_Attribute::att_SERNO, data_Attribute::GetSerialNumber(), data_Attribute::Init(), scsi_IO::IOCtl(), and bea_MediumMemory::m_scsiIO_p.

                                     {
    data_Attribute attr;
    attr.Init(data_Attribute::att_SERNO);
    cdb_ReadAttribute readAttr(attr);
    m_scsiIO_p->IOCtl(readAttr);
    return attr.GetSerialNumber();
}

Here is the call graph for this function:

void bea_MamMemory::Read (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 154 of file bea_mammemory.cpp.

References data_Attribute::att_MEDPOOL, data_Attribute::att_USRLABEL, cmn_HexDump(), dbg_DETAIL, data_Attribute::GetAttributeSize(), data_Attribute::GetAttrValue(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_m, bea_MediumMemory::m_scsiIO_p, bea_MediumMemory::m_tcmmedia_vol, bea_MediumMemory::m_tcmmedium, and df_TCMMediaVolume_t::NetToHost().

                         {
    log_FUNC_m(ReadVolumeRecords);

    {
        log_DBG_m(dbg_DETAIL, "Reading Medium record from att_USRLABEL");

        data_Attribute attr(data_Attribute::att_USRLABEL);
        cdb_ReadAttribute readAttr(attr);
        m_scsiIO_p->IOCtl(readAttr);

        // IMPORTANT NOTE:
        // df_TCMMedium_t is larger than the att_USRLABEL
        // We cut off a part of medium serial number when writing to the MAM attribute
        // Medium serial number is FYI anyway.
        UInt32_t toCopy( attr.GetAttributeSize() );
        if (sizeof(df_TCMMedium_t) < toCopy) {
            toCopy = sizeof(df_TCMMedium_t);
        }

        memcpy(&(m_tcmmedium), attr.GetAttrValue(), toCopy);

        df_TCMMedium_t medRec(m_tcmmedium);
        medRec.NetToHost();

        log_DBG_m(dbg_DETAIL,
            "USRLABEL contents:" << endl <<
            cmn_HexDump(attr.GetAttrValue(), toCopy, 16, true) );

        // TODO: ostream operator
    }

    {
        log_DBG_m(dbg_DETAIL, "Reading volume record from att_MEDPOOL");

        data_Attribute attr(data_Attribute::att_MEDPOOL);
        cdb_ReadAttribute readAttr(attr);
        m_scsiIO_p->IOCtl(readAttr);
        memcpy(&(m_tcmmedia_vol[0]), attr.GetAttrValue(), sizeof(df_TCMMediaVolume_t));

        df_TCMMediaVolume_t volRec(m_tcmmedia_vol[0]);
        volRec.NetToHost();

        log_DBG_m(dbg_DETAIL,
            "MEDPOOL contents:" << endl <<
            cmn_HexDump(attr.GetAttrValue(), sizeof(df_TCMMediaVolume_t), 16, true) );

        // TODO: ostream operator
    }

}

Here is the call graph for this function:

void bea_MamMemory::ReadAttributeList ( data_Attribute a_daList  )  [private]

Definition at line 61 of file bea_mammemory.cpp.

References data_Attribute::att_ATTRLIST, data_Attribute::Init(), scsi_IO::IOCtl(), log_FUNC_m, and bea_MediumMemory::m_scsiIO_p.

Referenced by Detect().

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_MamMemory::Write (  )  [virtual]

Implements bea_MediumMemory.

Definition at line 207 of file bea_mammemory.cpp.

References data_Attribute::att_MEDPOOL, data_Attribute::att_USRLABEL, dbg_DETAIL, data_Attribute::GetAttributeSize(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_m, bea_MediumMemory::m_scsiIO_p, bea_MediumMemory::m_tcmmedia_vol, bea_MediumMemory::m_tcmmedium, and data_Attribute::SetAttrValue().

                          {

    log_FUNC_m(Write);

    {
        log_DBG_m(dbg_DETAIL, "Writing medium record to att_USRLABEL");

        data_Attribute attr(data_Attribute::att_USRLABEL);
        log_DBG_m(dbg_DETAIL, "att_USRLABEL attr size: " << attr.GetAttributeSize());

        // IMPORTANT NOTE:
        // df_TCMMedium_t is larger than the att_USRLABEL
        // We cut off a part of medium serial number when writing to the MAM attribute
        // Medium serial number is FYI anyway.
        UInt32_t toCopy( attr.GetAttributeSize() );
        if (sizeof(df_TCMMedium_t) < toCopy) {
            toCopy = sizeof(df_TCMMedium_t);
        }

        vector<char> medbuf(toCopy);

        memcpy(&(medbuf[0]), &(m_tcmmedium), toCopy);
        attr.SetAttrValue(&(medbuf[0]));

        cdb_WriteAttribute writeAttr(attr);
        m_scsiIO_p->IOCtl(writeAttr);

        log_DBG_m(dbg_DETAIL, "Medium Record is written to MAM");

        // TODO: Write the barcode to the att_BARCODE as well (standard field to
        // store barcode.
    }

    {
        log_DBG_m(dbg_DETAIL, "Writing volume record to att_MEDPOOL");

        data_Attribute attr(data_Attribute::att_MEDPOOL);

        log_DBG_m(dbg_DETAIL, "att_MEDPOOL attr size: " << attr.GetAttributeSize());
        log_DBG_m(dbg_DETAIL, "m_tcmmedia_vol.size: " << m_tcmmedia_vol.size());

        vector<char> volbuf(attr.GetAttributeSize());
        memcpy(&(volbuf[0]), &(m_tcmmedia_vol[0]), sizeof(df_TCMMediaVolume_t));

        log_DBG_m(dbg_DETAIL, "attr.SetAttrValue ");
        attr.SetAttrValue(&(volbuf[0]));

        cdb_WriteAttribute writeAttr(attr);
        m_scsiIO_p->IOCtl(writeAttr);

        log_DBG_m(dbg_DETAIL, "Medium Volume Record is written to MAM");
    }
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from bea_MediumMemory.

Definition at line 143 of file bea_mediummemory.h.


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