Design Pattern Examples
Overview of object-oriented design patterns
DataReadWriteFunctions Class Reference

Represents some P/Invoke functions for accessing a named blocks of memory to read/write data in the Adapter_BackEnd.dll. More...

Collaboration diagram for DataReadWriteFunctions:
Collaboration graph

Public Types

enum  DDR_ErrorCode {
  DDR_ErrorCode_Success = 0 , DDR_ErrorCode_Block_Already_Opened = 1 , DDR_ErrorCode_Block_Not_Opened = 2 , DDR_ErrorCode_Invalid_Block_Name = 3 ,
  DDR_ErrorCode_Invalid_Handle = 4 , DDR_ErrorCode_Invalid_Offset = 5 , DDR_ErrorCode_Null_Argument = 6
}
 Represents the possible errors that can be returned from the memory block access functions. It is not possible to use C#'s P/Invoke to get these values so the enumeration needs to be duplicated here. More...
 

Static Public Attributes

const int DDR_MAX_OFFSET = 32
 All offsets must from 0 to 1 less than this value.
 
const string BLOCK_NAME_0 = "gorp"
 Define the name of BLOCK 0 that can be accessed in the Adapter_BackEnd.dll. In C#'s P/Invoke, it is not possible to map a string data through P/Invoke, only methods.
 
const string BLOCK_NAME_1 = "baba"
 Define the name of BLOCK 1 that can be accessed in the Adapter_BackEnd.dll. In C#'s P/Invoke, it is not possible to map a string data through P/Invoke, only methods.
 
const string BLOCK_NAME_2 = "yaga"
 Define the name of BLOCK 2 that can be accessed in the Adapter_BackEnd.dll. In C#'s P/Invoke, it is not possible to map a string data through P/Invoke, only methods.
 

Package Functions

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 block.
 
static DDR_ErrorCode DDR_CloseMemoryBlock (Int32 dataHandle)
 P/Invoke wrapper that closes access to a previously opened memory block, thus releasing it for others to open.
 
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 the successfully opened memory block.
 
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 by the specified handle.
 
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 by the specified handle.
 

Static Private Attributes

const string dll = "Adapter_BackEnd"
 

Detailed Description

Represents some P/Invoke functions for accessing a named blocks of memory to read/write data in the Adapter_BackEnd.dll.

Definition at line 24 of file Adapter_BackEndFunctions.cs.

Member Enumeration Documentation

◆ DDR_ErrorCode

Represents the possible errors that can be returned from the memory block access functions. It is not possible to use C#'s P/Invoke to get these values so the enumeration needs to be duplicated here.

Enumerator
DDR_ErrorCode_Success 

Operation succeeded.

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.

DDR_ErrorCode_Invalid_Block_Name 

The given name is not a recognized memory block name.

DDR_ErrorCode_Invalid_Handle 

The handle argument does not correspond to a valid open memory block.

DDR_ErrorCode_Invalid_Offset 

The given offset is out of bounds.

DDR_ErrorCode_Null_Argument 

The block name pointer or return handle pointer argument is NULL.

Definition at line 37 of file Adapter_BackEndFunctions.cs.

Member Function Documentation

◆ DDR_CloseMemoryBlock()

static DDR_ErrorCode DDR_CloseMemoryBlock ( Int32  dataHandle)
package

P/Invoke wrapper that closes access to a previously opened memory block, thus releasing it for others to open.

Parameters
dataHandleHandle to a previously opened memory block as obtained from the DDR_OpenMemoryBlock() function.
Returns
Returns a value from the DDR_ErrorCode enumeration indicating success or failure.

Referenced by DataReaderWriter.Dispose().

◆ DDR_GetDataChunk()

static DDR_ErrorCode DDR_GetDataChunk ( Int32  dataHandle,
Int32  chunkOffset,
out UInt32  value 
)
package

P/Invoke wrapper that reads a single 32-bit value at the given offset in the memory block indicated by the specified handle.

Parameters
dataHandleHandle to a previously opened memory block as obtained from the DDR_OpenMemoryBlock() function.
chunkOffsetOffset into the memory block from which to get the value (range is 0 to DDR_MAX_OFFSET-1).
valueReturns the requested valued.
Returns
Returns a value from the DDR_ErrorCode enumeration indicating success or failure.

◆ DDR_GetMemorySize()

static DDR_ErrorCode DDR_GetMemorySize ( Int32  dataHandle,
out Int32  memorySizeInChunks 
)
package

P/Invoke wrapper that retrieves the number of chunks in the memory block indicated by the handle to the successfully opened memory block.

Parameters
dataHandleHandle to a previously opened memory block as obtained from the DDR_OpenMemoryBlock() function.
memorySizeInChunksReturns the number of 32-bit chunks in the memory block.
Returns
Returns a value from the DDR_ErrorCode enumeration indicating success or failure.

Referenced by DataReaderWriter.DataReaderWriter().

◆ DDR_OpenMemoryBlock()

static DDR_ErrorCode DDR_OpenMemoryBlock ( string  blockName,
out Int32  dataHandle 
)
package

P/Invoke wrapper that opens access to a memory block for exclusive use, given the name of the memory block.

Parameters
blockNameName of the block to access (one of the predefined names, BLOCK_NAME_0, BLOCK_NAME_1, or BLOCK_NAME_2)
dataHandleReturns a handle to be used for accessing the specific memory block.
Returns
Returns a value from the DDR_ErrorCode enumeration indicating success or failure.

Referenced by DataReaderWriter.DataReaderWriter().

◆ DDR_SetDataChunk()

static DDR_ErrorCode DDR_SetDataChunk ( Int32  dataHandle,
Int32  chunkOffset,
UInt32  value 
)
package

P/Invoke wrapper that writes a single 32-bit value to the given offset in the memory block indicated by the specified handle.

Parameters
dataHandleHandle to a previously opened memory block as obtained from the DDR_OpenMemoryBlock() function.
chunkOffsetOffset into the memory block to which to set the value (range is 0 to DDR_MAX_OFFSET-1).
valueThe value to write to the memory block
Returns
Returns a value from the DDR_ErrorCode enumeration indicating success or failure.

Member Data Documentation

◆ BLOCK_NAME_0

const string BLOCK_NAME_0 = "gorp"
static

Define the name of BLOCK 0 that can be accessed in the Adapter_BackEnd.dll. In C#'s P/Invoke, it is not possible to map a string data through P/Invoke, only methods.

Definition at line 53 of file Adapter_BackEndFunctions.cs.

◆ BLOCK_NAME_1

const string BLOCK_NAME_1 = "baba"
static

Define the name of BLOCK 1 that can be accessed in the Adapter_BackEnd.dll. In C#'s P/Invoke, it is not possible to map a string data through P/Invoke, only methods.

Definition at line 59 of file Adapter_BackEndFunctions.cs.

◆ BLOCK_NAME_2

const string BLOCK_NAME_2 = "yaga"
static

Define the name of BLOCK 2 that can be accessed in the Adapter_BackEnd.dll. In C#'s P/Invoke, it is not possible to map a string data through P/Invoke, only methods.

Definition at line 65 of file Adapter_BackEndFunctions.cs.

◆ DDR_MAX_OFFSET

const int DDR_MAX_OFFSET = 32
static

All offsets must from 0 to 1 less than this value.

All offsets must from 0 to 1 less than this value.

Definition at line 29 of file Adapter_BackEndFunctions.cs.

Referenced by DataReaderWriter.Read().

◆ dll

const string dll = "Adapter_BackEnd"
staticprivate

Definition at line 68 of file Adapter_BackEndFunctions.cs.


The documentation for this class was generated from the following file: