2018-01-30 02:49:49 +00:00
|
|
|
//
|
|
|
|
// DynamicMachine.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 29/01/2018.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2018 Thomas Harte. All rights reserved.
|
2018-01-30 02:49:49 +00:00
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2018-01-30 02:49:49 +00:00
|
|
|
|
|
|
|
#include "../Configurable/Configurable.hpp"
|
2018-05-11 01:54:10 +00:00
|
|
|
#include "../Activity/Source.hpp"
|
2019-06-11 22:21:56 +00:00
|
|
|
|
2020-04-02 03:19:34 +00:00
|
|
|
#include "MachineTypes.hpp"
|
2018-01-30 02:49:49 +00:00
|
|
|
|
|
|
|
namespace Machine {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Provides the structure for owning a machine and dynamically casting it as desired without knowledge of
|
|
|
|
the machine's parent class or, therefore, the need to establish a common one.
|
|
|
|
*/
|
|
|
|
struct DynamicMachine {
|
|
|
|
virtual ~DynamicMachine() {}
|
2018-05-08 01:57:54 +00:00
|
|
|
|
2018-05-11 01:54:10 +00:00
|
|
|
virtual Activity::Source *activity_source() = 0;
|
2018-07-11 01:32:28 +00:00
|
|
|
virtual Configurable::Device *configurable_device() = 0;
|
2020-04-02 03:19:34 +00:00
|
|
|
virtual MachineTypes::TimedMachine *timed_machine() = 0;
|
|
|
|
virtual MachineTypes::ScanProducer *scan_producer() = 0;
|
|
|
|
virtual MachineTypes::AudioProducer *audio_producer() = 0;
|
|
|
|
virtual MachineTypes::JoystickMachine *joystick_machine() = 0;
|
|
|
|
virtual MachineTypes::KeyboardMachine *keyboard_machine() = 0;
|
|
|
|
virtual MachineTypes::MouseMachine *mouse_machine() = 0;
|
|
|
|
virtual MachineTypes::MediaTarget *media_target() = 0;
|
2018-02-13 02:46:21 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Provides a raw pointer to the underlying machine if and only if this dynamic machine really is
|
|
|
|
only a single machine.
|
|
|
|
|
|
|
|
Very unsafe. Very temporary.
|
|
|
|
|
|
|
|
TODO: eliminate in favour of introspection for machine-specific inputs. This is here temporarily
|
|
|
|
only to permit continuity of certain features in the Mac port that have not yet made their way
|
|
|
|
to the SDL/console port.
|
|
|
|
*/
|
|
|
|
virtual void *raw_pointer() = 0;
|
2018-01-30 02:49:49 +00:00
|
|
|
};
|
|
|
|
|
2020-04-02 03:19:34 +00:00
|
|
|
/*!
|
|
|
|
Provides a templateable means to access the above.
|
|
|
|
*/
|
|
|
|
template <typename MachineType> MachineType *get(DynamicMachine &);
|
|
|
|
|
|
|
|
#define SpecialisedGet(type, name) \
|
|
|
|
template <> \
|
|
|
|
inline type *get<type>(DynamicMachine &machine) { \
|
|
|
|
return machine.name(); \
|
|
|
|
}
|
|
|
|
|
|
|
|
SpecialisedGet(Activity::Source, activity_source)
|
|
|
|
SpecialisedGet(Configurable::Device, configurable_device)
|
|
|
|
SpecialisedGet(MachineTypes::TimedMachine, timed_machine)
|
|
|
|
SpecialisedGet(MachineTypes::ScanProducer, scan_producer)
|
|
|
|
SpecialisedGet(MachineTypes::AudioProducer, audio_producer)
|
|
|
|
SpecialisedGet(MachineTypes::JoystickMachine, joystick_machine)
|
|
|
|
SpecialisedGet(MachineTypes::KeyboardMachine, keyboard_machine)
|
|
|
|
SpecialisedGet(MachineTypes::MouseMachine, mouse_machine)
|
|
|
|
SpecialisedGet(MachineTypes::MediaTarget, media_target)
|
|
|
|
|
|
|
|
#undef SpecialisedGet
|
|
|
|
|
2018-01-30 02:49:49 +00:00
|
|
|
}
|