openMSX
DiskChanger.hh
Go to the documentation of this file.
1 #ifndef DISKCHANGER_HH
2 #define DISKCHANGER_HH
3 
4 #include "DiskContainer.hh"
5 #include "StateChangeListener.hh"
6 #include "serialize_meta.hh"
7 #include "array_ref.hh"
8 #include "noncopyable.hh"
9 #include <string>
10 #include <memory>
11 
12 namespace openmsx {
13 
14 class CommandController;
15 class StateChangeDistributor;
16 class Scheduler;
17 class FilePool;
18 class MSXMotherBoard;
19 class DiskFactory;
20 class DiskManipulator;
21 class Disk;
22 class DiskCommand;
23 class TclObject;
24 class DiskName;
25 
27  private noncopyable
28 {
29 public:
31  const std::string& driveName,
32  bool createCommand = true,
33  bool isDoubleSidedDrive = true);
34  DiskChanger(const std::string& driveName,
35  CommandController& commandController,
36  DiskFactory& diskFactory,
37  DiskManipulator& manipulator,
38  bool createCommand);
39  ~DiskChanger();
40 
41  void createCommand();
42 
43  const std::string& getDriveName() const { return driveName; }
44  const DiskName& getDiskName() const;
45  bool peekDiskChanged() const { return diskChangedFlag; }
46  void forceDiskChange() { diskChangedFlag = true; }
47  Disk& getDisk() { return *disk; }
48 
49  // DiskContainer
51  virtual const std::string& getContainerName() const;
52  virtual bool diskChanged();
53  virtual int insertDisk(string_ref filename);
54 
55  // for NowindCommand
56  void changeDisk(std::unique_ptr<Disk> newDisk);
57 
58  // for DirAsDSK
59  Scheduler* getScheduler() const { return scheduler; }
60  bool isDoubleSidedDrive() const { return doubleSidedDrive; }
61 
62  template<typename Archive>
63  void serialize(Archive& ar, unsigned version);
64 
65 private:
66  void init(const std::string& prefix, bool createCmd);
68  void ejectDisk();
69  void sendChangeDiskEvent(array_ref<std::string> args);
70 
71  // StateChangeListener
72  virtual void signalStateChange(const std::shared_ptr<StateChange>& event);
73  virtual void stopReplay(EmuTime::param time);
74 
75  CommandController& controller;
76  StateChangeDistributor* stateChangeDistributor;
77  Scheduler* scheduler;
78  FilePool* filePool;
79  DiskFactory& diskFactory;
80  DiskManipulator& manipulator;
81 
82  const std::string driveName;
83  std::unique_ptr<Disk> disk;
84 
85  friend class DiskCommand;
86  std::unique_ptr<DiskCommand> diskCommand; // must come after driveName
87  const bool doubleSidedDrive; // for DirAsDSK
88 
89  bool diskChangedFlag;
90 };
92 
93 } // namespace openmsx
94 
95 #endif
virtual const std::string & getContainerName() const
Definition: DiskChanger.cc:124
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
virtual bool diskChanged()
Definition: DiskChanger.cc:109
const std::string & getDriveName() const
Definition: DiskChanger.hh:43
const DiskName & getDiskName() const
Definition: DiskChanger.cc:104
DiskChanger(MSXMotherBoard &board, const std::string &driveName, bool createCommand=true, bool isDoubleSidedDrive=true)
Definition: DiskChanger.cc:47
void serialize(Archive &ar, unsigned version)
Definition: DiskChanger.cc:313
void changeDisk(std::unique_ptr< Disk > newDisk)
Definition: DiskChanger.cc:192
Scheduler * getScheduler() const
Definition: DiskChanger.hh:59
This class implements a subset of the proposal for std::array_ref (proposed for the next c++ standard...
Definition: array_ref.hh:19
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)
virtual int insertDisk(string_ref filename)
Definition: DiskChanger.cc:162
bool isDoubleSidedDrive() const
Definition: DiskChanger.hh:60
Based on boost::noncopyable, see boost documentation: http://www.boost.org/libs/utility.
Definition: noncopyable.hh:12
virtual SectorAccessibleDisk * getSectorAccessibleDisk()
Definition: DiskChanger.cc:116
bool peekDiskChanged() const
Definition: DiskChanger.hh:45