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

TokenD6.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 // compat header should always be first header if including system headers
00020 #define LIBSMBIOS_SOURCE
00021 #include "smbios/compat.h"
00022 
00023 #include <sstream>
00024 #include <iomanip>
00025 
00026 #include "TokenImpl.h"
00027 
00028 using namespace std;
00029 
00030 namespace smbios
00031 {
00032     CmosTokenD6::CmosTokenD6( const smbios::ISmbiosItem &initItem, std::vector< CmosRWChecksumObserver > &initChecksumList)
00033             : CmosTokenD5(initItem, initChecksumList)
00034     {
00035         size_t size;
00036         const u8 *ptr =  item->getBufferCopy(size) ; // MUST DELETE[]!
00037         size = size < sizeof(structure)? size : sizeof(structure);
00038         memcpy( const_cast<dell_protected_value_2_structure*>(&structure), ptr, size );
00039 
00040         // have to copy into parents "structure"
00041         size = size < sizeof(CmosTokenD5::structure)? size : sizeof(CmosTokenD5::structure);
00042         memcpy(
00043             const_cast<dell_protected_value_1_structure*>(&(CmosTokenD5::structure)),
00044             ptr,
00045             sizeof(CmosTokenD5::structure) );
00046 
00047         delete [] const_cast<u8 *>(ptr); //const_cast to fix msvc++
00048     }
00049 
00050     string CmosTokenD6::getTokenClass() const
00051     {
00052         return "TokenD6";
00053     }
00054 
00055     void CmosTokenD6::addChecksumObserver() const
00056     {
00057         // run superclass to get observer for value check
00058         CmosTokenD5::addChecksumObserver();
00059 
00060 
00061         // add an observer for the checked range
00062         ostringstream ost;
00063         ost << *item;
00064 
00065         CmosRWChecksumObserver chk(
00066             ost.str(),
00067             cmos,
00068             structure.rangeCheckType,
00069             structure.indexPort,
00070             structure.dataPort,
00071             structure.rangeCheckStart,
00072             structure.rangeCheckEnd,
00073             structure.rangeCheckIndex  );
00074 
00075         checksumList.push_back( chk );
00076     }
00077 }

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