data_Attribute Class Reference
[SCSI Library]

#include <data.h>

Inheritance diagram for data_Attribute:

Inheritance graph
[legend]
Collaboration diagram for data_Attribute:

Collaboration graph
[legend]

List of all members.


Detailed Description

MAM data attribute.

Author:
Andrej Jamsek

Definition at line 310 of file data.h.


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

Member Enumeration Documentation

Enumerator:
et_BIN  Binary data format.
et_ASCII  ASCII data format.
et_TEXT  Storage element (slot).

Definition at line 312 of file data.h.

00312                  {
00314         et_BIN          = 0x00,
00316         et_ASCII        = 0x01,
00318         et_TEXT         = 0x02
00319     } DataType_t;

Enumerator:
et_DATA  Regular data cartridge.
et_CLEAN  Cleaning cartridge.
et_WORM  Worm data cartridge.

Definition at line 321 of file data.h.

00321                  {
00323         et_DATA         = 0x00,
00325         et_CLEAN        = 0x01,
00327         et_WORM         = 0x80
00328     } MediaType_t;


Constructor & Destructor Documentation

data_Attribute::data_Attribute (  ) 

Definition at line 55 of file data_attribute.cpp.

References m_attribute.

00055                                {
00056     memset (&m_attribute, 0, sizeof(m_attribute));
00057 }

data_Attribute::data_Attribute ( UInt16_t  a_type  ) 

Definition at line 49 of file data_attribute.cpp.

References Init().

00049                                               {
00050     Init(a_type);
00051 }

Here is the call graph for this function:

data_Attribute::~data_Attribute (  )  [virtual]

Definition at line 61 of file data_attribute.cpp.

00061                                 {
00062     // Empty
00063 }


Member Function Documentation

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

Definition at line 347 of file data.h.

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

00347 { return m_attribute; };

Here is the caller graph for this function:

UInt16_t data_Attribute::GetId (  )  [inline]

Definition at line 348 of file data.h.

Referenced by cdb_ReadAttribute::cdb_ReadAttribute().

00348 { return m_type; };

Here is the caller graph for this function:

string data_Attribute::GetSerialNumber (  )  const

Definition at line 129 of file data_attribute.cpp.

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

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

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

Here is the caller graph for this function:

UInt64_t data_Attribute::GetMamCapacity (  )  const

Definition at line 135 of file data_attribute.cpp.

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

Referenced by Mamcapacity().

00135                                               {
00136     return ntoh(m_attribute.u.capacity);
00137 }

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

00141                                                {
00142     return ntoh(m_attribute.u.freespace);
00143 }

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

00153                                                 {
00154     switch (m_type) {
00155         case att_SERNO:
00156             return m_snSize;
00157         case att_CAPACITY:
00158             return m_capSize;
00159         case att_MEDMANUF:
00160             return m_manufSize;
00161         case att_FREE:
00162             return m_frsSize;
00163         case att_USRLABEL:
00164             return m_ulSize;
00165         case att_MEDPOOL:
00166             return m_mpSize;
00167     /*  There's no needs to have these MAM attributes, so they're commented out.
00168         case att_MEDTYPE:
00169             return m_mtSize;
00170         case att_MEDDENS:
00171             return m_dnsSize;
00172         case att_BARCODE:
00173             return m_bcSize;
00174     */
00175         case att_ATTRLIST:
00176             return 160;
00177         default:
00178             return 0;
00179     }
00180 }

Here is the caller graph for this function:

const char * data_Attribute::GetAttrValue (  ) 

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

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

Here is the caller graph for this function:

UInt32_t data_Attribute::GetAttrIDDataLength (  )  const

Definition at line 191 of file data_attribute.cpp.

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

Referenced by cdb_WriteAttribute::cdb_WriteAttribute().

00191                                                    {
00192     UInt32_t datavail = GetAttrIDListLength() - sizeof(m_attribute.available);
00193     return datavail;
00194 }

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

00184                                                    {
00185     UInt32_t datavail = cmn_OFFSETOF(data_Attribute_t, u) + GetAttributeSize();
00186     return datavail;
00187 }

Here is the call graph for this function:

Here is the caller graph for this function:

UInt32_t data_Attribute::GetAttributeListLength (  )  const [inline]

Definition at line 356 of file data.h.

References ntoh().

Referenced by Mamdetect().

00356 { return ntoh(m_attribute.available); };

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 357 of file data.h.

Referenced by Mamdetect().

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

Here is the caller graph for this function:

string data_Attribute::GetMediumManufact (  )  const

Definition at line 147 of file data_attribute.cpp.

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

Referenced by bea_MamMemory::GetManufacturer().

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

Here is the caller graph for this function:

bool data_Attribute::IsWorm (  )  const

Definition at line 235 of file data_attribute.cpp.

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

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

void data_Attribute::SetAvailableData ( scsi_UInt32  a_datasize  ) 

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

00204                                                             {
00205     m_attribute.available=hton(a_datasize);
00206 }

Here is the call graph for this function:

Here is the caller graph for this function:

void data_Attribute::SetAttrValue ( const char *  a_attrValue  ) 

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

void data_Attribute::Init ( UInt16_t  a_type  ) 

Definition at line 67 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, et_ASCII, et_BIN, et_TEXT, 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().

00067                                          {
00068     log_FUNC_m(Init);
00069     m_type = a_type;
00070     memset (&m_attribute, 0, sizeof(m_attribute));
00071 
00072     m_attribute.attrId=hton(m_type);
00073 
00074     m_attribute.attrLen=hton(GetAttributeSize());
00075 
00076     switch (m_type) {
00077         case att_ATTRLIST:{
00078             m_attribute.format = et_BIN;
00079             break;
00080         }
00081         case att_SERNO: {
00082             m_attribute.format = et_ASCII;
00083             break;
00084         }
00085         case att_CAPACITY: {
00086             m_attribute.format = et_BIN;
00087             break;
00088         }
00089         case att_MEDMANUF: {
00090             m_attribute.format = et_ASCII;
00091             break;
00092         }
00093         case att_FREE: {
00094             m_attribute.format = et_BIN;
00095             break;
00096         }
00097         case att_USRLABEL: {
00098             m_attribute.format = et_TEXT;
00099             break;
00100         }
00101         case att_MEDPOOL: {
00102             m_attribute.format = et_TEXT;
00103             break;
00104         }
00105 /*  There's no needs to have these MAM attributes, so they're commented out.
00106     case att_MEDTYPE: {
00107         m_attribute.format = et_BIN;
00108         break;
00109     }
00110     case att_MEDDENS: {
00111         m_attribute.format = et_BIN;
00112         break;
00113     }
00114     case att_BARCODE: {
00115         m_attribute.format = et_ASCII;
00116         break;
00117     }
00118     */
00119         default: {
00120             m_attribute.format = 0x00;
00121             break;
00122         }
00123     } // switch (m_type)
00124     log_DBG_m(dbg_DETAIL,"DataAttribute Type 0x" << hex << m_type << dec);
00125 }

Here is the call graph for this function:

Here is the caller graph for this function:

void data_Attribute::ClearAttrValue (  ) 

Definition at line 291 of file data_attribute.cpp.

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

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

bool data_Attribute::FindAttrID ( UInt16_t  a_attrId  ) 

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

00267                                                 {
00268     log_FUNC_m(FindAttrID);
00269     // TODO: This function doesn't work properly. att_MEDPOOL can't be found in the list
00270     // but it can be read...
00271     log_DBG_m(dbg_DETAIL, "Check attribute 0x"
00272                           << hex << setw(4) << setfill('0')
00273                           << a_attrId << dec);
00274     UInt16_t maxIdx = (ntoh(m_attribute.available) + 4) / 2;
00275     UInt16_t attrId=hton(a_attrId);
00276     UInt16_t *attrList = reinterpret_cast <UInt16_t *> (&(m_attribute));
00277     for (UInt16_t idx=3; idx < maxIdx; ++idx) {
00278         if (attrList[idx] == attrId) {
00279             log_DBG_m(dbg_DETAIL, "- Attribute 0x"
00280                                   << hex << setw(4) << setfill('0')
00281                                   << ntoh(attrList[idx]) << dec
00282                                   << " found!");
00283             return true;
00284         }
00285     }
00286     return false;
00287 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool data_Attribute::CheckMamAttributes (  ) 

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

00244                                        {
00245     log_FUNC_m(CheckMamAttributes);
00246 
00247     if (FindAttrID(att_FREE) == false) return false;       // Get MAM free space
00248     if (FindAttrID(att_CAPACITY) == false) return false;   // Get MAM capacity
00249     if (FindAttrID(att_SERNO) == false) return false;      // Get serial number
00250     if (FindAttrID(att_MEDMANUF) == false) return false;   // Get Medium Manufacture
00251     if (FindAttrID(att_USRLABEL) == false) return false;   // medium record
00252     if (FindAttrID(att_MEDPOOL) == false) return false;    // volume record(s)
00253     //  There's no needs to have these MAM attributes, so they're commented out.
00254     //  if (FindAttrID(att_MEDTYPE) == false) return false;    // Get Medium type
00255     //  if (FindAttrID(att_MEDDENS) == false) return false;    // Get Medium Density
00256     //  if (FindAttrID(att_BARCODE) == false) return false;    // Barcode
00257     log_DBG_m(dbg_DETAIL, "All needed MAM attributes are available");
00258     return true;
00259 }

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 330 of file data.h.

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

const UInt16_t data_Attribute::att_SERNO = 0x0401 [static]

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

Definition at line 332 of file data.h.

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

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

Definition at line 333 of file data.h.

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

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

const UInt16_t data_Attribute::att_USRLABEL = 0x0803 [static]

const UInt16_t data_Attribute::att_MEDPOOL = 0x0808 [static]

const UInt32_t data_Attribute::m_snSize = 8 [static]

Definition at line 372 of file data.h.

Referenced by GetAttributeSize().

const UInt32_t data_Attribute::m_capSize = 8 [static]

Definition at line 373 of file data.h.

Referenced by GetAttributeSize().

const UInt32_t data_Attribute::m_frsSize = 8 [static]

Definition at line 374 of file data.h.

Referenced by GetAttributeSize().

const UInt32_t data_Attribute::m_ulSize = 160 [static]

Definition at line 375 of file data.h.

Referenced by GetAttributeSize().

const UInt32_t data_Attribute::m_mpSize = 160 [static]

Definition at line 376 of file data.h.

Referenced by GetAttributeSize().

Definition at line 377 of file data.h.

Referenced by GetAttributeSize().

Reimplemented from scsi_Data.

Definition at line 389 of file data.h.

Definition at line 390 of file data.h.

Referenced by GetAttributeSize(), and Init().


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

Generated on Mon Feb 27 19:06:28 2012 for OPENARCHIVE by  doxygen 1.5.6