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
11namespace openmsx {
12
13class MSXMotherBoard;
14class Connector;
15class Pluggable;
16class CliComm;
17
22{
23public:
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
46 [[nodiscard]] const auto& getConnectors() const { return connectors; }
47 [[nodiscard]] const auto& getPluggables() const { return pluggables; }
48
51 [[nodiscard]] CliComm& getCliComm();
52
55 [[nodiscard]] EmuTime::param getCurrentTime() const;
56
57private:
58 [[nodiscard]] Connector& getConnector(std::string_view name) const;
59 [[nodiscard]] Pluggable& getPluggable(std::string_view name) const;
60
61private:
62 MSXMotherBoard& motherBoard;
63 std::vector<Connector*> connectors; // no order
64 std::vector<std::unique_ptr<Pluggable>> pluggables;
65
66 struct PlugCmd final : RecordedCommand {
67 PlugCmd(CommandController& commandController,
68 StateChangeDistributor& stateChangeDistributor,
69 Scheduler& scheduler);
70 void execute(std::span<const TclObject> tokens, TclObject& result,
71 EmuTime::param time) override;
72 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
73 void tabCompletion(std::vector<std::string>& tokens) const override;
74 [[nodiscard]] bool needRecord(std::span<const TclObject> tokens) const override;
75 } plugCmd;
76
77 struct UnplugCmd final : RecordedCommand {
78 UnplugCmd(CommandController& commandController,
79 StateChangeDistributor& stateChangeDistributor,
80 Scheduler& scheduler);
81 void execute(std::span<const TclObject> tokens, TclObject& result,
82 EmuTime::param time) override;
83 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
84 void tabCompletion(std::vector<std::string>& tokens) const override;
85 } unplugCmd;
86
87 struct PluggableInfo final : InfoTopic {
88 explicit PluggableInfo(InfoCommand& machineInfoCommand);
89 void execute(std::span<const TclObject> tokens,
90 TclObject& result) const override;
91 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
92 void tabCompletion(std::vector<std::string>& tokens) const override;
93 } pluggableInfo;
94
95 struct ConnectorInfo final : InfoTopic {
96 explicit ConnectorInfo(InfoCommand& machineInfoCommand);
97 void execute(std::span<const TclObject> tokens,
98 TclObject& result) const override;
99 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
100 void tabCompletion(std::vector<std::string>& tokens) const override;
101 } connectorInfo;
102
103 struct ConnectionClassInfo final : InfoTopic {
104 explicit ConnectionClassInfo(InfoCommand& machineInfoCommand);
105 void execute(std::span<const TclObject> tokens,
106 TclObject& result) const override;
107 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
108 void tabCompletion(std::vector<std::string>& tokens) const override;
109 } connectionClassInfo;
110};
111
112} // namespace openmsx
113
114#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.
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.
const auto & getConnectors() const
const auto & getPluggables() const
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...
This file implemented 3 utility functions:
Definition Autofire.cc:11