Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

RCS_SHAREDMEM Class Reference

#include <shm.hh>

Collaboration diagram for RCS_SHAREDMEM:

Collaboration graph
[legend]

Public Methods

 RCS_SHAREDMEM (key_t key, size_t size, int oflag, int mode=0)
 ~RCS_SHAREDMEM ()
int nattch ()

Data Fields

int create_errno
void * addr
int delete_totally
int created

Private Methods

 RCS_SHAREDMEM (RCS_SHAREDMEM &shm)

Private Attributes

shm_tshm

Constructor & Destructor Documentation

RCS_SHAREDMEM::RCS_SHAREDMEM key_t    key,
size_t    size,
int    oflag,
int    mode = 0
 

Definition at line 32 of file shm.cc.

00033 {
00034   shm = NULL;
00035   addr = NULL;
00036   delete_totally = 0;
00037   create_errno = 0;
00038   created = 0;
00039 
00040   if (oflag & RCS_SHAREDMEM_CREATE)
00041     {
00042       /* create shared memory */
00043 #if defined(VXWORKS) || defined(_Windows)
00044       shm = rcs_shm_open (key, size, 1);
00045 #else
00046 #ifdef USE_POSIX_SHAREDMEM
00047       shm = rcs_shm_open (key, size, O_CREAT, mode);
00048 #else
00049       shm = rcs_shm_open (key, size, IPC_CREAT, mode);
00050 #endif
00051 #endif
00052       if (shm == NULL)
00053         {
00054           create_errno = errno;
00055           rcs_print_error ("can't create shared memory\n");
00056           return;
00057         }
00058     }
00059   else
00060     {
00061       /* attach to existing shared memory */
00062       shm = rcs_shm_open (key, size, 0);
00063       if (shm == NULL)
00064         {
00065           create_errno = errno;
00066           rcs_print_error
00067             ("can't attach to shared memory-- is master started?\n");
00068           return;
00069         }
00070     }
00071   create_errno = shm->create_errno;
00072   created = shm->created;
00073   /* duplicate the pointer, so users don't
00074      have to dig into shm->addr */
00075   addr = shm->addr;
00076 }

RCS_SHAREDMEM::~RCS_SHAREDMEM  
 

Definition at line 78 of file shm.cc.

00079 {
00080   if (shm == NULL)
00081     {
00082       return;
00083     }
00084   else
00085     {
00086       if (delete_totally)
00087         {
00088           rcs_shm_delete (shm);
00089         }
00090       else
00091         {
00092           rcs_shm_close (shm);
00093         }
00094       shm = NULL;
00095     }
00096 }

RCS_SHAREDMEM::RCS_SHAREDMEM RCS_SHAREDMEM &    shm [private]
 

Definition at line 112 of file shm.cc.

00113 {
00114 }


Member Function Documentation

int RCS_SHAREDMEM::nattch  
 

Definition at line 99 of file shm.cc.

Referenced by SHMEM::close().

00100 {
00101   if (shm == NULL)
00102     {
00103       return -1;
00104     }
00105   else
00106     {
00107       return rcs_shm_nattch (shm);
00108     }
00109 }


Field Documentation

int RCS_SHAREDMEM::create_errno
 

Definition at line 121 of file shm.hh.

Referenced by SHMEM::open().

void* RCS_SHAREDMEM::addr
 

Definition at line 122 of file shm.hh.

Referenced by SHMEM::close(), SHMEM::main_access(), and SHMEM::open().

int RCS_SHAREDMEM::delete_totally
 

Definition at line 123 of file shm.hh.

Referenced by SHMEM::close().

shm_t* RCS_SHAREDMEM::shm [private]
 

Definition at line 126 of file shm.hh.

int RCS_SHAREDMEM::created
 

Definition at line 128 of file shm.hh.

Referenced by SHMEM::open().


The documentation for this class was generated from the following files:
Generated on Sun Dec 2 15:59:09 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001