From ca48497e8787e8b48434b114b158942b57726093 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 29 Jan 2018 21:49:49 -0500 Subject: [PATCH] Pulls `DynamicMachine` out of `MachineForTarget` and adds `MultiConfigurationTarget` as a first multiplexer. --- .../MultiConfigurationTarget.cpp | 28 ++++++++++++++ .../MultiConfigurationTarget.hpp | 35 ++++++++++++++++++ .../Dynamic/MultiMachine/MultiMachine.cpp | 5 ++- .../Dynamic/MultiMachine/MultiMachine.hpp | 6 ++- Machines/DynamicMachine.hpp | 37 +++++++++++++++++++ Machines/Utility/MachineForTarget.hpp | 21 +---------- .../Clock Signal.xcodeproj/project.pbxproj | 20 +++++++++- 7 files changed, 128 insertions(+), 24 deletions(-) create mode 100644 Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurationTarget.cpp create mode 100644 Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurationTarget.hpp create mode 100644 Machines/DynamicMachine.hpp diff --git a/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurationTarget.cpp b/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurationTarget.cpp new file mode 100644 index 000000000..da13ca227 --- /dev/null +++ b/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurationTarget.cpp @@ -0,0 +1,28 @@ +// +// MultiConfigurationTarget.cpp +// Clock Signal +// +// Created by Thomas Harte on 29/01/2018. +// Copyright © 2018 Thomas Harte. All rights reserved. +// + +#include "MultiConfigurationTarget.hpp" + +using namespace Analyser::Dynamic; + +MultiConfigurationTarget::MultiConfigurationTarget(const std::vector> &machines) : + machines_(machines) {} + +void MultiConfigurationTarget::configure_as_target(const Analyser::Static::Target &target) { +} + +bool MultiConfigurationTarget::insert_media(const Analyser::Static::Media &media) { + bool inserted = false; + for(const auto &machine : machines_) { + ConfigurationTarget::Machine *configuration_target = machine->configuration_target(); + if(configuration_target) { + inserted |= configuration_target->insert_media(media); + } + } + return inserted; +} diff --git a/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurationTarget.hpp b/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurationTarget.hpp new file mode 100644 index 000000000..f8790ce9d --- /dev/null +++ b/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurationTarget.hpp @@ -0,0 +1,35 @@ +// +// MultiConfigurationTarget.hpp +// Clock Signal +// +// Created by Thomas Harte on 29/01/2018. +// Copyright © 2018 Thomas Harte. All rights reserved. +// + +#ifndef MultiConfigurationTarget_hpp +#define MultiConfigurationTarget_hpp + +#include "../../../../Machines/ConfigurationTarget.hpp" +#include "../../../../Machines/DynamicMachine.hpp" + +#include +#include + +namespace Analyser { +namespace Dynamic { + +struct MultiConfigurationTarget: public ::ConfigurationTarget::Machine { + public: + MultiConfigurationTarget(const std::vector> &machines); + + void configure_as_target(const Analyser::Static::Target &target) override; + bool insert_media(const Analyser::Static::Media &media) override; + + private: + const std::vector> &machines_; +}; + +} +} + +#endif /* MultiConfigurationTarget_hpp */ diff --git a/Analyser/Dynamic/MultiMachine/MultiMachine.cpp b/Analyser/Dynamic/MultiMachine/MultiMachine.cpp index 71649c016..32a30a9a9 100644 --- a/Analyser/Dynamic/MultiMachine/MultiMachine.cpp +++ b/Analyser/Dynamic/MultiMachine/MultiMachine.cpp @@ -11,10 +11,11 @@ using namespace Analyser::Dynamic; MultiMachine::MultiMachine(std::vector> &&machines) : - machines_(std::move(machines)) {} + machines_(std::move(machines)), + configuration_target_(machines_) {} ConfigurationTarget::Machine *MultiMachine::configuration_target() { - return nullptr; + return &configuration_target_; } CRTMachine::Machine *MultiMachine::crt_machine() { diff --git a/Analyser/Dynamic/MultiMachine/MultiMachine.hpp b/Analyser/Dynamic/MultiMachine/MultiMachine.hpp index e1f86760c..e255bb7b1 100644 --- a/Analyser/Dynamic/MultiMachine/MultiMachine.hpp +++ b/Analyser/Dynamic/MultiMachine/MultiMachine.hpp @@ -9,7 +9,9 @@ #ifndef MultiMachine_hpp #define MultiMachine_hpp -#include "../../../Machines/Utility/MachineForTarget.hpp" +#include "../../../Machines/DynamicMachine.hpp" + +#include "Implementation/MultiConfigurationTarget.hpp" #include #include @@ -42,6 +44,8 @@ class MultiMachine: public ::Machine::DynamicMachine { private: std::vector> machines_; + + MultiConfigurationTarget configuration_target_; }; } diff --git a/Machines/DynamicMachine.hpp b/Machines/DynamicMachine.hpp new file mode 100644 index 000000000..1182120ee --- /dev/null +++ b/Machines/DynamicMachine.hpp @@ -0,0 +1,37 @@ +// +// DynamicMachine.hpp +// Clock Signal +// +// Created by Thomas Harte on 29/01/2018. +// Copyright © 2018 Thomas Harte. All rights reserved. +// + +#ifndef DynamicMachine_h +#define DynamicMachine_h + +#include "../Configurable/Configurable.hpp" +#include "ConfigurationTarget.hpp" +#include "CRTMachine.hpp" +#include "JoystickMachine.hpp" +#include "KeyboardMachine.hpp" +#include "Utility/Typer.hpp" + +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() {} + virtual ConfigurationTarget::Machine *configuration_target() = 0; + virtual CRTMachine::Machine *crt_machine() = 0; + virtual JoystickMachine::Machine *joystick_machine() = 0; + virtual KeyboardMachine::Machine *keyboard_machine() = 0; + virtual Configurable::Device *configurable_device() = 0; + virtual Utility::TypeRecipient *type_recipient() = 0; +}; + +} + +#endif /* DynamicMachine_h */ diff --git a/Machines/Utility/MachineForTarget.hpp b/Machines/Utility/MachineForTarget.hpp index 490f8ac59..dfa00269e 100644 --- a/Machines/Utility/MachineForTarget.hpp +++ b/Machines/Utility/MachineForTarget.hpp @@ -11,12 +11,7 @@ #include "../../Analyser/Static/StaticAnalyser.hpp" -#include "../../Configurable/Configurable.hpp" -#include "../ConfigurationTarget.hpp" -#include "../CRTMachine.hpp" -#include "../JoystickMachine.hpp" -#include "../KeyboardMachine.hpp" -#include "Typer.hpp" +#include "../DynamicMachine.hpp" #include #include @@ -24,20 +19,6 @@ 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() {} - virtual ConfigurationTarget::Machine *configuration_target() = 0; - virtual CRTMachine::Machine *crt_machine() = 0; - virtual JoystickMachine::Machine *joystick_machine() = 0; - virtual KeyboardMachine::Machine *keyboard_machine() = 0; - virtual Configurable::Device *configurable_device() = 0; - virtual Utility::TypeRecipient *type_recipient() = 0; -}; - enum class Error { None, UnknownMachine, diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 707dad95f..4c1c3ebb5 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -568,6 +568,8 @@ 4BB73EB71B587A5100552FC2 /* AllSuiteATests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB73EB61B587A5100552FC2 /* AllSuiteATests.swift */; }; 4BB73EC21B587A5100552FC2 /* Clock_SignalUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB73EC11B587A5100552FC2 /* Clock_SignalUITests.swift */; }; 4BBB14311CD2CECE00BDB55C /* IntermediateShader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBB142F1CD2CECE00BDB55C /* IntermediateShader.cpp */; }; + 4BBB70A4202011C2002FE009 /* MultiConfigurationTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBB70A3202011C2002FE009 /* MultiConfigurationTarget.cpp */; }; + 4BBB70A5202011C2002FE009 /* MultiConfigurationTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBB70A3202011C2002FE009 /* MultiConfigurationTarget.cpp */; }; 4BBC951E1F368D83008F4C34 /* i8272.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBC951C1F368D83008F4C34 /* i8272.cpp */; }; 4BBF49AF1ED2880200AB3669 /* FUSETests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BBF49AE1ED2880200AB3669 /* FUSETests.swift */; }; 4BBF99141C8FBA6F0075DAFB /* TextureBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBF99081C8FBA6F0075DAFB /* TextureBuilder.cpp */; }; @@ -1248,6 +1250,9 @@ 4BB73ECF1B587A6700552FC2 /* Clock Signal.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Clock Signal.entitlements"; sourceTree = ""; }; 4BBB142F1CD2CECE00BDB55C /* IntermediateShader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntermediateShader.cpp; sourceTree = ""; }; 4BBB14301CD2CECE00BDB55C /* IntermediateShader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = IntermediateShader.hpp; sourceTree = ""; }; + 4BBB709C2020109C002FE009 /* DynamicMachine.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = DynamicMachine.hpp; sourceTree = ""; }; + 4BBB70A2202011C2002FE009 /* MultiConfigurationTarget.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MultiConfigurationTarget.hpp; sourceTree = ""; }; + 4BBB70A3202011C2002FE009 /* MultiConfigurationTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MultiConfigurationTarget.cpp; sourceTree = ""; }; 4BBC34241D2208B100FFC9DF /* CSFastLoading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSFastLoading.h; sourceTree = ""; }; 4BBC951C1F368D83008F4C34 /* i8272.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = i8272.cpp; path = 8272/i8272.cpp; sourceTree = ""; }; 4BBC951D1F368D83008F4C34 /* i8272.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = i8272.hpp; path = 8272/i8272.hpp; sourceTree = ""; }; @@ -1693,8 +1698,9 @@ 4B3FCC3D201EC24200960631 /* MultiMachine */ = { isa = PBXGroup; children = ( - 4B3FCC3E201EC24200960631 /* MultiMachine.hpp */, 4B3FCC3F201EC24200960631 /* MultiMachine.cpp */, + 4B3FCC3E201EC24200960631 /* MultiMachine.hpp */, + 4BBB70A1202011C2002FE009 /* Implementation */, ); path = MultiMachine; sourceTree = ""; @@ -2618,6 +2624,7 @@ 4B54C0BB1F8D8E790050900F /* KeyboardMachine.cpp */, 4BA9C3CF1D8164A9002DDB61 /* ConfigurationTarget.hpp */, 4B046DC31CFE651500E9E45E /* CRTMachine.hpp */, + 4BBB709C2020109C002FE009 /* DynamicMachine.hpp */, 4B7041271F92C26900735E45 /* JoystickMachine.hpp */, 4B8E4ECD1DCE483D003716C3 /* KeyboardMachine.hpp */, 4BDCC5F81FB27A5E001220C5 /* ROMMachine.hpp */, @@ -2647,6 +2654,15 @@ path = ../../Processors; sourceTree = ""; }; + 4BBB70A1202011C2002FE009 /* Implementation */ = { + isa = PBXGroup; + children = ( + 4BBB70A2202011C2002FE009 /* MultiConfigurationTarget.hpp */, + 4BBB70A3202011C2002FE009 /* MultiConfigurationTarget.cpp */, + ); + path = Implementation; + sourceTree = ""; + }; 4BBC951F1F368D87008F4C34 /* 8272 */ = { isa = PBXGroup; children = ( @@ -3423,6 +3439,7 @@ 4BAD13441FF709C700FD114A /* MSX.cpp in Sources */, 4B055AC41FAE9AE80060FFFF /* Keyboard.cpp in Sources */, 4B055A941FAE85B50060FFFF /* CommodoreROM.cpp in Sources */, + 4BBB70A5202011C2002FE009 /* MultiConfigurationTarget.cpp in Sources */, 4B055A971FAE85BB0060FFFF /* ZX8081.cpp in Sources */, 4B055AAD1FAE85FD0060FFFF /* PCMTrack.cpp in Sources */, 4B055AC61FAE9AEE0060FFFF /* TIASound.cpp in Sources */, @@ -3565,6 +3582,7 @@ 4B4518841F75E91A00926311 /* UnformattedTrack.cpp in Sources */, 4B55CE5D1C3B7D6F0093A61B /* CSOpenGLView.m in Sources */, 4B894528201967B4007DE474 /* Disk.cpp in Sources */, + 4BBB70A4202011C2002FE009 /* MultiConfigurationTarget.cpp in Sources */, 4B89453A201967B4007DE474 /* StaticAnalyser.cpp in Sources */, 4BB697CB1D4B6D3E00248BDF /* TimedEventLoop.cpp in Sources */, 4B54C0C21F8D91CD0050900F /* Keyboard.cpp in Sources */,