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 IMEMORY_H 00020 #define IMEMORY_H 00021 00022 // compat header should always be first header 00023 #include "smbios/compat.h" 00024 00025 // types.h should be first user-defined header. 00026 #include "smbios/types.h" 00027 00028 #include "smbios/IFactory.h" 00029 #include "smbios/IException.h" 00030 00031 // abi_prefix should be last header included before declarations 00032 #include "smbios/config/abi_prefix.hpp" 00033 00034 namespace memory 00035 { 00036 00038 00040 // Exception Classes 00041 DECLARE_EXCEPTION( MemoryException ); 00042 DECLARE_EXCEPTION_EX( AccessError, memory, MemoryException ); 00043 DECLARE_EXCEPTION_EX( OutOfBounds, memory, MemoryException ); 00044 00045 //forward declarations... defined 'for real' below... 00046 class IMemory; 00047 00062 class MemoryFactory : public virtual factory::IFactory 00063 { 00064 public: 00066 00076 static MemoryFactory *getFactory(); 00077 virtual ~MemoryFactory() throw (); 00078 00080 00086 virtual IMemory *getSingleton() = 0; 00087 00089 00098 virtual IMemory *makeNew() = 0; 00099 00100 protected: 00102 MemoryFactory(); 00103 }; 00104 00105 00106 class IMemory 00107 { 00108 public: 00109 // CONSTRUCTORS, DESTRUCTOR, and ASSIGNMENT 00110 // Interface class: no default or copy constructor 00111 IMemory(); 00112 virtual ~IMemory (); 00113 00114 virtual u8 getByte(u64 offset) const = 0; 00115 virtual void putByte(u64 offset, u8 value) const = 0; 00116 virtual void fillBuffer(u8 *buffer, u64 offset, unsigned int length) const = 0; 00117 virtual int incReopenHint() = 0; 00118 virtual int decReopenHint() = 0; 00119 private: 00120 void operator =(const IMemory &); 00121 IMemory( const IMemory & ); 00122 }; 00123 00124 } 00125 00126 00127 // always should be last thing in header file 00128 #include "smbios/config/abi_suffix.hpp" 00129 00130 #endif /* IMEMORY_H */