Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

CommunShMem Class Reference

Shared memory communication. More...

#include <communShMem.h>

Inheritance diagram for CommunShMem::

Commun List of all members.

Public Methods

 CommunShMem (const String &shmemId, int size)
 Constructor. More...

virtual ~CommunShMem ()
 Destructor.

virtual int initialize ()
 Initialization of communication. More...

virtual Communoperator>> (Buffer &b)
 Read data. More...

virtual Communoperator<< (const Buffer &b)
 Write data. More...

virtual int isReady ()
 Communication channel ready for reading. More...


Private Methods

int checkClient ()
 Check client. More...


Private Attributes

Semaphore _sem1
 semaphore.

Semaphore _sem2
 semaphore.

SharedMemory _shmem
 shared memory.

pid_t _pid
 client process ID.


Detailed Description

Shared memory communication.

This class implements shared memory communication and offers the user of this class the standard interface of Commun class. Implementation is system dependent (so it is different on WIN32 and UNIX systems). It should be faster then using sockets.

See also:
CommunSocket, Commun
Author:
Marek Przeczek

Definition at line 55 of file communShMem.h.


Constructor & Destructor Documentation

CommunShMem::CommunShMem const String   shmemId,
int    size
 

Constructor.

Creates shared memory block and needed semaphores for communication. If semaphores or shared memory block already exist, they are used.

Parameters:
shmemId  shared memory identifier (3 characters long only)
size  shared memory size

Definition at line 37 of file communShMem.cpp.


Member Function Documentation

int CommunShMem::checkClient   [private]
 

Check client.

This routine checks if the client is still connected and is alive.

Returns:
1 (ok); 0 (failed, not connected)

Definition at line 179 of file communShMem.cpp.

Referenced by operator<<(), and operator>>().

int CommunShMem::initialize   [virtual]
 

Initialization of communication.

This method only waits for first unlocking of the semaphore used during communication. In this way it recognizes that communication has started.

Returns:
0 (failed); 1 (ok, initialized)

Reimplemented from Commun.

Definition at line 155 of file communShMem.cpp.

int CommunShMem::isReady   [virtual]
 

Communication channel ready for reading.

This method returns TRUE, if there are data in communication channel and should be read from it.

Returns:
0 (nothing); 1 (data in channel)

Reimplemented from Commun.

Definition at line 148 of file communShMem.cpp.

Commun & CommunShMem::operator<< const Buffer   b [virtual]
 

Write data.

This operator is used to write data from buffer to communication channel (shmem).

Parameters:
b  reference to Buffer object
Returns:
reference to this Commun object
See also:
operator>>()

Reimplemented from Commun.

Definition at line 102 of file communShMem.cpp.

Commun & CommunShMem::operator>> Buffer   b [virtual]
 

Read data.

This operator is used to read data from communication channel (shmem) to buffer.

Parameters:
b  reference to Buffer object
Returns:
reference to this Commun object
See also:
operator<<()

Reimplemented from Commun.

Definition at line 56 of file communShMem.cpp.


The documentation for this class was generated from the following files:
Generated on Mon Jan 28 14:53:28 2002 for Java Profiler Dynamic Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001