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

Generated on Tue Feb 26 14:52:57 2008 for SMBIOS Library by  doxygen 1.4.7