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

TObjectSharedMemory.hh

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

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