MotorControlModuleSDFM_TMS3.../Projects/EFC_Application/UMLibrary/driver/MemoryAccessSplitter.hh

60 lines
1.3 KiB
C++

/*
* MemoryAccessSplitter.hh
*
* Created on: 27 èþë. 2020 ã.
* Author: LeonidTitov
*/
#ifndef UMLIBRARY_DRIVER_MEMORYACCESSSPLITTER_HH_
#define UMLIBRARY_DRIVER_MEMORYACCESSSPLITTER_HH_
#include "../peripheral/IMemoryAccess.hh"
#include <cstddef>
namespace driver {
class MemoryAccessSplitter {
public:
peripheral::IMemoryAccess & piece();
peripheral::IMemoryAccess & remainder();
MemoryAccessSplitter( peripheral::IMemoryAccess & memory, std::size_t piece_size );
private:
class MemoryPiece : public peripheral::IMemoryAccess {
public:
bool read( char * data, std::size_t begin, std::size_t size );
bool write( const char * data, std::size_t begin, std::size_t size );
bool isReadComplete() const;
bool isWriteComplete() const;
std::size_t getCapacity() const;
MemoryPiece( peripheral::IMemoryAccess &, std::size_t size, std::size_t offset );
private:
bool read_query;
bool write_query;
mutable bool read_complite;
mutable bool write_complite;
std::size_t size;
std::size_t offset;
peripheral::IMemoryAccess & memory;
};
MemoryPiece first_part;
MemoryPiece second_part;
};
}
#endif /* UMLIBRARY_DRIVER_MEMORYACCESSSPLITTER_HH_ */