| 1 | #ifndef SIMPLEHEXREQUEST_H |
| 2 | #define SIMPLEHEXREQUEST_H |
| 3 | |
| 4 | #include "OpenMSXConnection.h" |
| 5 | |
| 6 | /** |
| 7 | * A set of helper classes if code needs to read openMSX debugables into an array of unsigned chars |
| 8 | * if class A needs to read a given debugable then this schema will suffice |
| 9 | * - Class A inherits from SimpleHexRequestUser |
| 10 | * - Class A can reimplement the DataHexRequestReceived if it wants to react when new data has arrived |
| 11 | * - Class A can reimplement the DataHexRequestCanceled if it wants to react to failures of the request |
| 12 | * - to read the debuggable into the memory just create a new SimpleHexRequest, fi. |
| 13 | * new SimpleHexRequest("{VDP status regs}",0,16,statusregs, *this); |
| 14 | * |
| 15 | */ |
| 16 | class SimpleHexRequestUser |
| 17 | { |
| 18 | protected: |
| 19 | virtual ~SimpleHexRequestUser() = default; |
| 20 | virtual void DataHexRequestReceived(); |
| 21 | virtual void DataHexRequestCanceled(); |
| 22 | friend class SimpleHexRequest; |
| 23 | }; |
| 24 | |
| 25 | class SimpleHexRequest : public ReadDebugBlockCommand |
| 26 | { |
| 27 | public: |
| 28 | SimpleHexRequest(const QString& debuggable, unsigned size, |
| 29 | unsigned char* target, SimpleHexRequestUser& user); |
| 30 | SimpleHexRequest(const QString& debuggable, unsigned offset, unsigned size, |
| 31 | unsigned char* target, SimpleHexRequestUser& user); |
| 32 | |
| 33 | void replyOk(const QString& message) override; |
| 34 | void cancel() override; |
| 35 | |
| 36 | unsigned offset; |
| 37 | |
| 38 | private: |
| 39 | SimpleHexRequestUser& user; |
| 40 | }; |
| 41 | |
| 42 | #endif // SIMPLEHEXREQUEST_H |