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 
7 using std::string;
8 
9 namespace openmsx {
10 
12 {
13  setConnector(nullptr);
14 }
15 
17 {
18 }
19 
20 const string& Pluggable::getName() const
21 {
22  static const string name("--empty--");
23  return name;
24 }
25 
26 void Pluggable::plug(Connector& newConnector, EmuTime::param time)
27 {
28  assert(getClass() == newConnector.getClass());
29 
30  if (connector) {
31  throw PlugException(getName() + " already plugged in " +
32  connector->getName() + '.');
33  }
34  plugHelper(newConnector, time);
35  setConnector(&newConnector);
36 }
37 
39 {
40  try {
41  unplugHelper(time);
42  } catch (MSXException&) {
44  }
45  setConnector(nullptr);
46 }
47 
49 {
50  return connector;
51 }
52 
54 {
55  connector = conn;
56 }
57 
58 } // namespace openmsx