ISmbiosItem Class Reference

Interface definition for Smbios Item operations. More...

#include <ISmbios.h>

Inheritance diagram for ISmbiosItem:

SmbiosItem SmbiosItemXml List of all members.

Public Types

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

Public Member Functions

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

Detailed Description

Interface definition for Smbios Item operations.

Theory of Operation

The ISmbiosItem class models access to individual items in the SMBIOS table. It does this by providing a set of accessor functions that allow structured data to be pulled out of the item.

There are two modes of operation, depending on how the ISmbiosTable is set up. First, normal mode allows clients to access any information in the Item by offset and length. This access mode imposes no checks or typing requirements on the data being accessed aside from bounds checking that no buffer overruns occur. The drawback of this mode is that the client code must always know the exact data length and offset of any data that they want to extract.

The next mode of operation is XML enhanced operation. In this mode, the client can pass in strings representing what data is requested. The item will use an XML file to look up the exact offset of this data using the string passed as a referenced. Then the item returns the data to the client. The advantage of this access mode is that data is strongly typed, and the client is prevented from invalid access modes. For example, they may not access half of a u16 data item using the getU8() function call.

Class Hierarchy

The class heirarchy for ISmbiosItem is simple. The abstract interface class is ISmbiosItem. The full implementation of normal-mode access is in SmbiosItem, and the XML enhanced mode access is implemented in SmbiosItemXml (formerly SmbiosItemAccess).

Implementation

The SmbiosItem is implemented with its own data buffer for item data. This is reasonable as the max size for any single item is 256 bytes of data. Upon construction, the Item copies the relevant item data out of the containing table and from then maintains its own memory buffer.

Lifetime and Ownership

The SmbiosItem is destroyed when the containing table is destroyed. There is no method to allow the table to release an item. The copy constructor is purposefully made 'private' to the Item to disallow third parties from taking bad references to individual items.

Definition at line 275 of file ISmbios.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
FIELD_LEN_BYTE 
FIELD_LEN_WORD 
FIELD_LEN_DWORD 
FIELD_LEN_QWORD 

Definition at line 454 of file ISmbios.h.


Constructor & Destructor Documentation

~ISmbiosItem (  )  [virtual]

Destructor

Definition at line 36 of file SmbiosItem.cpp.

ISmbiosItem (  ) 

Definition at line 39 of file SmbiosItem.cpp.


Member Function Documentation

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

Implemented in SmbiosItem.

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

Implemented in SmbiosItem.

virtual u32 getBitfield ( const std::string  field,
const std::string  bitField 
) const [pure 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.

Implemented in SmbiosItem, and SmbiosItemXml.

virtual u32 getBitfield ( unsigned int  offset,
unsigned int  fieldLen,
unsigned int  lsb,
unsigned int  msb = 0 
) const [pure 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.

Implemented in SmbiosItem.

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

Implemented in SmbiosItem.

virtual const size_t getBufferSize (  )  const [pure virtual]

Returns the buffer size of the item.

Implemented in SmbiosItem.

virtual u16 getHandle (  )  const [pure 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.

Implemented in SmbiosItem.

virtual u8 getLength (  )  const [pure 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.

Implemented in SmbiosItem.

virtual const char* getString ( const std::string  field  )  const [pure 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.

Implemented in SmbiosItem, and SmbiosItemXml.

virtual const char* getString ( unsigned int  header_offset  )  const [pure 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.

Implemented in SmbiosItem.

Referenced by smbios::printStructureField().

virtual const char* getStringByStringNumber ( u8   )  const [pure 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().

Implemented in SmbiosItem.

virtual u8 getType (  )  const [pure 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.

Implemented in SmbiosItem.

Referenced by SmbiosWorkaroundTable::fixupItem(), and testSmbiosXml::testItemIdentity().

virtual u16 getU16 ( const std::string  field  )  const [pure 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.

Implemented in SmbiosItem, and SmbiosItemXml.

virtual u16 getU16 ( unsigned int  offset  )  const [pure 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.

Implemented in SmbiosItem.

Referenced by smbios::compareU16().

virtual u32 getU32 ( const std::string  field  )  const [pure 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.

Implemented in SmbiosItem, and SmbiosItemXml.

virtual u32 getU32 ( unsigned int  offset  )  const [pure 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.

Implemented in SmbiosItem.

Referenced by smbios::compareU32().

virtual u64 getU64 ( const std::string  field  )  const [pure 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.

Implemented in SmbiosItem, and SmbiosItemXml.

virtual u64 getU64 ( unsigned int  offset  )  const [pure 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.

Implemented in SmbiosItem.

Referenced by smbios::compareU64().

virtual u8 getU8 ( const std::string  field  )  const [pure 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.

Implemented in SmbiosItem, and SmbiosItemXml.

virtual u8 getU8 ( unsigned int  offset  )  const [pure 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.

Implemented in SmbiosItem.

Referenced by smbios::compareU8(), smbios::getData(), rbu::getSupportedPacketType(), smbios::isBitSet(), and smbios::printStructureField().

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

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

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

Implemented in SmbiosItem, and SmbiosItemXml.

Referenced by smbios::operator<<().


The documentation for this class was generated from the following files:
Generated on Tue Jul 11 20:46:47 2006 for SMBIOS Library by  doxygen 1.4.7