openMSX
Pluggable.hh
Go to the documentation of this file.
1#ifndef PLUGGABLE_HH
2#define PLUGGABLE_HH
3
4#include "EmuTime.hh"
5#include <string_view>
6
7namespace openmsx {
8
9class Connector;
10
12{
13public:
14 virtual ~Pluggable() = default;
15
18 [[nodiscard]] virtual std::string_view getName() const;
19
23 [[nodiscard]] virtual std::string_view getClass() const = 0;
24
27 [[nodiscard]] virtual std::string_view getDescription() const = 0;
28
33 void plug(Connector& connector, EmuTime::param time);
34
38 void unplug(EmuTime::param time);
39
43 [[nodiscard]] Connector* getConnector() const { return connector; }
44
49 [[nodiscard]] bool isPluggedIn() const { return getConnector() != nullptr; }
50
51protected:
52 Pluggable();
53 virtual void plugHelper(Connector& newConnector, EmuTime::param time) = 0;
54 /* implementations of unplugHelper() may not throw exceptions. */
55 virtual void unplugHelper(EmuTime::param time) = 0;
56
57 friend class Connector; // for de-serialization
58 void setConnector(Connector* conn) { connector = conn; }
59
60private:
61 Connector* connector;
62};
63
64} // namespace openmsx
65
66#endif
Represents something you can plug devices into.
Definition Connector.hh:21
virtual void unplugHelper(EmuTime::param time)=0
void plug(Connector &connector, EmuTime::param time)
This method is called when this pluggable is inserted in a connector.
Definition Pluggable.cc:19
bool isPluggedIn() const
Returns true if this pluggable is currently plugged into a connector.
Definition Pluggable.hh:49
void unplug(EmuTime::param time)
This method is called when this pluggable is removed from a connector.
Definition Pluggable.cc:31
virtual ~Pluggable()=default
void setConnector(Connector *conn)
Definition Pluggable.hh:58
virtual std::string_view getName() const
Name used to identify this pluggable.
Definition Pluggable.cc:14
Connector * getConnector() const
Get the connector this Pluggable is plugged into.
Definition Pluggable.hh:43
virtual std::string_view getClass() const =0
A pluggable belongs to a certain class.
virtual void plugHelper(Connector &newConnector, EmuTime::param time)=0
virtual std::string_view getDescription() const =0
Description for this pluggable.
This file implemented 3 utility functions:
Definition Autofire.cc:11