openMSX
CartridgeSlotManager.hh
Go to the documentation of this file.
1 #ifndef CARTRIDGESLOTMANAGER_HH
2 #define CARTRIDGESLOTMANAGER_HH
3 
4 #include "noncopyable.hh"
5 #include "string_ref.hh"
6 #include <memory>
7 
8 namespace openmsx {
9 
10 class MSXMotherBoard;
11 class CartCmd;
12 class ExtCmd;
13 class HardwareConfig;
14 class CartridgeSlotInfo;
15 
17 {
18 public:
19  explicit CartridgeSlotManager(MSXMotherBoard& motherBoard);
21 
22  static int getSlotNum(string_ref slot);
23 
24  void createExternalSlot(int ps);
25  void createExternalSlot(int ps, int ss);
26  void removeExternalSlot(int ps);
27  void removeExternalSlot(int ps, int ss);
28  void testRemoveExternalSlot(int ps, const HardwareConfig& allowed) const;
29  void testRemoveExternalSlot(int ps, int ss, const HardwareConfig& allowed) const;
30 
31  // Query/allocate/free external slots
32  void getSpecificSlot(unsigned slot, int& ps, int& ss) const;
33  void getAnyFreeSlot(int& ps, int& ss) const;
34  void allocateSlot(int ps, int ss, const HardwareConfig& hwConfig);
35  void freeSlot(int ps, int ss, const HardwareConfig& hwConfig);
36 
37  // Allocate/free external primary slots
38  void allocatePrimarySlot(int& ps, const HardwareConfig& hwConfig);
39  void freePrimarySlot(int ps, const HardwareConfig& hwConfig);
40 
41  bool isExternalSlot(int ps, int ss, bool convert) const;
42 
43 private:
44  int getSlot(int ps, int ss) const;
45 
46  struct Slot {
47  Slot();
48  ~Slot();
49  bool exists() const;
50  bool used(const HardwareConfig* allowed = nullptr) const;
51 
52  std::unique_ptr<CartCmd> cartCommand;
53  std::unique_ptr<ExtCmd> extCommand;
54  const HardwareConfig* config;
55  unsigned useCount;
56  int ps;
57  int ss;
58  };
59  static const unsigned MAX_SLOTS = 16 + 4;
60  Slot slots[MAX_SLOTS];
61  MSXMotherBoard& motherBoard;
62  const std::unique_ptr<CartCmd> cartCmd;
63  const std::unique_ptr<CartridgeSlotInfo> extSlotInfo;
64  friend class CartCmd;
65  friend class CartridgeSlotInfo;
66 };
67 
68 } // namespace openmsx
69 
70 #endif
void getSpecificSlot(unsigned slot, int &ps, int &ss) const
void freeSlot(int ps, int ss, const HardwareConfig &hwConfig)
CartridgeSlotManager(MSXMotherBoard &motherBoard)
void getAnyFreeSlot(int &ps, int &ss) const
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
void freePrimarySlot(int ps, const HardwareConfig &hwConfig)
void convert(const th_ycbcr_buffer &input, RawFrame &output)
Definition: yuv2rgb.cc:341
bool isExternalSlot(int ps, int ss, bool convert) const
void allocateSlot(int ps, int ss, const HardwareConfig &hwConfig)
void allocatePrimarySlot(int &ps, const HardwareConfig &hwConfig)
bool exists(string_ref filename)
Does this file (directory) exists?
static int getSlotNum(string_ref slot)
void testRemoveExternalSlot(int ps, const HardwareConfig &allowed) const
Based on boost::noncopyable, see boost documentation: http://www.boost.org/libs/utility.
Definition: noncopyable.hh:12