00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00044 class MemoryFile : public IMemory
00045 {
00046 public:
00047
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
00066 class MemoryOsSpecific : public IMemory
00067 {
00068 public:
00069
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