ApparatusFramework::ServerNamedPipe Class Reference
[Simulation Services]

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

List of all members.

Public Types

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

Public Member Functions

 ServerNamedPipe (const std::string pipeName)
virtual ~ServerNamedPipe ()
virtual void createPipe ()
virtual void reopenPipe ()
void terminateListenerThread ()
DWORD writeBytes (LPCVOID data, const int lgth)
DWORD readBytes (LPVOID data, const int lgth)
PipeState getPipeState ()
virtual void runThread ()=0
void start ()
virtual void stateHasChanged (PipeState newState)
void waitForClient ()

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 server named pipe implements the server side of a named pipe. It opens a server 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 59 of file ServerNamedPipe.h.


Member Enumeration Documentation

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

WAITING 

The pipe server waits for a client to connect

Definition at line 75 of file ServerNamedPipe.h.


Constructor & Destructor Documentation

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

constructors, destructors Constructs a new server named pipe object.

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

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


Member Function Documentation

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

Creates the pipe.

PipeState ApparatusFramework::ServerNamedPipe::getPipeState (  ) 

querries Returns the state of the pipe

DWORD ApparatusFramework::ServerNamedPipe::readBytes ( LPVOID  data,
const int  lgth 
)

Reads from the named pipe to the given byte stream (blocking).

Parameters:
data byte stream to read to the named pipe
lgth length of the read data in bytes.
Returns:
Returns the number of read bytes.
virtual void ApparatusFramework::ServerNamedPipe::reopenPipe (  )  [virtual]

Reopens the pipe.

virtual void ApparatusFramework::ServerNamedPipe::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::ServerNamedPipe::start (  ) 

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::ServerNamedPipe::stateHasChanged ( PipeState  newState  )  [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
void ApparatusFramework::ServerNamedPipe::terminateListenerThread (  ) 

Kills the reader thread of the pipe object.

void ApparatusFramework::ServerNamedPipe::waitForClient (  ) 

wait for connection. Waits until a client connects. This function blocks the thread.

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

modifiers 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:
Returns the number of written bytes.

Member Data Documentation

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

Definition at line 161 of file ServerNamedPipe.h.

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

Definition at line 165 of file ServerNamedPipe.h.

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

Definition at line 151 of file ServerNamedPipe.h.

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

Definition at line 156 of file ServerNamedPipe.h.

The pipes name.

Definition at line 173 of file ServerNamedPipe.h.

The state that the pipe is currently in

Definition at line 177 of file ServerNamedPipe.h.

Unique system wide thread identifier of our thread.

Definition at line 169 of file ServerNamedPipe.h.

© 2004-2010 bbv Software Services AG / Apparatus Services