Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

SmbiosTableIterator.cpp

Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  * vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:cindent:textwidth=0:
00003  *
00004  * Copyright (C) 2005 Dell Inc.
00005  *  by Michael Brown <Michael_E_Brown@dell.com>
00006  * Licensed under the Open Software License version 2.1
00007  *
00008  * Alternatively, you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published
00010  * by the Free Software Foundation; either version 2 of the License,
00011  * or (at your option) any later version.
00012 
00013  * This program is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  */
00018 
00019 #define LIBSMBIOS_SOURCE
00020 #include "SmbiosImpl.h"
00021 
00022 // message.h should be included last.
00023 #include "smbios/message.h"
00024 
00025 using namespace smbiosLowlevel;
00026 using namespace std;
00027 
00028 namespace smbios
00029 {
00030     ISmbiosItem & SmbiosTableIteratorBase::dereference () const
00031     {
00032         if (0 == current)
00033         {
00034             throw ParameterExceptionImpl (_("Programmer error: attempt to dereference a Null iterator."));
00035         }
00036 
00037         const SmbiosTable *t = dynamic_cast<const SmbiosTable *>(table);
00038 
00039         if( 0 == t )
00040         {
00041             throw InternalErrorImpl(_("Smbios table not found or not initialized"));
00042         }
00043 
00044         ISmbiosItem *item = t->getCachedItem( current );
00045         if ( 0 != item )
00046             return *(item);
00047 
00048         ISmbiosItem &newitem = t->makeItem( current );
00049 
00050         t->cacheItem( current, newitem );
00051 
00052         return newitem;
00053     }
00054 
00055     void SmbiosTableIteratorBase::incrementIterator ()
00056     {
00057         const SmbiosTable *t = dynamic_cast<const SmbiosTable *>(table);
00058 
00059         while ((0 != t))
00060         {
00061             current = t->nextSmbiosStruct (current);
00062             if ((-1 == matchType) || (0 == current)
00063                     || ( reinterpret_cast<const smbios_structure_header *>(current)->type == matchType))
00064                 break;
00065         }
00066     }
00067 
00068 }

Generated on Wed Apr 11 16:25:10 2007 for SMBIOS Library by doxygen 1.3.5