From 66fbbce59a9f7e32664d7297e27b136d7e916409 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Sat, 28 Sep 2019 15:26:47 +0200 Subject: [PATCH] Device: - suppress prog_mode to the constructor and set mode to NONE_MODE - parse file extension - program, idCode and reset are now virtual --- device.cpp | 16 ++++++---------- device.hpp | 10 ++++++---- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/device.cpp b/device.cpp index 0955063..3410c44 100644 --- a/device.cpp +++ b/device.cpp @@ -5,21 +5,17 @@ using namespace std; -Device::Device(FtdiJtag *jtag, enum prog_mode mode, string filename): - _filename(filename), _mode(mode) +Device::Device(FtdiJtag *jtag, string filename): + _filename(filename), + _file_extension(filename.substr(filename.find_last_of(".") +1)), + _mode(NONE_MODE) { _jtag = jtag; + cout << _file_extension << endl; } -int Device::idCode() -{ - return 0; -} +Device::~Device() {} -void Device::program() -{ - throw std::runtime_error("Not implemented"); -} void Device::reset() { throw std::runtime_error("Not implemented"); diff --git a/device.hpp b/device.hpp index 5e1a158..bcfce42 100644 --- a/device.hpp +++ b/device.hpp @@ -17,13 +17,15 @@ class Device { SPI_MODE, MEM_MODE }; - Device(FtdiJtag *jtag, enum prog_mode, std::string filename); - virtual void program(); - int idCode(); - void reset(); + Device(FtdiJtag *jtag, std::string filename); + virtual ~Device(); + virtual void program(unsigned int offset = 0) = 0; + virtual int idCode() = 0; + virtual void reset(); protected: FtdiJtag *_jtag; std::string _filename; + std::string _file_extension; enum prog_mode _mode; };