| 1 |
#include "Pluggable.hh" |
| 2 |
|
| 3 |
#include "Connector.hh" |
| 4 |
#include "PlugException.hh" |
| 5 |
|
| 6 |
#include "unreachable.hh" |
| 7 |
|
| 8 |
#include <cassert> |
| 9 |
|
| 10 |
namespace openmsx { |
| 11 |
|
| 12 |
Pluggable::Pluggable() |
| 13 |
{ |
| 14 |
setConnector(nullptr); |
| 15 |
} |
| 16 |
|
| 17 |
zstring_view Pluggable::getName() const |
| 18 |
{ |
| 19 |
return ""; |
| 20 |
} |
| 21 |
|
| 22 |
void Pluggable::plug(Connector& newConnector, EmuTime time) |
| 23 |
{ |
| 24 |
assert(getClass() == newConnector.getClass()); |
| 25 |
|
| 26 |
if (connector) { |
| 27 |
throw PlugException(getName(), " already plugged in ", |
| 28 |
connector->getName(), '.'); |
| 29 |
} |
| 30 |
plugHelper(newConnector, time); |
| 31 |
setConnector(&newConnector); |
| 32 |
} |
| 33 |
|
| 34 |
void Pluggable::unplug(EmuTime time) |
| 35 |
{ |
| 36 |
try { |
| 37 |
unplugHelper(time); |
| 38 |
} catch (MSXException&) { |
| 39 |
UNREACHABLE; |
| 40 |
} |
| 41 |
setConnector(nullptr); |
| 42 |
} |
| 43 |
|
| 44 |
} |