Pluggable.cc 784 B

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