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

SV_Shared_Memory.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //==========================================================================
00004 /**
00005  *  @file    SV_Shared_Memory.h
00006  *
00007  *  $Id: SV_Shared_Memory.h,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //==========================================================================
00012 
00013 #ifndef ACE_SV_SHARED_MEMORY_H
00014 #define ACE_SV_SHARED_MEMORY_H
00015 
00016 #include "ace/pre.h"
00017 
00018 #include "ace/ACE_export.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "ace/OS.h"
00025 
00026 /**
00027  * @class ACE_SV_Shared_Memory
00028  *
00029  * @brief This is a wrapper for System V shared memory.
00030  */
00031 class ACE_Export ACE_SV_Shared_Memory
00032 {
00033 public:
00034   enum
00035   {
00036     ACE_CREATE = IPC_CREAT,
00037     ACE_OPEN   = 0
00038   };
00039 
00040   // = Initialization and termination methods.
00041   ACE_SV_Shared_Memory (void);
00042   ACE_SV_Shared_Memory (key_t external_id,
00043                         size_t size,
00044                         int create,
00045                         int perms = ACE_DEFAULT_FILE_PERMS,
00046                         void *virtual_addr = 0,
00047                         int flags = 0);
00048 
00049   ACE_SV_Shared_Memory (ACE_HANDLE internal_id,
00050                         int flags = 0);
00051 
00052   int  open (key_t external_id,
00053              size_t size,
00054              int create = ACE_SV_Shared_Memory::ACE_OPEN,
00055              int perms = ACE_DEFAULT_FILE_PERMS);
00056 
00057   int  open_and_attach (key_t external_id,
00058                         size_t size,
00059                         int create = ACE_SV_Shared_Memory::ACE_OPEN,
00060                         int perms = ACE_DEFAULT_FILE_PERMS,
00061                         void *virtual_addr = 0,
00062                         int flags = 0);
00063 
00064   /// Attach this shared memory segment.
00065   int  attach (void *virtual_addr = 0,
00066                int flags =0);
00067 
00068   /// Detach this shared memory segment.
00069   int  detach (void);
00070 
00071   /// Remove this shared memory segment.
00072   int  remove (void);
00073 
00074   /// Forward to underlying System V <shmctl>.
00075   int  control (int cmd, void *buf);
00076 
00077   // = Segment-related info.
00078   void *get_segment_ptr (void) const;
00079   size_t get_segment_size (void) const;
00080 
00081   /// Return the ID of the shared memory segment (i.e., an ACE_HANDLE).
00082   ACE_HANDLE get_id (void) const;
00083 
00084   /// Dump the state of an object.
00085   void dump (void) const;
00086 
00087   /// Declare the dynamic allocation hooks.
00088   ACE_ALLOC_HOOK_DECLARE;
00089 
00090 protected:
00091   enum
00092   {
00093     /// Most restrictive alignment.
00094     ALIGN_WORDB = 8
00095   };
00096 
00097   /// Internal identifier.
00098   ACE_HANDLE internal_id_;
00099 
00100   /// Size of the mapped segment.
00101   size_t size_;
00102 
00103   /// Pointer to the beginning of the segment.
00104   void *segment_ptr_;
00105 
00106   /// Round up to an appropriate page size.
00107   size_t round_up (size_t len);
00108 };
00109 
00110 #if defined (__ACE_INLINE__)
00111 #include "ace/SV_Shared_Memory.i"
00112 #endif /* __ACE_INLINE__ */
00113 
00114 #include "ace/post.h"
00115 
00116 #endif /* ACE_SV_SHARED_MEMORY_H */

Generated on Mon Jun 16 11:21:33 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002