mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-24 11:11:02 -07:00
Split the dependency so that the encoders/decoders don't depend on arch.
This commit is contained in:
96
arch/arch.cc
Normal file
96
arch/arch.cc
Normal file
@@ -0,0 +1,96 @@
|
||||
#include "lib/core/globals.h"
|
||||
#include "lib/encoders/encoders.h"
|
||||
#include "lib/decoders/decoders.h"
|
||||
#include "lib/config/config.h"
|
||||
#include "arch/agat/agat.h"
|
||||
#include "arch/aeslanier/aeslanier.h"
|
||||
#include "arch/amiga/amiga.h"
|
||||
#include "arch/apple2/apple2.h"
|
||||
#include "arch/brother/brother.h"
|
||||
#include "arch/c64/c64.h"
|
||||
#include "arch/f85/f85.h"
|
||||
#include "arch/fb100/fb100.h"
|
||||
#include "arch/ibm/ibm.h"
|
||||
#include "arch/macintosh/macintosh.h"
|
||||
#include "arch/micropolis/micropolis.h"
|
||||
#include "arch/mx/mx.h"
|
||||
#include "arch/northstar/northstar.h"
|
||||
#include "arch/rolandd20/rolandd20.h"
|
||||
#include "arch/smaky6/smaky6.h"
|
||||
#include "arch/tartu/tartu.h"
|
||||
#include "arch/tids990/tids990.h"
|
||||
#include "arch/victor9k/victor9k.h"
|
||||
#include "arch/zilogmcz/zilogmcz.h"
|
||||
#include "arch/arch.h"
|
||||
|
||||
std::unique_ptr<Encoder> Arch::createEncoder(Config& config)
|
||||
{
|
||||
if (!config.hasEncoder())
|
||||
error("no encoder configured");
|
||||
return createEncoder(config->encoder());
|
||||
}
|
||||
|
||||
std::unique_ptr<Encoder> Arch::createEncoder(const EncoderProto& config){
|
||||
static const std::map<int,
|
||||
std::function<std::unique_ptr<Encoder>(const EncoderProto&)>>
|
||||
encoders = {
|
||||
{EncoderProto::kAgat, createAgatEncoder },
|
||||
{EncoderProto::kAmiga, createAmigaEncoder },
|
||||
{EncoderProto::kApple2, createApple2Encoder },
|
||||
{EncoderProto::kBrother, createBrotherEncoder },
|
||||
{EncoderProto::kC64, createCommodore64Encoder},
|
||||
{EncoderProto::kIbm, createIbmEncoder },
|
||||
{EncoderProto::kMacintosh, createMacintoshEncoder },
|
||||
{EncoderProto::kMicropolis, createMicropolisEncoder },
|
||||
{EncoderProto::kNorthstar, createNorthstarEncoder },
|
||||
{EncoderProto::kTartu, createTartuEncoder },
|
||||
{EncoderProto::kTids990, createTids990Encoder },
|
||||
{EncoderProto::kVictor9K, createVictor9kEncoder },
|
||||
};
|
||||
|
||||
auto encoder = encoders.find(config.format_case());
|
||||
if (encoder == encoders.end())
|
||||
error("no encoder specified");
|
||||
|
||||
return (encoder->second)(config);
|
||||
}
|
||||
|
||||
std::unique_ptr<Decoder> Arch::createDecoder(Config& config)
|
||||
{
|
||||
if (!config.hasDecoder())
|
||||
error("no decoder configured");
|
||||
return createDecoder(config->decoder());
|
||||
}
|
||||
|
||||
std::unique_ptr<Decoder> Arch::createDecoder(const DecoderProto& config)
|
||||
{
|
||||
static const std::map<int,
|
||||
std::function<std::unique_ptr<Decoder>(const DecoderProto&)>>
|
||||
decoders = {
|
||||
{DecoderProto::kAgat, createAgatDecoder },
|
||||
{DecoderProto::kAeslanier, createAesLanierDecoder },
|
||||
{DecoderProto::kAmiga, createAmigaDecoder },
|
||||
{DecoderProto::kApple2, createApple2Decoder },
|
||||
{DecoderProto::kBrother, createBrotherDecoder },
|
||||
{DecoderProto::kC64, createCommodore64Decoder},
|
||||
{DecoderProto::kF85, createDurangoF85Decoder },
|
||||
{DecoderProto::kFb100, createFb100Decoder },
|
||||
{DecoderProto::kIbm, createIbmDecoder },
|
||||
{DecoderProto::kMacintosh, createMacintoshDecoder },
|
||||
{DecoderProto::kMicropolis, createMicropolisDecoder },
|
||||
{DecoderProto::kMx, createMxDecoder },
|
||||
{DecoderProto::kNorthstar, createNorthstarDecoder },
|
||||
{DecoderProto::kRolandd20, createRolandD20Decoder },
|
||||
{DecoderProto::kSmaky6, createSmaky6Decoder },
|
||||
{DecoderProto::kTartu, createTartuDecoder },
|
||||
{DecoderProto::kTids990, createTids990Decoder },
|
||||
{DecoderProto::kVictor9K, createVictor9kDecoder },
|
||||
{DecoderProto::kZilogmcz, createZilogMczDecoder },
|
||||
};
|
||||
|
||||
auto decoder = decoders.find(config.format_case());
|
||||
if (decoder == decoders.end())
|
||||
error("no decoder specified");
|
||||
|
||||
return (decoder->second)(config);
|
||||
}
|
||||
16
arch/arch.h
Normal file
16
arch/arch.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
class Encoder;
|
||||
class Decoder;
|
||||
class DecoderProto;
|
||||
class EncoderProto;
|
||||
class Config;
|
||||
|
||||
namespace Arch
|
||||
{
|
||||
std::unique_ptr<Decoder> createDecoder(Config& config);
|
||||
std::unique_ptr<Decoder> createDecoder(const DecoderProto& config);
|
||||
|
||||
std::unique_ptr<Encoder> createEncoder(Config& config);
|
||||
std::unique_ptr<Encoder> createEncoder(const EncoderProto& config);
|
||||
}
|
||||
2
build.py
2
build.py
@@ -27,6 +27,7 @@ cxxlibrary(
|
||||
"./lib/decoders/fmmfm.cc",
|
||||
"./lib/encoders/encoders.cc",
|
||||
"./lib/readerwriter.cc",
|
||||
"./arch/arch.cc",
|
||||
"./arch/aeslanier/decoder.cc",
|
||||
"./arch/agat/agat.cc",
|
||||
"./arch/agat/decoder.cc",
|
||||
@@ -89,6 +90,7 @@ cxxlibrary(
|
||||
"arch/c64/data_gcr.h": "./arch/c64/data_gcr.h",
|
||||
"arch/c64/c64.h": "./arch/c64/c64.h",
|
||||
"arch/tartu/tartu.h": "./arch/tartu/tartu.h",
|
||||
"arch/arch.h": "./arch/arch.h",
|
||||
"lib/decoders/decoders.h": "./lib/decoders/decoders.h",
|
||||
"lib/decoders/fluxdecoder.h": "./lib/decoders/fluxdecoder.h",
|
||||
"lib/decoders/rawbits.h": "./lib/decoders/rawbits.h",
|
||||
|
||||
@@ -4,25 +4,6 @@
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/decoders/decoders.h"
|
||||
#include "lib/encoders/encoders.h"
|
||||
#include "arch/agat/agat.h"
|
||||
#include "arch/aeslanier/aeslanier.h"
|
||||
#include "arch/amiga/amiga.h"
|
||||
#include "arch/apple2/apple2.h"
|
||||
#include "arch/brother/brother.h"
|
||||
#include "arch/c64/c64.h"
|
||||
#include "arch/f85/f85.h"
|
||||
#include "arch/fb100/fb100.h"
|
||||
#include "arch/ibm/ibm.h"
|
||||
#include "arch/macintosh/macintosh.h"
|
||||
#include "arch/micropolis/micropolis.h"
|
||||
#include "arch/mx/mx.h"
|
||||
#include "arch/northstar/northstar.h"
|
||||
#include "arch/rolandd20/rolandd20.h"
|
||||
#include "arch/smaky6/smaky6.h"
|
||||
#include "arch/tartu/tartu.h"
|
||||
#include "arch/tids990/tids990.h"
|
||||
#include "arch/victor9k/victor9k.h"
|
||||
#include "arch/zilogmcz/zilogmcz.h"
|
||||
#include "lib/data/fluxmapreader.h"
|
||||
#include "lib/data/flux.h"
|
||||
#include "protocol.h"
|
||||
@@ -33,45 +14,6 @@
|
||||
#include "lib/data/layout.h"
|
||||
#include <numeric>
|
||||
|
||||
std::unique_ptr<Decoder> Decoder::create(Config& config)
|
||||
{
|
||||
if (!config.hasDecoder())
|
||||
error("no decoder configured");
|
||||
return create(config->decoder());
|
||||
}
|
||||
|
||||
std::unique_ptr<Decoder> Decoder::create(const DecoderProto& config)
|
||||
{
|
||||
static const std::map<int,
|
||||
std::function<std::unique_ptr<Decoder>(const DecoderProto&)>>
|
||||
decoders = {
|
||||
{DecoderProto::kAgat, createAgatDecoder },
|
||||
{DecoderProto::kAeslanier, createAesLanierDecoder },
|
||||
{DecoderProto::kAmiga, createAmigaDecoder },
|
||||
{DecoderProto::kApple2, createApple2Decoder },
|
||||
{DecoderProto::kBrother, createBrotherDecoder },
|
||||
{DecoderProto::kC64, createCommodore64Decoder},
|
||||
{DecoderProto::kF85, createDurangoF85Decoder },
|
||||
{DecoderProto::kFb100, createFb100Decoder },
|
||||
{DecoderProto::kIbm, createIbmDecoder },
|
||||
{DecoderProto::kMacintosh, createMacintoshDecoder },
|
||||
{DecoderProto::kMicropolis, createMicropolisDecoder },
|
||||
{DecoderProto::kMx, createMxDecoder },
|
||||
{DecoderProto::kNorthstar, createNorthstarDecoder },
|
||||
{DecoderProto::kRolandd20, createRolandD20Decoder },
|
||||
{DecoderProto::kSmaky6, createSmaky6Decoder },
|
||||
{DecoderProto::kTartu, createTartuDecoder },
|
||||
{DecoderProto::kTids990, createTids990Decoder },
|
||||
{DecoderProto::kVictor9K, createVictor9kDecoder },
|
||||
{DecoderProto::kZilogmcz, createZilogMczDecoder },
|
||||
};
|
||||
|
||||
auto decoder = decoders.find(config.format_case());
|
||||
if (decoder == decoders.end())
|
||||
error("no decoder specified");
|
||||
|
||||
return (decoder->second)(config);
|
||||
}
|
||||
|
||||
std::shared_ptr<TrackDataFlux> Decoder::decodeToSectors(
|
||||
std::shared_ptr<const Fluxmap> fluxmap,
|
||||
|
||||
@@ -3,57 +3,12 @@
|
||||
#include "lib/data/fluxmap.h"
|
||||
#include "lib/decoders/decoders.h"
|
||||
#include "lib/encoders/encoders.h"
|
||||
#include "arch/agat/agat.h"
|
||||
#include "arch/amiga/amiga.h"
|
||||
#include "arch/apple2/apple2.h"
|
||||
#include "arch/brother/brother.h"
|
||||
#include "arch/c64/c64.h"
|
||||
#include "arch/ibm/ibm.h"
|
||||
#include "arch/macintosh/macintosh.h"
|
||||
#include "arch/micropolis/micropolis.h"
|
||||
#include "arch/northstar/northstar.h"
|
||||
#include "arch/tartu/tartu.h"
|
||||
#include "arch/tids990/tids990.h"
|
||||
#include "arch/victor9k/victor9k.h"
|
||||
#include "lib/encoders/encoders.pb.h"
|
||||
#include "lib/config/proto.h"
|
||||
#include "lib/data/layout.h"
|
||||
#include "lib/data/image.h"
|
||||
#include "protocol.h"
|
||||
|
||||
std::unique_ptr<Encoder> Encoder::create(Config& config)
|
||||
{
|
||||
if (!config.hasEncoder())
|
||||
error("no encoder configured");
|
||||
return create(config->encoder());
|
||||
}
|
||||
|
||||
std::unique_ptr<Encoder> Encoder::create(const EncoderProto& config)
|
||||
{
|
||||
static const std::map<int,
|
||||
std::function<std::unique_ptr<Encoder>(const EncoderProto&)>>
|
||||
encoders = {
|
||||
{EncoderProto::kAgat, createAgatEncoder },
|
||||
{EncoderProto::kAmiga, createAmigaEncoder },
|
||||
{EncoderProto::kApple2, createApple2Encoder },
|
||||
{EncoderProto::kBrother, createBrotherEncoder },
|
||||
{EncoderProto::kC64, createCommodore64Encoder},
|
||||
{EncoderProto::kIbm, createIbmEncoder },
|
||||
{EncoderProto::kMacintosh, createMacintoshEncoder },
|
||||
{EncoderProto::kMicropolis, createMicropolisEncoder },
|
||||
{EncoderProto::kNorthstar, createNorthstarEncoder },
|
||||
{EncoderProto::kTartu, createTartuEncoder },
|
||||
{EncoderProto::kTids990, createTids990Encoder },
|
||||
{EncoderProto::kVictor9K, createVictor9kEncoder },
|
||||
};
|
||||
|
||||
auto encoder = encoders.find(config.format_case());
|
||||
if (encoder == encoders.end())
|
||||
error("no encoder specified");
|
||||
|
||||
return (encoder->second)(config);
|
||||
}
|
||||
|
||||
nanoseconds_t Encoder::calculatePhysicalClockPeriod(
|
||||
nanoseconds_t targetClockPeriod, nanoseconds_t targetRotationalPeriod)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,6 @@ public:
|
||||
virtual ~Encoder() {}
|
||||
|
||||
static std::unique_ptr<Encoder> create(Config& config);
|
||||
static std::unique_ptr<Encoder> create(const EncoderProto& config);
|
||||
|
||||
public:
|
||||
virtual std::shared_ptr<const Sector> getSector(
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "lib/encoders/encoders.h"
|
||||
#include "lib/config/config.pb.h"
|
||||
#include "lib/core/utils.h"
|
||||
#include "arch/arch.h"
|
||||
|
||||
Path::Path(const std::vector<std::string> other):
|
||||
std::vector<std::string>(other)
|
||||
@@ -244,12 +245,12 @@ std::unique_ptr<Filesystem> Filesystem::createFilesystemFromConfig()
|
||||
if (globalConfig().hasFluxSource())
|
||||
{
|
||||
fluxSource = FluxSource::create(globalConfig());
|
||||
decoder = Decoder::create(globalConfig());
|
||||
decoder = Arch::createDecoder(globalConfig());
|
||||
}
|
||||
if (globalConfig()->flux_sink().type() == FLUXTYPE_DRIVE)
|
||||
{
|
||||
fluxSink = FluxSink::create(globalConfig());
|
||||
encoder = Encoder::create(globalConfig());
|
||||
encoder = Arch::createEncoder(globalConfig());
|
||||
}
|
||||
sectorInterface = SectorInterface::createFluxSectorInterface(
|
||||
fluxSource, fluxSink, encoder, decoder);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "lib/fluxsource/fluxsource.h"
|
||||
#include "lib/fluxsink/fluxsink.h"
|
||||
#include "lib/imagewriter/imagewriter.h"
|
||||
#include "arch/arch.h"
|
||||
#include "fluxengine.h"
|
||||
#include <google/protobuf/text_format.h>
|
||||
#include <fstream>
|
||||
@@ -66,7 +67,7 @@ int mainRead(int argc, const char* argv[])
|
||||
error("you cannot copy flux to a hardware device");
|
||||
|
||||
auto fluxSource = FluxSource::create(globalConfig());
|
||||
auto decoder = Decoder::create(globalConfig());
|
||||
auto decoder = Arch::createDecoder(globalConfig());
|
||||
auto writer = ImageWriter::create(globalConfig());
|
||||
|
||||
readDiskCommand(*fluxSource, *decoder, *writer);
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
#include "lib/config/proto.h"
|
||||
#include "lib/fluxsink/fluxsink.h"
|
||||
#include "lib/fluxsource/fluxsource.h"
|
||||
#include "arch/brother/brother.h"
|
||||
#include "arch/ibm/ibm.h"
|
||||
#include "arch/arch.h"
|
||||
#include "lib/imagereader/imagereader.h"
|
||||
#include "fluxengine.h"
|
||||
#include <google/protobuf/text_format.h>
|
||||
@@ -71,14 +70,14 @@ int mainWrite(int argc, const char* argv[])
|
||||
auto reader = ImageReader::create(globalConfig());
|
||||
std::shared_ptr<Image> image = reader->readMappedImage();
|
||||
|
||||
auto encoder = Encoder::create(globalConfig());
|
||||
auto encoder = Arch::createEncoder(globalConfig());
|
||||
auto fluxSink = FluxSink::create(globalConfig());
|
||||
|
||||
std::shared_ptr<Decoder> decoder;
|
||||
std::shared_ptr<FluxSource> verificationFluxSource;
|
||||
if (globalConfig().hasDecoder() && fluxSink->isHardware() && verify)
|
||||
{
|
||||
decoder = Decoder::create(globalConfig());
|
||||
decoder = Arch::createDecoder(globalConfig());
|
||||
verificationFluxSource =
|
||||
FluxSource::create(globalConfig().getVerificationFluxSourceProto());
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#include <lib/core/globals.h>
|
||||
#include <lib/fluxsource/fluxsource.h>
|
||||
#include <lib/fluxsink/fluxsink.h>
|
||||
#include <lib/imagereader/imagereader.h>
|
||||
#include <lib/imagewriter/imagewriter.h>
|
||||
#include <lib/decoders/decoders.h>
|
||||
#include <lib/encoders/encoders.h>
|
||||
#include <lib/config/config.h>
|
||||
#include "lib/core/globals.h"
|
||||
#include "lib/fluxsource/fluxsource.h"
|
||||
#include "lib/fluxsink/fluxsink.h"
|
||||
#include "lib/imagereader/imagereader.h"
|
||||
#include "lib/imagewriter/imagewriter.h"
|
||||
#include "lib/decoders/decoders.h"
|
||||
#include "lib/encoders/encoders.h"
|
||||
#include "arch/arch.h"
|
||||
#include "lib/config/config.h"
|
||||
#include "context.h"
|
||||
#include "gui.h"
|
||||
|
||||
@@ -64,7 +65,7 @@ namespace
|
||||
{
|
||||
if (!_encoder)
|
||||
{
|
||||
_encoder = Encoder::create(globalConfig());
|
||||
_encoder = Arch::createEncoder(globalConfig());
|
||||
}
|
||||
return _encoder.get();
|
||||
}
|
||||
@@ -73,7 +74,7 @@ namespace
|
||||
{
|
||||
if (!_decoder)
|
||||
{
|
||||
_decoder = Decoder::create(globalConfig());
|
||||
_decoder = Arch::createDecoder(globalConfig());
|
||||
}
|
||||
return _decoder.get();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user