openMSX
PluggingController.hh
Go to the documentation of this file.
1 #ifndef PLUGGINGCONTROLLER_HH
2 #define PLUGGINGCONTROLLER_HH
3 
4 #include "RecordedCommand.hh"
5 #include "InfoTopic.hh"
6 #include "EmuTime.hh"
7 #include <memory>
8 #include <string_view>
9 #include <vector>
10 
11 namespace openmsx {
12 
13 class MSXMotherBoard;
14 class Connector;
15 class Pluggable;
16 class CliComm;
17 
22 {
23 public:
24  explicit PluggingController(MSXMotherBoard& motherBoard);
26 
29  void registerConnector(Connector& connector);
30  void unregisterConnector(Connector& connector);
31 
35  [[nodiscard]] Connector* findConnector(std::string_view name) const;
36 
39  void registerPluggable(std::unique_ptr<Pluggable> pluggable);
40 
44  [[nodiscard]] Pluggable* findPluggable(std::string_view name) const;
45 
48  [[nodiscard]] CliComm& getCliComm();
49 
52  [[nodiscard]] EmuTime::param getCurrentTime() const;
53 
54 private:
55  [[nodiscard]] Connector& getConnector(std::string_view name) const;
56  [[nodiscard]] Pluggable& getPluggable(std::string_view name) const;
57 
58 private:
59  MSXMotherBoard& motherBoard;
60  std::vector<Connector*> connectors; // no order
61  std::vector<std::unique_ptr<Pluggable>> pluggables;
62 
63  struct PlugCmd final : RecordedCommand {
64  PlugCmd(CommandController& commandController,
65  StateChangeDistributor& stateChangeDistributor,
66  Scheduler& scheduler);
67  void execute(span<const TclObject> tokens, TclObject& result,
68  EmuTime::param time) override;
69  [[nodiscard]] std::string help(span<const TclObject> tokens) const override;
70  void tabCompletion(std::vector<std::string>& tokens) const override;
71  [[nodiscard]] bool needRecord(span<const TclObject> tokens) const override;
72  } plugCmd;
73 
74  struct UnplugCmd final : RecordedCommand {
75  UnplugCmd(CommandController& commandController,
76  StateChangeDistributor& stateChangeDistributor,
77  Scheduler& scheduler);
78  void execute(span<const TclObject> tokens, TclObject& result,
79  EmuTime::param time) override;
80  [[nodiscard]] std::string help(span<const TclObject> tokens) const override;
81  void tabCompletion(std::vector<std::string>& tokens) const override;
82  } unplugCmd;
83 
84  struct PluggableInfo final : InfoTopic {
85  explicit PluggableInfo(InfoCommand& machineInfoCommand);
86  void execute(span<const TclObject> tokens,
87  TclObject& result) const override;
88  [[nodiscard]] std::string help(span<const TclObject> tokens) const override;
89  void tabCompletion(std::vector<std::string>& tokens) const override;
90  } pluggableInfo;
91 
92  struct ConnectorInfo final : InfoTopic {
93  explicit ConnectorInfo(InfoCommand& machineInfoCommand);
94  void execute(span<const TclObject> tokens,
95  TclObject& result) const override;
96  [[nodiscard]] std::string help(span<const TclObject> tokens) const override;
97  void tabCompletion(std::vector<std::string>& tokens) const override;
98  } connectorInfo;
99 
100  struct ConnectionClassInfo final : InfoTopic {
101  explicit ConnectionClassInfo(InfoCommand& machineInfoCommand);
102  void execute(span<const TclObject> tokens,
103  TclObject& result) const override;
104  [[nodiscard]] std::string help(span<const TclObject> tokens) const override;
105  void tabCompletion(std::vector<std::string>& tokens) const override;
106  } connectionClassInfo;
107 };
108 
109 } // namespace openmsx
110 
111 #endif
Represents something you can plug devices into.
Definition: Connector.hh:21
Central administration of Connectors and Pluggables.
void registerPluggable(std::unique_ptr< Pluggable > pluggable)
Add a Pluggable to the registry.
void unregisterConnector(Connector &connector)
Pluggable * findPluggable(std::string_view name) const
Return the Pluggable with given name or nullptr if there is none with this name.
PluggingController(MSXMotherBoard &motherBoard)
void registerConnector(Connector &connector)
Connectors must be (un)registered.
Connector * findConnector(std::string_view name) const
Return the Connector with given name or nullptr if there is none with this name.
CliComm & getCliComm()
Access to the MSX specific CliComm, so that Connectors can get it.
EmuTime::param getCurrentTime() const
Convenience method: get current time.
Commands that directly influence the MSX state should send and events so that they can be recorded by...
Definition: span.hh:126
This file implemented 3 utility functions:
Definition: Autofire.cc:9