openMSX
MSXMultiMemDevice.hh
Go to the documentation of this file.
1 #ifndef MSXMULTIMEMDEVICE_HH
2 #define MSXMULTIMEMDEVICE_HH
3 
4 #include "MSXMultiDevice.hh"
5 #include <vector>
6 
7 namespace openmsx {
8 
9 class MSXCPUInterface;
10 
12 {
13 public:
14  MSXMultiMemDevice(const HardwareConfig& hwConf);
15  virtual ~MSXMultiMemDevice();
16 
17  bool canAdd(int base, int size);
18  void add(MSXDevice& device, int base, int size);
19  void remove(MSXDevice& device, int base, int size);
20  bool empty() const;
21  std::vector<MSXDevice*> getDevices() const;
22 
23  // MSXDevice
24  virtual std::string getName() const;
25  virtual void getNameList(TclObject& result) const;
26  virtual byte readMem(word address, EmuTime::param time);
27  virtual byte peekMem(word address, EmuTime::param time) const;
28  virtual void writeMem(word address, byte value, EmuTime::param time);
29  virtual const byte* getReadCacheLine(word start) const;
30  virtual byte* getWriteCacheLine(word start) const;
31 
32 private:
33  struct Range {
34  Range(unsigned base_, unsigned size_, MSXDevice& device_);
35  bool operator==(const Range& other) const;
36 
37  unsigned base;
38  unsigned size;
39  MSXDevice* device;
40  };
41 
42  const Range& searchRange(unsigned address) const;
43  MSXDevice* searchDevice(unsigned address) const;
44 
45  std::vector<Range> ranges;
46 };
47 
48 } // namespace openmsx
49 
50 #endif