Design Pattern Examples
Overview of object-oriented design patterns
Adapter_FrontEndClass.h
Go to the documentation of this file.
1
5
6#pragma once
7#ifndef __ADAPTER_H__
8#define __ADAPTER_H__
9
10#include <exception>
11#include <string>
12#include <vector>
13#include <stdint.h>
14
16{
17
18 // Represents an array of 8-bit values or bytes.
19 typedef std::vector<uint8_t> ByteArray;
20
21
26 class DataReaderWriterInitException : public std::exception
27 {
28 private:
29 std::string message;
30 public:
32 : message(msg)
33 {
34 }
35
39 const char* what()
40 {
41 return message.c_str();
42 }
43 };
44
45
50 class DataReaderWriterException : public std::exception
51 {
52 private:
53 std::string message;
54 public:
56 : message(msg)
57 {
58 }
59
63 const char *what()
64 {
65 return message.c_str();
66 }
67 };
68
74 {
75 public:
81 {
85 };
86
87 private:
91
92 private:
101
102 public:
109
114
119 uint32_t GetMemoryBlockByteSize();
120
132 ByteArray Read(int byteOffset, uint32_t maxBytes);
133
146 void Write(int byteOffset, const ByteArray& data, uint32_t maxBytes);
147
158 std::string BufferToString(const ByteArray& data, uint32_t maxBytes,
159 int indent);
160 };
161
162} // end namespace
163
164#endif // __ADAPTER_H__
Represents an error that occurred when reading or writing data in the Data reader/writer.
const char * what()
Override exception::what() to return the message we are tracking.
Represents a data reader/writer to a caller.
uint32_t GetMemoryBlockByteSize()
Retrieve the size of the currently opened memory block in bytes.
std::string BufferToString(const ByteArray &data, uint32_t maxBytes, int indent)
Convert the specified data up to the specified number of bytes into a string by performing a "hex dum...
void Write(int byteOffset, const ByteArray &data, uint32_t maxBytes)
Write a specified number of bytes.
const char * _GetBlockNameForBlockNumber(DataReaderWriter::MemoryBlockNumber blockNumber)
Given a block number, retrieve the corresponding block name.
ByteArray Read(int byteOffset, uint32_t maxBytes)
Read a specified number of bytes.
MemoryBlockNumber
Represents the memory blocks that can be accessed. Hides how memory blocks are actually identified.
Represents an error that occurred during initialization or shut down of the Data reader/writer.
const char * what()
Override exception::what() to return the message we are tracking.
The namespace containing all Design Pattern Examples implemented in C++.
std::vector< uint8_t > ByteArray