2018-01-29 03:22:21 +00:00
|
|
|
//
|
|
|
|
// MultiMachine.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 28/01/2018.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2018 Thomas Harte. All rights reserved.
|
2018-01-29 03:22:21 +00:00
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2018-01-29 03:22:21 +00:00
|
|
|
|
2018-01-30 02:49:49 +00:00
|
|
|
#include "../../../Machines/DynamicMachine.hpp"
|
|
|
|
|
2020-04-02 03:19:34 +00:00
|
|
|
#include "Implementation/MultiProducer.hpp"
|
2018-02-09 21:31:05 +00:00
|
|
|
#include "Implementation/MultiConfigurable.hpp"
|
2020-04-02 03:19:34 +00:00
|
|
|
#include "Implementation/MultiProducer.hpp"
|
2018-02-09 21:31:05 +00:00
|
|
|
#include "Implementation/MultiJoystickMachine.hpp"
|
|
|
|
#include "Implementation/MultiKeyboardMachine.hpp"
|
2018-07-11 01:32:28 +00:00
|
|
|
#include "Implementation/MultiMediaTarget.hpp"
|
2018-01-29 03:22:21 +00:00
|
|
|
|
|
|
|
#include <memory>
|
2018-02-11 00:38:26 +00:00
|
|
|
#include <mutex>
|
2018-01-29 03:22:21 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Analyser::Dynamic {
|
2018-01-29 03:22:21 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Provides the same interface as to a single machine, while multiplexing all
|
|
|
|
underlying calls to an array of real dynamic machines.
|
|
|
|
|
2018-02-19 21:03:17 +00:00
|
|
|
Calls to crt_machine->get_crt will return that for the frontmost machine;
|
|
|
|
anything installed as the speaker's delegate will similarly receive
|
|
|
|
feedback only from that machine.
|
2018-01-29 03:22:21 +00:00
|
|
|
|
|
|
|
Following each crt_machine->run_for, reorders the supplied machines by
|
|
|
|
confidence.
|
|
|
|
|
|
|
|
If confidence for any machine becomes disproportionately low compared to
|
2018-02-19 21:03:17 +00:00
|
|
|
the others in the set, that machine stops running.
|
2018-01-29 03:22:21 +00:00
|
|
|
*/
|
2020-04-02 03:19:34 +00:00
|
|
|
class MultiMachine: public ::Machine::DynamicMachine, public MultiTimedMachine::Delegate {
|
2018-01-29 03:22:21 +00:00
|
|
|
public:
|
2018-03-07 00:08:02 +00:00
|
|
|
/*!
|
|
|
|
Allows a potential MultiMachine creator to enquire as to whether there's any benefit in
|
|
|
|
requesting this class as a proxy.
|
|
|
|
|
|
|
|
@returns @c true if the multimachine would discard all but the first machine in this list;
|
|
|
|
@c false otherwise.
|
|
|
|
*/
|
|
|
|
static bool would_collapse(const std::vector<std::unique_ptr<DynamicMachine>> &machines);
|
2018-01-29 03:22:21 +00:00
|
|
|
MultiMachine(std::vector<std::unique_ptr<DynamicMachine>> &&machines);
|
|
|
|
|
2020-01-24 03:57:51 +00:00
|
|
|
Activity::Source *activity_source() final;
|
|
|
|
Configurable::Device *configurable_device() final;
|
2020-04-02 03:19:34 +00:00
|
|
|
MachineTypes::TimedMachine *timed_machine() final;
|
|
|
|
MachineTypes::ScanProducer *scan_producer() final;
|
|
|
|
MachineTypes::AudioProducer *audio_producer() final;
|
|
|
|
MachineTypes::JoystickMachine *joystick_machine() final;
|
|
|
|
MachineTypes::KeyboardMachine *keyboard_machine() final;
|
|
|
|
MachineTypes::MouseMachine *mouse_machine() final;
|
|
|
|
MachineTypes::MediaTarget *media_target() final;
|
2020-01-24 03:57:51 +00:00
|
|
|
void *raw_pointer() final;
|
2018-01-29 03:22:21 +00:00
|
|
|
|
2018-02-19 21:03:17 +00:00
|
|
|
private:
|
2020-04-02 03:19:34 +00:00
|
|
|
void did_run_machines(MultiTimedMachine *) final;
|
2018-02-01 12:53:52 +00:00
|
|
|
|
2018-01-29 03:22:21 +00:00
|
|
|
std::vector<std::unique_ptr<DynamicMachine>> machines_;
|
2019-02-28 03:39:33 +00:00
|
|
|
std::recursive_mutex machines_mutex_;
|
2018-01-30 02:49:49 +00:00
|
|
|
|
2018-02-09 21:31:05 +00:00
|
|
|
MultiConfigurable configurable_;
|
2020-04-02 03:19:34 +00:00
|
|
|
MultiTimedMachine timed_machine_;
|
|
|
|
MultiScanProducer scan_producer_;
|
|
|
|
MultiAudioProducer audio_producer_;
|
2018-02-09 21:31:05 +00:00
|
|
|
MultiJoystickMachine joystick_machine_;
|
|
|
|
MultiKeyboardMachine keyboard_machine_;
|
2018-07-11 01:32:28 +00:00
|
|
|
MultiMediaTarget media_target_;
|
2018-02-12 01:24:08 +00:00
|
|
|
|
|
|
|
void pick_first();
|
|
|
|
bool has_picked_ = false;
|
2018-01-29 03:22:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|