2017-11-25 02:36:22 +00:00
|
|
|
//
|
|
|
|
// TypedDynamicMachine.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 24/11/2017.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-11-25 02:36:22 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef TypedDynamicMachine_h
|
|
|
|
#define TypedDynamicMachine_h
|
|
|
|
|
|
|
|
#include "MachineForTarget.hpp"
|
|
|
|
|
|
|
|
namespace Machine {
|
|
|
|
|
|
|
|
template<typename T> class TypedDynamicMachine: public ::Machine::DynamicMachine {
|
|
|
|
public:
|
|
|
|
TypedDynamicMachine(T *machine) : machine_(machine) {}
|
|
|
|
T *get() { return machine_.get(); }
|
|
|
|
|
|
|
|
TypedDynamicMachine() : TypedDynamicMachine(nullptr) {}
|
|
|
|
TypedDynamicMachine(TypedDynamicMachine &&rhs) : machine_(std::move(rhs.machine_)) {}
|
|
|
|
TypedDynamicMachine &operator=(TypedDynamicMachine &&rhs) {
|
|
|
|
machine_ = std::move(rhs.machine_);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
Activity::Source *activity_source() final {
|
2018-05-11 01:54:10 +00:00
|
|
|
return get<Activity::Source>();
|
2018-05-08 01:57:54 +00:00
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
MediaTarget::Machine *media_target() final {
|
2018-07-11 01:32:28 +00:00
|
|
|
return get<MediaTarget::Machine>();
|
2017-11-25 02:36:22 +00:00
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
CRTMachine::Machine *crt_machine() final {
|
2017-11-25 02:36:22 +00:00
|
|
|
return get<CRTMachine::Machine>();
|
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
JoystickMachine::Machine *joystick_machine() final {
|
2017-11-25 02:36:22 +00:00
|
|
|
return get<JoystickMachine::Machine>();
|
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
KeyboardMachine::Machine *keyboard_machine() final {
|
2017-11-25 02:36:22 +00:00
|
|
|
return get<KeyboardMachine::Machine>();
|
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
MouseMachine::Machine *mouse_machine() final {
|
2019-06-11 22:21:56 +00:00
|
|
|
return get<MouseMachine::Machine>();
|
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
Configurable::Device *configurable_device() final {
|
2017-11-25 02:36:22 +00:00
|
|
|
return get<Configurable::Device>();
|
|
|
|
}
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
void *raw_pointer() final {
|
2018-02-13 02:46:21 +00:00
|
|
|
return get();
|
|
|
|
}
|
|
|
|
|
2017-11-25 02:36:22 +00:00
|
|
|
private:
|
|
|
|
template <typename Class> Class *get() {
|
|
|
|
return dynamic_cast<Class *>(machine_.get());
|
|
|
|
}
|
|
|
|
std::unique_ptr<T> machine_;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* TypedDynamicMachine_h */
|