2017-11-25 02:36:22 +00:00
|
|
|
//
|
|
|
|
// TypedDynamicMachine.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 24/11/2017.
|
|
|
|
// Copyright © 2017 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
2018-05-11 01:54:10 +00:00
|
|
|
Activity::Source *activity_source() override {
|
|
|
|
return get<Activity::Source>();
|
2018-05-08 01:57:54 +00:00
|
|
|
}
|
|
|
|
|
2017-11-25 02:36:22 +00:00
|
|
|
ConfigurationTarget::Machine *configuration_target() override {
|
|
|
|
return get<ConfigurationTarget::Machine>();
|
|
|
|
}
|
|
|
|
|
|
|
|
CRTMachine::Machine *crt_machine() override {
|
|
|
|
return get<CRTMachine::Machine>();
|
|
|
|
}
|
|
|
|
|
|
|
|
JoystickMachine::Machine *joystick_machine() override {
|
|
|
|
return get<JoystickMachine::Machine>();
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyboardMachine::Machine *keyboard_machine() override {
|
|
|
|
return get<KeyboardMachine::Machine>();
|
|
|
|
}
|
|
|
|
|
|
|
|
Configurable::Device *configurable_device() override {
|
|
|
|
return get<Configurable::Device>();
|
|
|
|
}
|
|
|
|
|
2018-02-13 02:46:21 +00:00
|
|
|
void *raw_pointer() override {
|
|
|
|
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 */
|