1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-18 04:29:46 +00:00
CLK/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurable.cpp

65 lines
1.8 KiB
C++
Raw Normal View History

//
// MultiConfigurable.cpp
// Clock Signal
//
// Created by Thomas Harte on 09/02/2018.
// Copyright 2018 Thomas Harte. All rights reserved.
//
#include "MultiConfigurable.hpp"
#include <algorithm>
using namespace Analyser::Dynamic;
MultiConfigurable::MultiConfigurable(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines) {
for(const auto &machine: machines) {
Configurable::Device *device = machine->configurable_device();
2018-02-19 21:06:46 +00:00
if(device) devices_.push_back(device);
2018-05-05 23:32:20 +00:00
}
}
std::vector<std::unique_ptr<Configurable::Option>> MultiConfigurable::get_options() {
std::vector<std::unique_ptr<Configurable::Option>> options;
// Produce the list of unique options.
for(const auto &device : devices_) {
std::vector<std::unique_ptr<Configurable::Option>> device_options = device->get_options();
for(auto &option : device_options) {
if(std::find(options.begin(), options.end(), option) == options.end()) {
options.push_back(std::move(option));
}
}
}
return options;
}
void MultiConfigurable::set_selections(const Configurable::SelectionSet &selection_by_option) {
for(const auto &device : devices_) {
device->set_selections(selection_by_option);
}
}
Configurable::SelectionSet MultiConfigurable::get_accurate_selections() {
Configurable::SelectionSet set;
for(const auto &device : devices_) {
Configurable::SelectionSet device_set = device->get_accurate_selections();
for(auto &selection : device_set) {
set.insert(std::move(selection));
}
}
return set;
}
Configurable::SelectionSet MultiConfigurable::get_user_friendly_selections() {
Configurable::SelectionSet set;
for(const auto &device : devices_) {
Configurable::SelectionSet device_set = device->get_user_friendly_selections();
for(auto &selection : device_set) {
set.insert(std::move(selection));
}
}
return set;
}