2016-08-24 01:35:59 +00:00
|
|
|
//
|
|
|
|
// StaticAnalyser.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 23/08/2016.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2016 Thomas Harte. All rights reserved.
|
2016-08-24 01:35:59 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef StaticAnalyser_hpp
|
|
|
|
#define StaticAnalyser_hpp
|
|
|
|
|
2018-01-25 02:48:44 +00:00
|
|
|
#include "../Machines.hpp"
|
|
|
|
|
|
|
|
#include "../../Storage/Cartridge/Cartridge.hpp"
|
2019-08-25 19:10:09 +00:00
|
|
|
#include "../../Storage/Disk/Disk.hpp"
|
|
|
|
#include "../../Storage/MassStorage/MassStorageDevice.hpp"
|
|
|
|
#include "../../Storage/Tape/Tape.hpp"
|
2021-04-25 03:17:47 +00:00
|
|
|
#include "../../Reflection/Struct.hpp"
|
2016-08-27 22:26:51 +00:00
|
|
|
|
2018-04-14 16:12:12 +00:00
|
|
|
#include <memory>
|
2016-08-24 01:35:59 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2018-01-25 02:48:44 +00:00
|
|
|
namespace Analyser {
|
|
|
|
namespace Static {
|
2016-08-24 01:35:59 +00:00
|
|
|
|
2021-04-25 03:17:47 +00:00
|
|
|
struct State;
|
|
|
|
|
2017-08-17 14:48:29 +00:00
|
|
|
/*!
|
2021-04-25 03:17:47 +00:00
|
|
|
A list of disks, tapes and cartridges, and possibly a state snapshot.
|
2017-08-17 14:48:29 +00:00
|
|
|
*/
|
|
|
|
struct Media {
|
2018-01-24 03:18:16 +00:00
|
|
|
std::vector<std::shared_ptr<Storage::Disk::Disk>> disks;
|
|
|
|
std::vector<std::shared_ptr<Storage::Tape::Tape>> tapes;
|
|
|
|
std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> cartridges;
|
2019-08-25 19:10:09 +00:00
|
|
|
std::vector<std::shared_ptr<Storage::MassStorage::MassStorageDevice>> mass_storage_devices;
|
2017-12-02 21:01:30 +00:00
|
|
|
|
|
|
|
bool empty() const {
|
2019-08-25 19:10:09 +00:00
|
|
|
return disks.empty() && tapes.empty() && cartridges.empty() && mass_storage_devices.empty();
|
2017-12-02 21:01:30 +00:00
|
|
|
}
|
2020-03-20 00:40:43 +00:00
|
|
|
|
|
|
|
Media &operator +=(const Media &rhs) {
|
|
|
|
#define append(name) name.insert(name.end(), rhs.name.begin(), rhs.name.end());
|
|
|
|
append(disks);
|
|
|
|
append(tapes);
|
|
|
|
append(cartridges);
|
|
|
|
append(mass_storage_devices);
|
|
|
|
#undef append
|
|
|
|
return *this;
|
|
|
|
}
|
2017-08-17 14:48:29 +00:00
|
|
|
};
|
|
|
|
|
2016-08-28 16:20:40 +00:00
|
|
|
/*!
|
2021-04-25 03:17:47 +00:00
|
|
|
Describes a machine and possibly its state; conventionally subclassed to add other machine-specific configuration fields and any
|
|
|
|
necessary instructions on how to launch any software provided, plus a measure of confidence in this target's correctness.
|
2016-08-28 16:20:40 +00:00
|
|
|
*/
|
2016-08-24 01:35:59 +00:00
|
|
|
struct Target {
|
2020-03-15 04:13:38 +00:00
|
|
|
Target(Machine machine) : machine(machine) {}
|
2018-03-09 20:36:11 +00:00
|
|
|
virtual ~Target() {}
|
|
|
|
|
2021-04-25 03:17:47 +00:00
|
|
|
// This field is entirely optional.
|
2021-04-25 03:19:30 +00:00
|
|
|
std::unique_ptr<Reflection::Struct> state;
|
2021-04-25 03:17:47 +00:00
|
|
|
|
2018-01-25 02:48:44 +00:00
|
|
|
Machine machine;
|
2018-01-25 03:35:54 +00:00
|
|
|
Media media;
|
2020-03-15 04:13:38 +00:00
|
|
|
float confidence = 0.0f;
|
2016-08-24 01:35:59 +00:00
|
|
|
};
|
2018-04-14 16:12:12 +00:00
|
|
|
typedef std::vector<std::unique_ptr<Target>> TargetList;
|
2016-08-24 01:35:59 +00:00
|
|
|
|
2016-08-28 16:20:40 +00:00
|
|
|
/*!
|
|
|
|
Attempts, through any available means, to return a list of potential targets for the file with the given name.
|
2017-11-08 03:51:06 +00:00
|
|
|
|
2016-08-28 16:20:40 +00:00
|
|
|
@returns The list of potential targets, sorted from most to least probable.
|
|
|
|
*/
|
2018-04-14 16:12:12 +00:00
|
|
|
TargetList GetTargets(const std::string &file_name);
|
2016-08-24 01:35:59 +00:00
|
|
|
|
2017-08-17 14:48:29 +00:00
|
|
|
/*!
|
|
|
|
Inspects the supplied file and determines the media included.
|
|
|
|
*/
|
2018-04-06 21:42:24 +00:00
|
|
|
Media GetMedia(const std::string &file_name);
|
2017-08-17 14:48:29 +00:00
|
|
|
|
2018-01-25 02:48:44 +00:00
|
|
|
}
|
2016-08-24 01:35:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* StaticAnalyser_hpp */
|