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
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef MultiMachine_hpp
|
|
|
|
#define MultiMachine_hpp
|
|
|
|
|
2018-01-30 02:49:49 +00:00
|
|
|
#include "../../../Machines/DynamicMachine.hpp"
|
|
|
|
|
2018-02-09 21:31:05 +00:00
|
|
|
#include "Implementation/MultiConfigurable.hpp"
|
2018-01-31 03:23:06 +00:00
|
|
|
#include "Implementation/MultiCRTMachine.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>
|
|
|
|
|
|
|
|
namespace Analyser {
|
|
|
|
namespace Dynamic {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
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
|
|
|
*/
|
2018-02-01 12:53:52 +00:00
|
|
|
class MultiMachine: public ::Machine::DynamicMachine, public MultiCRTMachine::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;
|
|
|
|
CRTMachine::Machine *crt_machine() final;
|
|
|
|
JoystickMachine::Machine *joystick_machine() final;
|
|
|
|
MouseMachine::Machine *mouse_machine() final;
|
|
|
|
KeyboardMachine::Machine *keyboard_machine() final;
|
|
|
|
MediaTarget::Machine *media_target() final;
|
|
|
|
void *raw_pointer() final;
|
2018-01-29 03:22:21 +00:00
|
|
|
|
2018-02-19 21:03:17 +00:00
|
|
|
private:
|
2020-01-24 03:57:51 +00:00
|
|
|
void multi_crt_did_run_machines() 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_;
|
2018-01-31 03:23:06 +00:00
|
|
|
MultiCRTMachine crt_machine_;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MultiMachine_hpp */
|