メインページ   モジュール   クラス階層   アルファベット順一覧   構成   ファイル一覧   構成メンバ   ファイルメンバ   関連ページ  

TObjectSharedMemory.hh

解説を見る。
00001 // =====================================================================
00002 //  $Id: TObjectSharedMemory.hh,v 1.1.1.1 2003/06/27 02:56:41 goiwai Exp $
00003 //  $Name: CLDAQ-1-06-00 $
00004 // =====================================================================
00005 #ifndef __TOBJECTSHAREDMEMORY_HH
00006 #define __TOBJECTSHAREDMEMORY_HH
00007 
00008 #include "Tglobals.h"
00009 
00010 //OutputしてるときはInputさせない
00011 class TObjectSharedMemory
00012 {
00013 
00014   protected:
00015     static TObjectSharedMemory* theObjectSharedMemory;
00016 
00017   public:
00018     enum { tDefaultMaxEvent = 100 };
00019     enum { tDefaultMemorySize = 1024 * 1024 };
00020     
00021   protected:
00022     Tint theSharedMemoryID;
00023     Tint theMemorySize;
00024     Tint theMaxEvent;
00025     Tint theCurrentPositionOfMemorySpace;
00026     Tbool* theReadable;
00027     Tvoid* theBaseAddress;
00028     Tvoid* theAddress;
00029 
00030   public:
00031     TObjectSharedMemory( Tint memsize, Tint maxevt );
00032 
00033   protected:
00034     virtual ~TObjectSharedMemory();
00035 
00036   public:
00037     Tvoid* Attach( const Tvoid* shmaddr = 0, Tint shmflg = 0 ) const;
00038     Tint Detach();
00039     Tint Remove( struct shmid_ds* buf = 0 );
00040 
00041   public:
00042     Tint GetSharedMemoryID() const;
00043     Tint GetMemorySize() const;
00044     Tvoid* GetBaseAddress() const;
00045     Tvoid* GetAddress() const;
00046     Tint GetMaxEvent() const;
00047     Tint GetCurrentPositionOfMemorySpace() const;
00048     Tvoid SetMaxEvent( Tint maxevt );
00049     Tvoid SetCurrentPositionOfMemorySpace( Tint pos );
00050     Tvoid SetSharedMemoryID( Tint memid );
00051     Tvoid SetMemorySize( Tint memsize );
00052     Tvoid SetAddress( Tvoid* shmaddr );
00053     Tbool IsReadable() const;
00054     Tvoid SetReadable( Tbool permission );
00055 
00056   public:
00057     static TObjectSharedMemory* GetObjectSharedMemory();
00058 
00059 };
00060 
00061 inline TObjectSharedMemory* TObjectSharedMemory::GetObjectSharedMemory()
00062 {
00063   return( theObjectSharedMemory );
00064 }
00065 
00066 inline Tint TObjectSharedMemory::GetMaxEvent() const
00067 {
00068   return( theMaxEvent );
00069 }
00070 
00071 inline Tint TObjectSharedMemory::GetCurrentPositionOfMemorySpace() const
00072 {
00073   return( theCurrentPositionOfMemorySpace );
00074 }
00075 
00076 inline Tvoid TObjectSharedMemory::SetMaxEvent( Tint maxevt )
00077 {
00078   theMaxEvent = maxevt;
00079   return;
00080 }
00081 
00082 inline Tvoid TObjectSharedMemory::SetCurrentPositionOfMemorySpace( Tint pos )
00083 {
00084   theCurrentPositionOfMemorySpace = pos;
00085   return;
00086 }
00087 
00088 inline Tint TObjectSharedMemory::GetSharedMemoryID() const
00089 {
00090   return( theSharedMemoryID );
00091 }
00092 
00093 inline Tint TObjectSharedMemory::GetMemorySize() const
00094 {
00095   return( theMemorySize );
00096 }
00097 
00098 inline Tvoid* TObjectSharedMemory::GetBaseAddress() const
00099 {
00100   return( theBaseAddress );
00101 }
00102 
00103 inline Tvoid* TObjectSharedMemory::GetAddress() const
00104 {
00105   return( theAddress );
00106 }
00107 
00108 inline Tvoid TObjectSharedMemory::SetSharedMemoryID( Tint memid )
00109 {
00110   theSharedMemoryID = memid;
00111   return;
00112 }
00113 
00114 inline Tvoid TObjectSharedMemory::SetMemorySize( Tint memsize )
00115 {
00116   theMemorySize = memsize;
00117   return;
00118 }
00119 
00120 inline Tvoid TObjectSharedMemory::SetAddress( Tvoid* shmaddr )
00121 {
00122   theAddress = shmaddr;
00123   return;
00124 }
00125 
00126 inline Tvoid* TObjectSharedMemory::Attach( const Tvoid* shmaddr, Tint shmflg ) const
00127 {
00128   return( shmat( theSharedMemoryID, shmaddr, shmflg ) );
00129 }
00130 
00131 inline Tint TObjectSharedMemory::Detach()
00132 {
00133   return( shmdt( (Tvoid*)theReadable ) );
00134 }
00135 
00136 inline Tint TObjectSharedMemory::Remove( struct shmid_ds* buf )
00137 {
00138   return( shmctl( theSharedMemoryID, IPC_RMID, buf ) );
00139 }
00140 
00141 inline Tbool TObjectSharedMemory::IsReadable() const
00142 {
00143   return( *theReadable );
00144 }
00145 
00146 inline Tvoid TObjectSharedMemory::SetReadable( Tbool permission )
00147 {
00148   *theReadable = permission;
00149   return;
00150 }
00151 
00152 #endif

CLDAQ - a Class Library for Data AcQuisition (Version 1.6.0)
Go IWAI <goiwai@users.sourceforge.jp>