SMBIOS Library
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
ISmbiosItem Class Reference

Interface definition for Smbios Item operations. More...

#include <ISmbios.h>

Inheritance diagram for ISmbiosItem:
Inheritance graph
Collaboration diagram for ISmbiosItem:
Collaboration graph

Public Types

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
< ISmbiosItem
clone ()=0
virtual u8 getType () const =0
virtual u8 getLength () const =0
virtual u16 getHandle () const =0
virtual void getData (unsigned int offset, u8 *out, size_t size) const =0
virtual const u8getBufferCopy (size_t &length) const =0
virtual size_t getBufferSize () const =0
 Returns the buffer size of the item.
virtual const char * getStringByStringNumber (u8) const =0

Protected Member Functions

virtual std::ostream & streamify (std::ostream &cout) const =0

Friends

std::ostream & operator<< (std::ostream &cout, const ISmbiosItem &item)

Detailed Description

Interface definition for Smbios Item operations.

Theory of OperationThe 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 HierarchyThe 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).ImplementationThe 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 OwnershipThe 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 241 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 310 of file ISmbios.h.

Constructor & Destructor Documentation

~ISmbiosItem ( )
virtual

Destructor

Definition at line 35 of file SmbiosItem.cpp.

Definition at line 38 of file SmbiosItem.cpp.

Member Function Documentation

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

Implemented in SmbiosItem.

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

Implemented in SmbiosItem.

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

Implemented in SmbiosItem.

virtual size_t getBufferSize ( ) const
pure virtual

Returns the buffer size of the item.

Implemented in SmbiosItem.

virtual void getData ( unsigned int  offset,
u8 out,
size_t  size 
) 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
offsetThe offset to the field within the Item.
outvoid pointer to where to store output data
sizesize of data to return
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::compare(), smbios::getBits_FromItem(), smbios::getData(), smbios::getU16_FromItem(), smbios::getU32_FromItem(), smbios::getU64_FromItem(), and smbios::getU8_FromItem().

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.

Referenced by testStandalone::testEachItemAccessors(), testStandalone::testNonXml(), and testStandalone::testTable_Subscript().

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.

Referenced by testStandalone::testEachItemAccessors(), testStandalone::testNonXml(), and testStandalone::testTable_Subscript().

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.

Referenced by couldBeBayonet(), getIdByteFromOEMItem(), smbios::getString_FromItem(), testPlatform::testOutOfBounds(), and testPlatform::testVariousAccessors().

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(), testStandalone::testEachItemAccessors(), testStandalone::testItemIdentity(), testStandalone::testNonXml(), and testStandalone::testTable_Subscript().

virtual std::ostream& streamify ( std::ostream &  cout) const
protectedpure virtual

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

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

Implemented in SmbiosItem.

Referenced by smbios::operator<<().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  cout,
const ISmbiosItem item 
)
friend

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