SmbiosItem Class Reference

#include <SmbiosImpl.h>

Inheritance diagram for SmbiosItem:

ISmbiosItem SmbiosItemXml List of all members.

Public Types

enum  { FIELD_LEN_BYTE = 1, FIELD_LEN_WORD = 2, FIELD_LEN_DWORD = 4, FIELD_LEN_QWORD = 8 }

Public Member Functions

 SmbiosItem (const SmbiosItem &source)
 SmbiosItem (const smbiosLowlevel::smbios_structure_header *header=0)
virtual ~SmbiosItem ()
virtual std::auto_ptr< const
ISmbiosItem
clone () const
virtual std::auto_ptr< ISmbiosItemclone ()
virtual std::ostream & streamify (std::ostream &cout) const
u8 getType () const
u8 getLength () const
u16 getHandle () const
virtual u8 getU8 (unsigned int offset) const
virtual u8 getU8 (const std::string field) const
virtual u16 getU16 (unsigned int offset) const
virtual u16 getU16 (const std::string field) const
virtual u32 getU32 (unsigned int offset) const
virtual u32 getU32 (const std::string field) const
virtual u64 getU64 (unsigned int offset) const
virtual u64 getU64 (const std::string field) const
virtual u32 getBitfield (unsigned int offset, unsigned int fieldLen, unsigned int lsb, unsigned int msb) const
virtual u32 getBitfield (const std::string field, const std::string bitField) const
virtual const char * getString (unsigned int header_offset) const
virtual const char * getString (const std::string field) const
virtual const u8getBufferCopy (size_t &length) const
virtual const size_t getBufferSize () const
 Returns the buffer size of the item.
virtual void fixup (const SmbiosWorkaroundTable *workaround) const
virtual const char * getStringByStringNumber (u8) const

Protected Attributes

const smbiosLowlevel::smbios_structure_headerheader
size_t header_size

Private Member Functions

SmbiosItemoperator= (const SmbiosItem &source)

Detailed Description

Definition at line 173 of file SmbiosImpl.h.


Member Enumeration Documentation

anonymous enum [inherited]
 

Enumerator:
FIELD_LEN_BYTE 
FIELD_LEN_WORD 
FIELD_LEN_DWORD 
FIELD_LEN_QWORD 

Definition at line 454 of file ISmbios.h.


Constructor & Destructor Documentation

SmbiosItem const SmbiosItem source  ) 
 

Definition at line 45 of file SmbiosItem.cpp.

References SmbiosItem::header, and SmbiosItem::header_size.

Referenced by SmbiosItem::clone().

SmbiosItem const smbiosLowlevel::smbios_structure_header header = 0  )  [explicit]
 

Definition at line 59 of file SmbiosItem.cpp.

References SmbiosItem::header, SmbiosItem::header_size, and smbios_structure_header::length.

~SmbiosItem  )  [virtual]
 

Definition at line 93 of file SmbiosItem.cpp.

References SmbiosItem::header.


Member Function Documentation

std::auto_ptr< ISmbiosItem > clone  )  [virtual]
 

Implements ISmbiosItem.

Definition at line 201 of file SmbiosItem.cpp.

References SmbiosItem::SmbiosItem().

std::auto_ptr< const ISmbiosItem > clone  )  const [virtual]
 

Implements ISmbiosItem.

Definition at line 196 of file SmbiosItem.cpp.

References SmbiosItem::SmbiosItem().

void fixup const SmbiosWorkaroundTable workaround  )  const [virtual]
 

Definition at line 385 of file SmbiosItem.cpp.

References SmbiosWorkaroundTable::fixupItem(), SmbiosItem::header, and SmbiosItem::header_size.

u32 getBitfield const std::string  field,
const std::string  bitField
const [virtual]
 

Returns the bitfield denoted by bitField. Caller must be aware of the size of the bitfield. Bitfield will be returned in the lowest bits of the u32 return value.

Parameters:
field The name of the field within the item.
bitField The name of the bitfield to retrieve.
Returns:
The value of the bitfield in the lowest bits of the u32. Throws smbios::SmbiosParseException if error.

Implements ISmbiosItem.

Reimplemented in SmbiosItemXml.

u32 getBitfield unsigned int  offset,
unsigned int  fieldLen,
unsigned int  lsb,
unsigned int  msb
const [virtual]
 

Returns the bitfield specified by the offset into the item.

Parameters:
offset The offset of the field within the item.
fieldLen The total length of the bitfield.
lsb The least significant bit of the bitfield.
msb The most significant bit of the bitfield. Optional. Default is the same as lsb if not supplied.
Returns:
The bitfield will be contained in the lowest bits of the u32 upon return. Throws smbios::SmbiosDataOutOfBounds on error.
Sample XML:
        <FIELD offset="12h" name="BIOS Characteristics Extension Byte 1" length="BYTE" usage="BITFIELD">
            <MAPPING>
                <BITS lsb="0" name="ACPI supported"/> 
                <BITS lsb="1" name="USB Legacy is supported"/> 
                <BITS lsb="2" name="AGP is supported"/> 
                <BITS lsb="3" name="I20 boot is supported"/> 
                <BITS lsb="4" name="LS-120 boot is supported"/> 
                <BITS lsb="5" name="ATAPI ZIP Drive boot is supported"/> 
                <BITS lsb="6" name="1394 boot is supported"/> 
                <BITS lsb="7" name="Smart Battery is supported"/> 
            </MAPPING>
        </FIELD>

In this example, a call to getBitfield with an lsb of 2 and no msb would return the value of the "AGP is supported" bit as the lowest bit of the u32 return value.

Implements ISmbiosItem.

Definition at line 318 of file SmbiosItem.cpp.

References smbios::checkItemBounds(), SmbiosItem::header, SmbiosItem::header_size, and smbios_structure_header::length.

const u8 * getBufferCopy size_t &  length  )  const [virtual]
 

Implements ISmbiosItem.

Definition at line 371 of file SmbiosItem.cpp.

References SmbiosItem::header, and SmbiosItem::header_size.

const size_t getBufferSize  )  const [virtual]
 

Returns the buffer size of the item.

Implements ISmbiosItem.

Definition at line 380 of file SmbiosItem.cpp.

References SmbiosItem::header_size.

u16 getHandle  )  const [virtual]
 

Returns the Handle field of the SMBIOS Item. This field is standard for all SMBIOS tables and is defined in the SMBIOS standard.

Returns:
The Handle value.

Implements ISmbiosItem.

Definition at line 216 of file SmbiosItem.cpp.

References smbios_structure_header::handle, and SmbiosItem::header.

u8 getLength  )  const [virtual]
 

Returns the Length field of the SMBIOS Item. This field is standard for all SMBIOS tables and is defined in the SMBIOS standard.

Returns:
The Length value.

Implements ISmbiosItem.

Definition at line 211 of file SmbiosItem.cpp.

References SmbiosItem::header, and smbios_structure_header::length.

Referenced by SmbiosItem::getString().

const char * getString const std::string  field  )  const [virtual]
 

XML Enhanced access to string fields. Returns the string for the field field. Field must be of length "BYTE" and of usage "STRING". Type is checked against XML file. Other than that, this method is identical to getString(unsigned int):

Parameters:
field A string representing the FIELD to look up. This is converted to the integer field offset by looking up in the XML file.

Implements ISmbiosItem.

Reimplemented in SmbiosItemXml.

const char * getString unsigned int  header_offset  )  const [virtual]
 

Returns the string at header_offset. Offset is given as the field value for that particular string. The string should almost always be retrieved with the getString(const std::string field) method instead.

Parameters:
header_offset The offset into the list of strings found at the end of the item.
Returns:
The string if it is found. Throws smbios::SmbiosItemDataOutOfBounds or smbios::InternalError on error.

Implements ISmbiosItem.

Definition at line 174 of file SmbiosItem.cpp.

References _, SmbiosItem::getLength(), SmbiosItem::getStringByStringNumber(), and SmbiosItem::header.

const char * getStringByStringNumber u8   )  const [virtual]
 

Not likely to be useful to regular client code. It is public mainly to help in writing Unit Tests. Clients should normally use getString().

Implements ISmbiosItem.

Definition at line 116 of file SmbiosItem.cpp.

References _, smbios::force_u64_to_u32(), SmbiosItem::header, SmbiosItem::header_size, and smbios_structure_header::length.

Referenced by SmbiosItem::getString().

u8 getType  )  const [virtual]
 

Returns the Type field of the SMBIOS Item. This field is standard for all SMBIOS tables and is defined in the SMBIOS standard.

Returns:
The Type value.

Implements ISmbiosItem.

Definition at line 206 of file SmbiosItem.cpp.

References SmbiosItem::header, and smbios_structure_header::type.

Referenced by SmbiosItemXml::streamify().

u16 getU16 const std::string  field  )  const [virtual]
 

Returns a byte field from the Item.

This function takes a string that represents a FIELD element from the smbios XML definition. The implementation will look up the offset in XML and call getU8( int ) with the correct offset.

The implementation will also validate in the XML that the FIELD is actually of length U8, and will throw an exception if the data field is the wrong length

Sample XML:

        <STRUCTURE type="2" description="Base Board Information">
            <FIELD offset="0h" name="Type" length="BYTE" usage="STRUCTURE_TYPE"/>
            <FIELD offset="1h" name="Length" length="BYTE" usage="SIZE"/>
            <FIELD offset="2h" name="Handle" length="WORD" usage="HANDLE"/>
            <FIELD offset="4h" name="Manufacturer" length="BYTE" usage="STRING"/>
            <FIELD offset="5h" name="Product" length="BYTE" usage="STRING"/>
            <FIELD offset="6h" name="Version" length="BYTE" usage="STRING"/>
            <FIELD offset="7h" name="Serial Number" length="BYTE" usage="STRING"/>
        </STRUCTURE>
         
the field argument could specify, for example, "Manufacturer", and the NUMBER in offset 0x04 would be returned. The number in this example represents the string number.

Parameters:
field String corresponding to the FIELD element in the XML
Returns:
The byte in field. Throws smbios::SmbiosItemDataOutOfBounds, smbios::SmbiosParseException, or smbios::NotImplemented on error.

Implements ISmbiosItem.

Reimplemented in SmbiosItemXml.

u16 getU16 unsigned int  offset  )  const [virtual]
 

Set of accessor functions: getU8(), getU16(), getU32(), and getU64() Returns a (byte|word|dword|qword) field from the Item.

The offset specified is an int representing the a valid offset within the table. Method will return a u8/u16/u32/u64 (depending on function called).

These methods all check the offset parameter for out of bounds conditions. They will throw exceptions on attempts to access data outside the length of the present item.

Parameters:
offset The offset to the field within the Item.
Returns:
The (byte|word|dword|qword) at offset. Throws smbios::SmbiosItemDataOutOfBounds or smbios::SmbiosParseException on error.
Warning:
These methods are unchecked access. There is no verification that (for example) when you use getU8() that the location you are trying to access is actually a U8.

Implements ISmbiosItem.

Definition at line 282 of file SmbiosItem.cpp.

References smbios::checkItemBounds(), smbios::getData(), SmbiosItem::header, SmbiosItem::header_size, and smbios_structure_header::length.

u32 getU32 const std::string  field  )  const [virtual]
 

Returns a byte field from the Item.

This function takes a string that represents a FIELD element from the smbios XML definition. The implementation will look up the offset in XML and call getU8( int ) with the correct offset.

The implementation will also validate in the XML that the FIELD is actually of length U8, and will throw an exception if the data field is the wrong length

Sample XML:

        <STRUCTURE type="2" description="Base Board Information">
            <FIELD offset="0h" name="Type" length="BYTE" usage="STRUCTURE_TYPE"/>
            <FIELD offset="1h" name="Length" length="BYTE" usage="SIZE"/>
            <FIELD offset="2h" name="Handle" length="WORD" usage="HANDLE"/>
            <FIELD offset="4h" name="Manufacturer" length="BYTE" usage="STRING"/>
            <FIELD offset="5h" name="Product" length="BYTE" usage="STRING"/>
            <FIELD offset="6h" name="Version" length="BYTE" usage="STRING"/>
            <FIELD offset="7h" name="Serial Number" length="BYTE" usage="STRING"/>
        </STRUCTURE>
         
the field argument could specify, for example, "Manufacturer", and the NUMBER in offset 0x04 would be returned. The number in this example represents the string number.

Parameters:
field String corresponding to the FIELD element in the XML
Returns:
The byte in field. Throws smbios::SmbiosItemDataOutOfBounds, smbios::SmbiosParseException, or smbios::NotImplemented on error.

Implements ISmbiosItem.

Reimplemented in SmbiosItemXml.

u32 getU32 unsigned int  offset  )  const [virtual]
 

Set of accessor functions: getU8(), getU16(), getU32(), and getU64() Returns a (byte|word|dword|qword) field from the Item.

The offset specified is an int representing the a valid offset within the table. Method will return a u8/u16/u32/u64 (depending on function called).

These methods all check the offset parameter for out of bounds conditions. They will throw exceptions on attempts to access data outside the length of the present item.

Parameters:
offset The offset to the field within the Item.
Returns:
The (byte|word|dword|qword) at offset. Throws smbios::SmbiosItemDataOutOfBounds or smbios::SmbiosParseException on error.
Warning:
These methods are unchecked access. There is no verification that (for example) when you use getU8() that the location you are trying to access is actually a U8.

Implements ISmbiosItem.

Definition at line 291 of file SmbiosItem.cpp.

References smbios::checkItemBounds(), smbios::getData(), SmbiosItem::header, SmbiosItem::header_size, and smbios_structure_header::length.

u64 getU64 const std::string  field  )  const [virtual]
 

Returns a byte field from the Item.

This function takes a string that represents a FIELD element from the smbios XML definition. The implementation will look up the offset in XML and call getU8( int ) with the correct offset.

The implementation will also validate in the XML that the FIELD is actually of length U8, and will throw an exception if the data field is the wrong length

Sample XML:

        <STRUCTURE type="2" description="Base Board Information">
            <FIELD offset="0h" name="Type" length="BYTE" usage="STRUCTURE_TYPE"/>
            <FIELD offset="1h" name="Length" length="BYTE" usage="SIZE"/>
            <FIELD offset="2h" name="Handle" length="WORD" usage="HANDLE"/>
            <FIELD offset="4h" name="Manufacturer" length="BYTE" usage="STRING"/>
            <FIELD offset="5h" name="Product" length="BYTE" usage="STRING"/>
            <FIELD offset="6h" name="Version" length="BYTE" usage="STRING"/>
            <FIELD offset="7h" name="Serial Number" length="BYTE" usage="STRING"/>
        </STRUCTURE>
         
the field argument could specify, for example, "Manufacturer", and the NUMBER in offset 0x04 would be returned. The number in this example represents the string number.

Parameters:
field String corresponding to the FIELD element in the XML
Returns:
The byte in field. Throws smbios::SmbiosItemDataOutOfBounds, smbios::SmbiosParseException, or smbios::NotImplemented on error.

Implements ISmbiosItem.

Reimplemented in SmbiosItemXml.

u64 getU64 unsigned int  offset  )  const [virtual]
 

Set of accessor functions: getU8(), getU16(), getU32(), and getU64() Returns a (byte|word|dword|qword) field from the Item.

The offset specified is an int representing the a valid offset within the table. Method will return a u8/u16/u32/u64 (depending on function called).

These methods all check the offset parameter for out of bounds conditions. They will throw exceptions on attempts to access data outside the length of the present item.

Parameters:
offset The offset to the field within the Item.
Returns:
The (byte|word|dword|qword) at offset. Throws smbios::SmbiosItemDataOutOfBounds or smbios::SmbiosParseException on error.
Warning:
These methods are unchecked access. There is no verification that (for example) when you use getU8() that the location you are trying to access is actually a U8.

Implements ISmbiosItem.

Definition at line 299 of file SmbiosItem.cpp.

References smbios::checkItemBounds(), smbios::getData(), SmbiosItem::header, SmbiosItem::header_size, and smbios_structure_header::length.

u8 getU8 const std::string  field  )  const [virtual]
 

Returns a byte field from the Item.

This function takes a string that represents a FIELD element from the smbios XML definition. The implementation will look up the offset in XML and call getU8( int ) with the correct offset.

The implementation will also validate in the XML that the FIELD is actually of length U8, and will throw an exception if the data field is the wrong length

Sample XML:

        <STRUCTURE type="2" description="Base Board Information">
            <FIELD offset="0h" name="Type" length="BYTE" usage="STRUCTURE_TYPE"/>
            <FIELD offset="1h" name="Length" length="BYTE" usage="SIZE"/>
            <FIELD offset="2h" name="Handle" length="WORD" usage="HANDLE"/>
            <FIELD offset="4h" name="Manufacturer" length="BYTE" usage="STRING"/>
            <FIELD offset="5h" name="Product" length="BYTE" usage="STRING"/>
            <FIELD offset="6h" name="Version" length="BYTE" usage="STRING"/>
            <FIELD offset="7h" name="Serial Number" length="BYTE" usage="STRING"/>
        </STRUCTURE>
         
the field argument could specify, for example, "Manufacturer", and the NUMBER in offset 0x04 would be returned. The number in this example represents the string number.

Parameters:
field String corresponding to the FIELD element in the XML
Returns:
The byte in field. Throws smbios::SmbiosItemDataOutOfBounds, smbios::SmbiosParseException, or smbios::NotImplemented on error.

Implements ISmbiosItem.

Reimplemented in SmbiosItemXml.

u8 getU8 unsigned int  offset  )  const [virtual]
 

Set of accessor functions: getU8(), getU16(), getU32(), and getU64() Returns a (byte|word|dword|qword) field from the Item.

The offset specified is an int representing the a valid offset within the table. Method will return a u8/u16/u32/u64 (depending on function called).

These methods all check the offset parameter for out of bounds conditions. They will throw exceptions on attempts to access data outside the length of the present item.

Parameters:
offset The offset to the field within the Item.
Returns:
The (byte|word|dword|qword) at offset. Throws smbios::SmbiosItemDataOutOfBounds or smbios::SmbiosParseException on error.
Warning:
These methods are unchecked access. There is no verification that (for example) when you use getU8() that the location you are trying to access is actually a U8.

Implements ISmbiosItem.

Definition at line 275 of file SmbiosItem.cpp.

References smbios::checkItemBounds(), SmbiosItem::header, SmbiosItem::header_size, and smbios_structure_header::length.

SmbiosItem& operator= const SmbiosItem source  )  [private]
 

virtual std::ostream& streamify std::ostream &  cout  )  const [virtual]
 

Used by 'stdostream &smbios::operator <<( std::ostream &, ISmbiosItem&)' to print out the item info.

Not particularly useful for clients. Use operator<< instead.

Implements ISmbiosItem.

Reimplemented in SmbiosItemXml.

Referenced by SmbiosItemXml::streamify().


Member Data Documentation

const smbiosLowlevel::smbios_structure_header* header [protected]
 

Definition at line 211 of file SmbiosImpl.h.

Referenced by SmbiosItem::fixup(), SmbiosItem::getBitfield(), SmbiosItem::getBufferCopy(), SmbiosItem::getHandle(), SmbiosItem::getLength(), SmbiosItem::getString(), SmbiosItem::getStringByStringNumber(), SmbiosItem::getType(), SmbiosItem::getU16(), SmbiosItem::getU32(), SmbiosItem::getU64(), SmbiosItem::getU8(), SmbiosItem::SmbiosItem(), SmbiosItemXml::streamify(), and SmbiosItem::~SmbiosItem().

size_t header_size [protected]
 

Definition at line 212 of file SmbiosImpl.h.

Referenced by SmbiosItem::fixup(), SmbiosItem::getBitfield(), SmbiosItem::getBufferCopy(), SmbiosItem::getBufferSize(), SmbiosItem::getStringByStringNumber(), SmbiosItem::getU16(), SmbiosItem::getU32(), SmbiosItem::getU64(), SmbiosItem::getU8(), and SmbiosItem::SmbiosItem().


The documentation for this class was generated from the following files:
Generated on Tue Jan 17 02:59:09 2006 for SMBIOS Library by  doxygen 1.4.6