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 "noncopyable.hh"
6 #include "serialize_meta.hh"
7 #include "string_ref.hh"
8 #include <memory>
9 
10 namespace openmsx {
11 
12 class Pluggable;
13 class PluggingController;
14 
21 class Connector : private noncopyable
22 {
23 public:
27  const std::string& getName() const { return name; }
28 
32  virtual const std::string getDescription() const = 0;
33 
38  virtual string_ref getClass() const = 0;
39 
45  virtual void plug(Pluggable& device, EmuTime::param time);
46 
52  virtual void unplug(EmuTime::param time);
53 
57  Pluggable& getPlugged() const { return *plugged; }
58 
60  return pluggingController;
61  }
62 
63  template<typename Archive>
64  void serialize(Archive& ar, unsigned version);
65 
66 protected:
73  Connector(PluggingController& pluggingController,
74  string_ref name, std::unique_ptr<Pluggable> dummy);
75 
76  ~Connector();
77 
78 private:
79  PluggingController& pluggingController;
80  const std::string name;
81  const std::unique_ptr<Pluggable> dummy;
82  Pluggable* plugged;
83 };
84 
85 REGISTER_BASE_CLASS(Connector, "Connector");
86 
87 } // namespace openmsx
88 
89 #endif
virtual string_ref getClass() const =0
A Connector belong to a certain class.
Represents something you can plug devices into.
Definition: Connector.hh:21
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:59
void serialize(Archive &ar, unsigned version)
Definition: Connector.cc:37
REGISTER_BASE_CLASS(Connector,"Connector")
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:7
Pluggable & getPlugged() const
Returns the Pluggable currently plugged in.
Definition: Connector.hh:57
Based on boost::noncopyable, see boost documentation: http://www.boost.org/libs/utility.
Definition: noncopyable.hh:12
virtual void unplug(EmuTime::param time)
This unplugs the currently inserted Pluggable from this Connector.
Definition: Connector.cc:30
const std::string & getName() const
Name that identifies this connector.
Definition: Connector.hh:27
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:24
Connector(PluggingController &pluggingController, string_ref name, std::unique_ptr< Pluggable > dummy)
Creates a new Connector.
Definition: Connector.cc:9