MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/driver/MemoryAccessSplitter.hh
2024-06-07 11:12:56 +03:00

60 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 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_ */