ApparatusFramework::ClientNamedPipe Class Reference
[Simulation Services]

#include <SimulationServices/current/include/ClientNamedPipe.h>

List of all members.

Public Types

enum  PipeState {
  INVALID = 0, EXISTENT, STARTED, STARTFAILURE,
  CREATED, CREATEFAILURE, CONNECTED, CONNECTFAILURE,
  BROKEN
}

Public Member Functions

 ClientNamedPipe (const std::string pipeName)
virtual ~ClientNamedPipe ()
virtual void createPipe ()
void terminateListenerThread ()
DWORD writeBytes (LPCVOID data, const int lgth)
DWORD readBytes (LPVOID data, const int lgth)
DWORD readBytes (LPVOID data, const int lgth, DWORD &timeout)
PipeState getPipeState ()
virtual void runThread ()=0

Protected Member Functions

void start ()
virtual void stateHasChanged (PipeState newState)

Protected Attributes

OVERLAPPED m_overlappedRead
OVERLAPPED m_overlappedWrite
HANDLE m_hPipe
HANDLE m_hThread
DWORD m_threadID
std::string m_pipeName
PipeState m_pipeState

Detailed Description

The client named pipe implements the client side of a named pipe. It opens a client pipe and creates the structures needed for overlapped operations. The write and read operations are protected to avoid a deadlock of our devices when we are simulating them.

Definition at line 91 of file ClientNamedPipe.h.


Member Enumeration Documentation

pipeStates All states that a client pipe can have

Enumerator:
INVALID 

Invalid state, this is used for initialization of state variables

EXISTENT 

The variable has been constructed but no pipe has been created yet

STARTED 

The thread has been started

STARTFAILURE 

The thread could not be started

CREATED 

The pipe has been created but is not connected

CREATEFAILURE 

The pipe could not be created

CONNECTED 

The pipe was successfully connected

CONNECTFAILURE 

The pipe could not be connected

BROKEN 

The pipe is broken, server disconnected/closed pipe

Definition at line 108 of file ClientNamedPipe.h.


Constructor & Destructor Documentation

ApparatusFramework::ClientNamedPipe::ClientNamedPipe ( const std::string  pipeName  ) 

constructors, destructors Constructs a new client named pipe object.

Parameters:
pipeName name of the pipe to create.
virtual ApparatusFramework::ClientNamedPipe::~ClientNamedPipe (  )  [virtual]

Destroys a client named pipe object and releases all the associated resources.


Member Function Documentation

virtual void ApparatusFramework::ClientNamedPipe::createPipe (  )  [virtual]

modifiers Creates the pipe.

PipeState ApparatusFramework::ClientNamedPipe::getPipeState (  ) 

querries Returns the state of the pipe

Returns:
The current pipe state. See PipeState
DWORD ApparatusFramework::ClientNamedPipe::readBytes ( LPVOID  data,
const int  lgth,
DWORD &  timeout 
)

Reads from the named pipe to the given byte stream.

Parameters:
data byte stream to write to the named pipe
lgth length of the read data in bytes.
timeout timeout in ms.
Returns:
The number of read bytes.
DWORD ApparatusFramework::ClientNamedPipe::readBytes ( LPVOID  data,
const int  lgth 
)

Reads from the named pipe to the given byte stream.

Parameters:
data byte stream to write to the named pipe
lgth length of the read data in bytes.
Returns:
The number of read bytes.
virtual void ApparatusFramework::ClientNamedPipe::runThread (  )  [pure virtual]

tasking This method is the body of the thread waiting on data on the data. This method must never call any methods of the kernels services. It is used to emulate the interrupt routines on the target hardware. The only allowed kernel services call is send message to task.

void ApparatusFramework::ClientNamedPipe::start (  )  [protected]

tasking Must be called from the constructor to create the thread. This mechanism is necessary to allow the correct initialization of the virtual table of the class before starting the thread.

virtual void ApparatusFramework::ClientNamedPipe::stateHasChanged ( PipeState  newState  )  [protected, virtual]

Has to be overridden by the subclass and is called each time the state of the pipe changes.

Parameters:
newState The new pipe state. See PipeState
void ApparatusFramework::ClientNamedPipe::terminateListenerThread (  ) 

Kills the reader thread of the pipe object.

DWORD ApparatusFramework::ClientNamedPipe::writeBytes ( LPCVOID  data,
const int  lgth 
)

Writes the given byte stream to the named pipe.

Parameters:
data byte stream to write to the named pipe.
lgth length of the data to be written in bytes.
Returns:
The number of written bytes.

Member Data Documentation

Handle to the named pipe created using the windows NT system calls.

Definition at line 193 of file ClientNamedPipe.h.

Handle to the thread used to read data from the named pipe.

Definition at line 198 of file ClientNamedPipe.h.

protocols fields Overlapped structure to synchronize asynchronous read operations on the named pipe.

Definition at line 183 of file ClientNamedPipe.h.

Overlapped structure to synchronize asynchronous write operations on the named pipe.

Definition at line 188 of file ClientNamedPipe.h.

The name of pipe.

Definition at line 206 of file ClientNamedPipe.h.

The state that the pipe is currently in

Definition at line 210 of file ClientNamedPipe.h.

Unique system wide thread identifier of our thread.

Definition at line 202 of file ClientNamedPipe.h.

© 2004-2010 bbv Software Services AG / Apparatus Services