openMSX
Connector.hh
Go to the documentation of this file.
1 #ifndef CONNECTOR_HH
2 #define CONNECTOR_HH
3 
4 #include "EmuTime.hh"
5 #include "serialize_meta.hh"
6 #include "string_ref.hh"
7 #include <memory>
8 
9 namespace openmsx {
10 
11 class Pluggable;
12 class PluggingController;
13 
20 class Connector
21 {
22 public:
23  Connector(const Connector&) = delete;
24  Connector& operator=(const Connector&) = delete;
25 
29  const std::string& getName() const { return name; }
30 
34  virtual const std::string getDescription() const = 0;
35 
40  virtual string_ref getClass() const = 0;
41 
47  virtual void plug(Pluggable& device, EmuTime::param time);
48 
54  virtual void unplug(EmuTime::param time);
55 
59  Pluggable& getPlugged() const { return *plugged; }
60 
62  return pluggingController;
63  }
64 
65  template<typename Archive>
66  void serialize(Archive& ar, unsigned version);
67 
68 protected:
75  Connector(PluggingController& pluggingController,
76  string_ref name, std::unique_ptr<Pluggable> dummy);
77 
78  ~Connector();
79 
80 private:
81  PluggingController& pluggingController;
82  const std::string name;
83  const std::unique_ptr<Pluggable> dummy;
84  Pluggable* plugged;
85 };
86 
87 REGISTER_BASE_CLASS(Connector, "Connector");
88 
89 } // namespace openmsx
90 
91 #endif
virtual string_ref getClass() const =0
A Connector belong to a certain class.
Represents something you can plug devices into.
Definition: Connector.hh:20
Connector(const Connector &)=delete
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
Central administration of Connectors and Pluggables.
PluggingController & getPluggingController() const
Definition: Connector.hh:61
void serialize(Archive &ar, unsigned version)
Definition: Connector.cc:38
REGISTER_BASE_CLASS(Connector,"Connector")
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
Pluggable & getPlugged() const
Returns the Pluggable currently plugged in.
Definition: Connector.hh:59
Connector & operator=(const Connector &)=delete
virtual void unplug(EmuTime::param time)
This unplugs the currently inserted Pluggable from this Connector.
Definition: Connector.cc:31
const std::string & getName() const
Name that identifies this connector.
Definition: Connector.hh:29
virtual const std::string getDescription() const =0
Get a description for this connector.
virtual void plug(Pluggable &device, EmuTime::param time)
This plugs a Pluggable in this Connector.
Definition: Connector.cc:25