• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

MemoryImpl.h

Go to the documentation of this file.
00001 // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:
00002 /*
00003  * Copyright (C) 2005 Dell Inc.
00004  *  by Michael Brown <Michael_E_Brown@dell.com>
00005  * Licensed under the Open Software License version 2.1
00006  *
00007  * Alternatively, you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published
00009  * by the Free Software Foundation; either version 2 of the License,
00010  * or (at your option) any later version.
00011 
00012  * This program is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00015  * See the GNU General Public License for more details.
00016  */
00017 
00018 
00019 #ifndef SMBIOSIMPL_H
00020 #define SMBIOSIMPL_H
00021 
00022 #include "smbios/IMemory.h"
00023 #include "FactoryImpl2.h"
00024 #include "ExceptionImpl.h"
00025 
00026 namespace memory
00027 {
00028     DEFINE_EXCEPTION_EX( AccessErrorImpl, memory, AccessError );
00029     DEFINE_EXCEPTION_EX( OutOfBoundsImpl, memory, OutOfBounds );
00030 
00031     class MemoryFactoryImpl : public factory::TFactory<MemoryFactory>
00032     {
00033     public:
00034         MemoryFactoryImpl();
00035         virtual ~MemoryFactoryImpl() throw ();
00036         virtual IMemory *getSingleton();
00037         virtual IMemory *makeNew();
00038     protected:
00039         static IMemory *_mem_instance;
00040     };
00041 
00042 
00043     // for unit tests
00044     class MemoryFile : public IMemory
00045     {
00046     public:
00047         // CONSTRUCTORS, DESTRUCTOR, and ASSIGNMENT
00048         explicit MemoryFile (const std::string file);
00049         virtual ~MemoryFile ();
00050 
00051         virtual void fillBuffer(u8 *buffer, u64 offset, unsigned int length) const;
00052         virtual u8 getByte(u64 offset) const;
00053         virtual void putByte(u64 offset, u8 value) const;
00054         virtual int incReopenHint() {return ++reopenHint;};
00055         virtual int decReopenHint() {return --reopenHint;};
00056 
00057     private:
00058         const std::string filename;
00059         mutable FILE *fd;
00060         bool rw;
00061         int reopenHint;
00062 
00063         MemoryFile ();
00064         MemoryFile (const MemoryFile & source);
00065         MemoryFile& operator = (const MemoryFile & source);
00066     };
00067 
00068     // for real work
00069     class MemoryOsSpecific : public IMemory
00070     {
00071     public:
00072         // CONSTRUCTORS, DESTRUCTOR, and ASSIGNMENT
00073         explicit MemoryOsSpecific (const std::string file);
00074         virtual ~MemoryOsSpecific ();
00075 
00076         virtual void fillBuffer(u8 *buffer, u64 offset, unsigned int length) const;
00077         virtual u8 getByte(u64 offset) const;
00078         virtual void putByte(u64 offset, u8 value) const;
00079         virtual int incReopenHint();
00080         virtual int decReopenHint();
00081 
00082     private:
00083         void *osData;
00084 
00085         MemoryOsSpecific ();
00086         MemoryOsSpecific (const MemoryOsSpecific & source);
00087         MemoryOsSpecific& operator = (const MemoryOsSpecific & source);
00088     };
00089 }
00090 
00091 
00092 #endif /* SMBIOSIMPL_H */

Generated on Sun Aug 22 2010 14:38:30 for SMBIOS Library by  doxygen 1.7.1