SMBIOS Library
IMemory.h
Go to the documentation of this file.
1 // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:
2 /*
3  * Copyright (C) 2005 Dell Inc.
4  * by Michael Brown <Michael_E_Brown@dell.com>
5  * Licensed under the Open Software License version 2.1
6  *
7  * Alternatively, you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published
9  * by the Free Software Foundation; either version 2 of the License,
10  * or (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  * See the GNU General Public License for more details.
16  */
17 
18 
19 #ifndef IMEMORY_H
20 #define IMEMORY_H
21 
22 // compat header should always be first header
23 #include "smbios/compat.h"
24 
25 // types.h should be first user-defined header.
26 #include "smbios/types.h"
27 
28 #include "smbios/IFactory.h"
29 #include "smbios/IException.h"
30 
31 // abi_prefix should be last header included before declarations
33 
34 namespace memory
35 {
36 
38 
40  // Exception Classes
41  DECLARE_EXCEPTION( MemoryException );
42  DECLARE_EXCEPTION_EX( AccessError, memory, MemoryException );
43  DECLARE_EXCEPTION_EX( OutOfBounds, memory, MemoryException );
44 
45  //forward declarations... defined 'for real' below...
46  class IMemory;
47 
62  class MemoryFactory : public virtual factory::IFactory
63  {
64  public:
66 
76  static MemoryFactory *getFactory();
77  virtual ~MemoryFactory() throw ();
78 
80 
86  virtual IMemory *getSingleton() = 0;
87 
89 
98  virtual IMemory *makeNew() = 0;
99 
100  protected:
102  MemoryFactory();
103  };
104 
105 
106  class IMemory
107  {
108  public:
109  // CONSTRUCTORS, DESTRUCTOR, and ASSIGNMENT
110  // Interface class: no default or copy constructor
111  IMemory();
112  virtual ~IMemory ();
113 
114  virtual u8 getByte(u64 offset) const = 0;
115  virtual void putByte(u64 offset, u8 value) const = 0;
116  virtual void fillBuffer(u8 *buffer, u64 offset, unsigned int length) const = 0;
117  virtual int incReopenHint() = 0;
118  virtual int decReopenHint() = 0;
119  private:
120  void operator =(const IMemory &);
121  IMemory( const IMemory & );
122  };
123 
124 }
125 
126 
127 // always should be last thing in header file
129 
130 #endif /* IMEMORY_H */