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

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 
00055     private:
00056         const std::string filename;
00057         mutable FILE *fd;
00058         bool rw;
00059 
00060         MemoryFile ();
00061         MemoryFile (const MemoryFile & source);
00062         MemoryFile& operator = (const MemoryFile & source);
00063     };
00064 
00065     // for real work
00066     class MemoryOsSpecific : public IMemory
00067     {
00068     public:
00069         // CONSTRUCTORS, DESTRUCTOR, and ASSIGNMENT
00070         explicit MemoryOsSpecific (const std::string file);
00071         virtual ~MemoryOsSpecific ();
00072 
00073         virtual void fillBuffer(u8 *buffer, u64 offset, unsigned int length) const;
00074         virtual u8 getByte(u64 offset) const;
00075         virtual void putByte(u64 offset, u8 value) const;
00076 
00077     private:
00078         void *osData;
00079 
00080         MemoryOsSpecific ();
00081         MemoryOsSpecific (const MemoryOsSpecific & source);
00082         MemoryOsSpecific& operator = (const MemoryOsSpecific & source);
00083     };
00084 }
00085 
00086 
00087 #endif /* SMBIOSIMPL_H */

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