openMSX
Pluggable.cc
Go to the documentation of this file.
1#include "Pluggable.hh"
2#include "PlugException.hh"
3#include "Connector.hh"
4#include "unreachable.hh"
5#include <cassert>
6
7namespace openmsx {
8
10{
11 setConnector(nullptr);
12}
13
14std::string_view Pluggable::getName() const
15{
16 return "";
17}
18
19void Pluggable::plug(Connector& newConnector, EmuTime::param time)
20{
21 assert(getClass() == newConnector.getClass());
22
23 if (connector) {
24 throw PlugException(getName(), " already plugged in ",
25 connector->getName(), '.');
26 }
27 plugHelper(newConnector, time);
28 setConnector(&newConnector);
29}
30
31void Pluggable::unplug(EmuTime::param time)
32{
33 try {
34 unplugHelper(time);
35 } catch (MSXException&) {
37 }
38 setConnector(nullptr);
39}
40
41} // namespace openmsx
Represents something you can plug devices into.
Definition Connector.hh:21
const std::string & getName() const
Name that identifies this connector.
Definition Connector.hh:29
virtual std::string_view getClass() const =0
A Connector belong to a certain class.
Thrown when a plug action fails.
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
void unplug(EmuTime::param time)
This method is called when this pluggable is removed from a connector.
Definition Pluggable.cc:31
void setConnector(Connector *conn)
Definition Pluggable.hh:58
virtual std::string_view getName() const
Name used to identify this pluggable.
Definition Pluggable.cc:14
virtual std::string_view getClass() const =0
A pluggable belongs to a certain class.
virtual void plugHelper(Connector &newConnector, EmuTime::param time)=0
This file implemented 3 utility functions:
Definition Autofire.cc:11
#define UNREACHABLE