Public Types | Public Member Functions | Static Public Attributes | Private Attributes

data_Attribute Class Reference
[SCSI Library]

MAM data attribute. More...

#include <data.h>

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

List of all members.

Public Types

enum  DataType_t {
  et_BIN = 0x00, et_ASCII = 0x01,
  et_TEXT = 0x02
}
enum  MediaType_t {
  et_DATA = 0x00, et_CLEAN = 0x01,
  et_WORM = 0x80
}

Public Member Functions

 data_Attribute ()
 data_Attribute (UInt16_t a_type)
virtual ~data_Attribute ()
const data_Attribute_tGetAttributeData () const
UInt16_t GetId ()
string GetSerialNumber () const
UInt64_t GetMamCapacity () const
UInt64_t GetMamFreeSpace () const
UInt16_t GetAttributeSize () const
const char * GetAttrValue ()
UInt32_t GetAttrIDDataLength () const
UInt32_t GetAttrIDListLength () const
UInt32_t GetAttributeListLength () const
const UInt16_tGetAttrList () const
string GetMediumManufact () const
bool IsWorm () const
void SetAvailableData (scsi_UInt32 a_datasize)
void SetAttrValue (const char *a_attrValue)
void Init (UInt16_t a_type)
void ClearAttrValue ()
bool FindAttrID (UInt16_t a_attrId)
bool CheckMamAttributes ()

Static Public Attributes

static const UInt16_t att_ATTRLIST = 0x0000
static const UInt16_t att_SERNO = 0x0401
static const UInt16_t att_CAPACITY = 0x0407
static const UInt16_t att_MEDMANUF = 0x0400
static const UInt16_t att_FREE = 0x0004
static const UInt16_t att_USRLABEL = 0x0803
static const UInt16_t att_MEDPOOL = 0x0808
static const UInt32_t m_snSize = 8
static const UInt32_t m_capSize = 8
static const UInt32_t m_frsSize = 8
static const UInt32_t m_ulSize = 160
static const UInt32_t m_mpSize = 160
static const UInt32_t m_manufSize = 8

Private Attributes

 log_CLASSID_m
UInt16_t m_type
data_Attribute_t m_attribute

Detailed Description

MAM data attribute.

Author:
Andrej Jamsek

Definition at line 324 of file data.h.


Member Enumeration Documentation

Enumerator:
et_BIN 

Binary data format.

et_ASCII 

ASCII data format.

et_TEXT 

Storage element (slot).

Definition at line 326 of file data.h.

                 {
        et_BIN          = 0x00,
        et_ASCII        = 0x01,
        et_TEXT         = 0x02
    } DataType_t;

Enumerator:
et_DATA 

Regular data cartridge.

et_CLEAN 

Cleaning cartridge.

et_WORM 

Worm data cartridge.

Definition at line 335 of file data.h.

                 {
        et_DATA         = 0x00,
        et_CLEAN        = 0x01,
        et_WORM         = 0x80
    } MediaType_t;


Constructor & Destructor Documentation

data_Attribute::data_Attribute (  ) 

Definition at line 69 of file data_attribute.cpp.

References m_attribute.

                               {
    memset (&m_attribute, 0, sizeof(m_attribute));
}

data_Attribute::data_Attribute ( UInt16_t  a_type  ) 

Definition at line 63 of file data_attribute.cpp.

References Init().

                                              {
    Init(a_type);
}

Here is the call graph for this function:

data_Attribute::~data_Attribute (  )  [virtual]

Definition at line 75 of file data_attribute.cpp.

                                {
    // Empty
}


Member Function Documentation

bool data_Attribute::CheckMamAttributes (  ) 

Definition at line 258 of file data_attribute.cpp.

References att_CAPACITY, att_FREE, att_MEDMANUF, att_MEDPOOL, att_SERNO, att_USRLABEL, dbg_DETAIL, FindAttrID(), log_DBG_m, and log_FUNC_m.

Referenced by Mamdetect().

                                       {
    log_FUNC_m(CheckMamAttributes);

    if (FindAttrID(att_FREE) == false) return false;       // Get MAM free space
    if (FindAttrID(att_CAPACITY) == false) return false;   // Get MAM capacity
    if (FindAttrID(att_SERNO) == false) return false;      // Get serial number
    if (FindAttrID(att_MEDMANUF) == false) return false;   // Get Medium Manufacture
    if (FindAttrID(att_USRLABEL) == false) return false;   // medium record
    if (FindAttrID(att_MEDPOOL) == false) return false;    // volume record(s)
    //  There's no needs to have these MAM attributes, so they're commented out.
    //  if (FindAttrID(att_MEDTYPE) == false) return false;    // Get Medium type
    //  if (FindAttrID(att_MEDDENS) == false) return false;    // Get Medium Density
    //  if (FindAttrID(att_BARCODE) == false) return false;    // Barcode
    log_DBG_m(dbg_DETAIL, "All needed MAM attributes are available");
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void data_Attribute::ClearAttrValue (  ) 

Definition at line 305 of file data_attribute.cpp.

References data_Attribute_t::attrValue, m_attribute, and data_Attribute_t::u.

                                    {
    memset(&m_attribute.u.attrValue,0,sizeof(m_attribute.u.attrValue));
}

bool data_Attribute::FindAttrID ( UInt16_t  a_attrId  ) 

Definition at line 281 of file data_attribute.cpp.

References data_Attribute_t::available, dbg_DETAIL, hton(), log_DBG_m, log_FUNC_m, m_attribute, ntoh(), and reinterpret_cast().

Referenced by CheckMamAttributes().

                                                {
    log_FUNC_m(FindAttrID);
    // TODO: This function doesn't work properly. att_MEDPOOL can't be found in the list
    // but it can be read...
    log_DBG_m(dbg_DETAIL, "Check attribute 0x"
                          << hex << setw(4) << setfill('0')
                          << a_attrId << dec);
    UInt16_t maxIdx = (ntoh(m_attribute.available) + 4) / 2;
    UInt16_t attrId=hton(a_attrId);
    UInt16_t *attrList = reinterpret_cast <UInt16_t *> (&(m_attribute));
    for (UInt16_t idx=3; idx < maxIdx; ++idx) {
        if (attrList[idx] == attrId) {
            log_DBG_m(dbg_DETAIL, "- Attribute 0x"
                                  << hex << setw(4) << setfill('0')
                                  << ntoh(attrList[idx]) << dec
                                  << " found!");
            return true;
        }
    }
    return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const data_Attribute_t& data_Attribute::GetAttributeData (  )  const [inline]

Definition at line 361 of file data.h.

Referenced by cdb_WriteAttribute::GetBufferPointer(), cdb_ReadAttribute::GetBufferPointer(), and Mamdetect().

{ return m_attribute; };

Here is the caller graph for this function:

UInt32_t data_Attribute::GetAttributeListLength (  )  const [inline]

Definition at line 370 of file data.h.

References ntoh().

Referenced by Mamdetect().

{ return ntoh(m_attribute.available); };

Here is the call graph for this function:

Here is the caller graph for this function:

UInt16_t data_Attribute::GetAttributeSize (  )  const

Definition at line 167 of file data_attribute.cpp.

References att_ATTRLIST, att_CAPACITY, att_FREE, att_MEDMANUF, att_MEDPOOL, att_SERNO, att_USRLABEL, m_capSize, m_frsSize, m_manufSize, m_mpSize, m_snSize, m_type, and m_ulSize.

Referenced by GetAttrIDListLength(), Init(), Mamrmedinfo(), Mamrvolinfo(), bea_MamMemory::Read(), SetAttrValue(), and bea_MamMemory::Write().

                                                {
    switch (m_type) {
        case att_SERNO:
            return m_snSize;
        case att_CAPACITY:
            return m_capSize;
        case att_MEDMANUF:
            return m_manufSize;
        case att_FREE:
            return m_frsSize;
        case att_USRLABEL:
            return m_ulSize;
        case att_MEDPOOL:
            return m_mpSize;
    /*  There's no needs to have these MAM attributes, so they're commented out.
        case att_MEDTYPE:
            return m_mtSize;
        case att_MEDDENS:
            return m_dnsSize;
        case att_BARCODE:
            return m_bcSize;
    */
        case att_ATTRLIST:
            return 160;
        default:
            return 0;
    }
}

Here is the caller graph for this function:

UInt32_t data_Attribute::GetAttrIDDataLength (  )  const

Definition at line 205 of file data_attribute.cpp.

References data_Attribute_t::available, GetAttrIDListLength(), and m_attribute.

Referenced by cdb_WriteAttribute::cdb_WriteAttribute().

                                                   {
    UInt32_t datavail = GetAttrIDListLength() - sizeof(m_attribute.available);
    return datavail;
}

Here is the call graph for this function:

Here is the caller graph for this function:

UInt32_t data_Attribute::GetAttrIDListLength (  )  const

Definition at line 198 of file data_attribute.cpp.

References cmn_OFFSETOF, and GetAttributeSize().

Referenced by cdb_ReadAttribute::cdb_ReadAttribute(), cdb_WriteAttribute::cdb_WriteAttribute(), GetAttrIDDataLength(), cdb_WriteAttribute::GetBufferSize(), and cdb_ReadAttribute::GetBufferSize().

                                                   {
    UInt32_t datavail = cmn_OFFSETOF(data_Attribute_t, u) + GetAttributeSize();
    return datavail;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const UInt16_t* data_Attribute::GetAttrList (  )  const [inline]

Definition at line 371 of file data.h.

Referenced by Mamdetect().

{ return (reinterpret_cast <const UInt16_t *> (&(m_attribute))); };

Here is the caller graph for this function:

const char * data_Attribute::GetAttrValue (  ) 

Definition at line 212 of file data_attribute.cpp.

References data_Attribute_t::attrValue, m_attribute, and data_Attribute_t::u.

Referenced by Mamrmedinfo(), Mamrvolinfo(), Mamwmedinfo(), Mamwvolinfo(), and bea_MamMemory::Read().

                                        {
    return (reinterpret_cast<char *>(&(m_attribute.u.attrValue)));
}

Here is the caller graph for this function:

UInt16_t data_Attribute::GetId (  )  [inline]

Definition at line 362 of file data.h.

Referenced by cdb_ReadAttribute::cdb_ReadAttribute().

{ return m_type; };

Here is the caller graph for this function:

UInt64_t data_Attribute::GetMamCapacity (  )  const

Definition at line 149 of file data_attribute.cpp.

References data_Attribute_t::capacity, m_attribute, ntoh(), and data_Attribute_t::u.

Referenced by Mamcapacity().

                                              {
    return ntoh(m_attribute.u.capacity);
}

Here is the call graph for this function:

Here is the caller graph for this function:

UInt64_t data_Attribute::GetMamFreeSpace (  )  const

Definition at line 155 of file data_attribute.cpp.

References data_Attribute_t::freespace, m_attribute, ntoh(), and data_Attribute_t::u.

Referenced by bea_MamMemory::GetAvailable(), and Mamfree().

                                               {
    return ntoh(m_attribute.u.freespace);
}

Here is the call graph for this function:

Here is the caller graph for this function:

string data_Attribute::GetMediumManufact (  )  const

Definition at line 161 of file data_attribute.cpp.

References m_attribute, data_Attribute_t::mediumManufact, and data_Attribute_t::u.

Referenced by bea_MamMemory::GetManufacturer().

                                               {
    return string (reinterpret_cast<const char *>(&(m_attribute.u.mediumManufact)));
}

Here is the caller graph for this function:

string data_Attribute::GetSerialNumber (  )  const

Definition at line 143 of file data_attribute.cpp.

References m_attribute, data_Attribute_t::serialNum, and data_Attribute_t::u.

Referenced by bea_MamMemory::GetSerialNumber(), and Mamserial().

                                             {
    return string (reinterpret_cast<const char *>(&(m_attribute.u.serialNum)));
}

Here is the caller graph for this function:

void data_Attribute::Init ( UInt16_t  a_type  ) 

Definition at line 81 of file data_attribute.cpp.

References att_ATTRLIST, att_CAPACITY, att_FREE, att_MEDMANUF, att_MEDPOOL, att_SERNO, att_USRLABEL, data_Attribute_t::attrId, data_Attribute_t::attrLen, dbg_DETAIL, data_Attribute_t::format, GetAttributeSize(), hton(), log_DBG_m, log_FUNC_m, m_attribute, and m_type.

Referenced by data_Attribute(), bea_MamMemory::GetAvailable(), bea_MamMemory::GetManufacturer(), bea_MamMemory::GetSerialNumber(), and bea_MamMemory::ReadAttributeList().

                                         {
    log_FUNC_m(Init);
    m_type = a_type;
    memset (&m_attribute, 0, sizeof(m_attribute));

    m_attribute.attrId=hton(m_type);

    m_attribute.attrLen=hton(GetAttributeSize());

    switch (m_type) {
        case att_ATTRLIST:{
            m_attribute.format = et_BIN;
            break;
        }
        case att_SERNO: {
            m_attribute.format = et_ASCII;
            break;
        }
        case att_CAPACITY: {
            m_attribute.format = et_BIN;
            break;
        }
        case att_MEDMANUF: {
            m_attribute.format = et_ASCII;
            break;
        }
        case att_FREE: {
            m_attribute.format = et_BIN;
            break;
        }
        case att_USRLABEL: {
            m_attribute.format = et_TEXT;
            break;
        }
        case att_MEDPOOL: {
            m_attribute.format = et_TEXT;
            break;
        }
/*  There's no needs to have these MAM attributes, so they're commented out.
    case att_MEDTYPE: {
        m_attribute.format = et_BIN;
        break;
    }
    case att_MEDDENS: {
        m_attribute.format = et_BIN;
        break;
    }
    case att_BARCODE: {
        m_attribute.format = et_ASCII;
        break;
    }
    */
        default: {
            m_attribute.format = 0x00;
            break;
        }
    } // switch (m_type)
    log_DBG_m(dbg_DETAIL,"DataAttribute Type 0x" << hex << m_type << dec);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool data_Attribute::IsWorm (  )  const

Definition at line 249 of file data_attribute.cpp.

References et_WORM, m_attribute, data_Attribute_t::mediumType, and data_Attribute_t::u.

                                  {
    if ( m_attribute.u.mediumType == data_Attribute::et_WORM) return true;
    else return false;
}

void data_Attribute::SetAttrValue ( const char *  a_attrValue  ) 

Definition at line 224 of file data_attribute.cpp.

References data_Attribute_t::attrValue, GetAttributeSize(), m_attribute, and data_Attribute_t::u.

Referenced by Mamwmedinfo(), Mamwvolinfo(), and bea_MamMemory::Write().

                                                        {
    memset(&m_attribute.u.attrValue, 0, GetAttributeSize());
    memcpy(&(m_attribute.u.attrValue), a_attrValue, GetAttributeSize());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void data_Attribute::SetAvailableData ( scsi_UInt32  a_datasize  ) 

Definition at line 218 of file data_attribute.cpp.

References data_Attribute_t::available, hton(), and m_attribute.

Referenced by cdb_ReadAttribute::cdb_ReadAttribute(), and cdb_WriteAttribute::cdb_WriteAttribute().

                                                            {
    m_attribute.available=hton(a_datasize);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

const UInt16_t data_Attribute::att_ATTRLIST = 0x0000 [static]

Definition at line 344 of file data.h.

Referenced by GetAttributeSize(), Init(), Mamdetect(), and bea_MamMemory::ReadAttributeList().

const UInt16_t data_Attribute::att_CAPACITY = 0x0407 [static]

Definition at line 346 of file data.h.

Referenced by CheckMamAttributes(), GetAttributeSize(), Init(), and Mamcapacity().

const UInt16_t data_Attribute::att_FREE = 0x0004 [static]
const UInt16_t data_Attribute::att_MEDMANUF = 0x0400 [static]

Definition at line 347 of file data.h.

Referenced by CheckMamAttributes(), GetAttributeSize(), bea_MamMemory::GetManufacturer(), and Init().

const UInt16_t data_Attribute::att_MEDPOOL = 0x0808 [static]
const UInt16_t data_Attribute::att_SERNO = 0x0401 [static]
const UInt16_t data_Attribute::att_USRLABEL = 0x0803 [static]

Reimplemented from scsi_Data.

Definition at line 403 of file data.h.

const UInt32_t data_Attribute::m_capSize = 8 [static]

Definition at line 387 of file data.h.

Referenced by GetAttributeSize().

const UInt32_t data_Attribute::m_frsSize = 8 [static]

Definition at line 388 of file data.h.

Referenced by GetAttributeSize().

Definition at line 391 of file data.h.

Referenced by GetAttributeSize().

const UInt32_t data_Attribute::m_mpSize = 160 [static]

Definition at line 390 of file data.h.

Referenced by GetAttributeSize().

const UInt32_t data_Attribute::m_snSize = 8 [static]

Definition at line 386 of file data.h.

Referenced by GetAttributeSize().

Definition at line 404 of file data.h.

Referenced by GetAttributeSize(), and Init().

const UInt32_t data_Attribute::m_ulSize = 160 [static]

Definition at line 389 of file data.h.

Referenced by GetAttributeSize().


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