Design Pattern Examples
Overview of object-oriented design patterns
Adapter_BackEndFunctions.cs
Go to the documentation of this file.
1
10
11using System;
12using System.Collections.Generic;
13using System.Linq;
14using System.Runtime.InteropServices;
15using System.Text;
16using System.Threading.Tasks;
17
19{
24 internal static class DataReadWriteFunctions
25 {
29 public const int DDR_MAX_OFFSET = 32;
30
31
37 public enum DDR_ErrorCode
38 {
46 }
47
53 public const string BLOCK_NAME_0 = "gorp";
59 public const string BLOCK_NAME_1 = "baba";
65 public const string BLOCK_NAME_2 = "yaga";
66
67
68 private const string dll = "Adapter_BackEnd";
69
80 [DllImport(dll, CallingConvention = CallingConvention.Cdecl,
81 ExactSpelling = true, CharSet = CharSet.Ansi)]
82 internal static extern
83 DDR_ErrorCode DDR_OpenMemoryBlock(string blockName, out Int32 dataHandle);
84
93 [DllImport(dll, CallingConvention = CallingConvention.Cdecl,
94 ExactSpelling = true, CharSet = CharSet.Ansi)]
95 internal static extern
97
109 [DllImport(dll, CallingConvention = CallingConvention.Cdecl,
110 ExactSpelling = true, CharSet = CharSet.Ansi)]
111 internal static extern
112 DDR_ErrorCode DDR_GetMemorySize(Int32 dataHandle, out Int32 memorySizeInChunks);
113
125 [DllImport(dll, CallingConvention = CallingConvention.Cdecl,
126 ExactSpelling = true, CharSet = CharSet.Ansi)]
127 internal static extern
128 DDR_ErrorCode DDR_GetDataChunk(Int32 dataHandle, Int32 chunkOffset, out UInt32 value);
129
141 [DllImport(dll, CallingConvention = CallingConvention.Cdecl,
142 ExactSpelling = true, CharSet = CharSet.Ansi)]
143 internal static extern
144 DDR_ErrorCode DDR_SetDataChunk(Int32 dataHandle, Int32 chunkOffset, UInt32 value);
145 }
146}
Represents some P/Invoke functions for accessing a named blocks of memory to read/write data in the A...
const string BLOCK_NAME_0
Define the name of BLOCK 0 that can be accessed in the Adapter_BackEnd.dll. In C#'s P/Invoke,...
DDR_ErrorCode
Represents the possible errors that can be returned from the memory block access functions....
@ DDR_ErrorCode_Invalid_Offset
The given offset is out of bounds.
@ DDR_ErrorCode_Invalid_Block_Name
The given name is not a recognized memory block name.
@ DDR_ErrorCode_Null_Argument
The block name pointer or return handle pointer argument is NULL.
@ DDR_ErrorCode_Invalid_Handle
The handle argument does not correspond to a valid open memory block.
@ DDR_ErrorCode_Block_Already_Opened
Memory block is already open and cannot be opened again.
@ DDR_ErrorCode_Block_Not_Opened
Memory block is closed and cannot be accessed.
static DDR_ErrorCode DDR_GetMemorySize(Int32 dataHandle, out Int32 memorySizeInChunks)
P/Invoke wrapper that retrieves the number of chunks in the memory block indicated by the handle to t...
static DDR_ErrorCode DDR_OpenMemoryBlock(string blockName, out Int32 dataHandle)
P/Invoke wrapper that opens access to a memory block for exclusive use, given the name of the memory ...
const int DDR_MAX_OFFSET
All offsets must from 0 to 1 less than this value.
const string BLOCK_NAME_2
Define the name of BLOCK 2 that can be accessed in the Adapter_BackEnd.dll. In C#'s P/Invoke,...
static DDR_ErrorCode DDR_SetDataChunk(Int32 dataHandle, Int32 chunkOffset, UInt32 value)
P/Invoke wrapper that writes a single 32-bit value to the given offset in the memory block indicated ...
const string BLOCK_NAME_1
Define the name of BLOCK 1 that can be accessed in the Adapter_BackEnd.dll. In C#'s P/Invoke,...
static DDR_ErrorCode DDR_GetDataChunk(Int32 dataHandle, Int32 chunkOffset, out UInt32 value)
P/Invoke wrapper that reads a single 32-bit value at the given offset in the memory block indicated b...
static DDR_ErrorCode DDR_CloseMemoryBlock(Int32 dataHandle)
P/Invoke wrapper that closes access to a previously opened memory block, thus releasing it for others...
The namespace containing all Design Pattern Examples implemented in C#.