00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TObjectSharedMemory.hh"
00017
00018 TObjectSharedMemory* TObjectSharedMemory::theObjectSharedMemory = 0;
00019
00020 TObjectSharedMemory::TObjectSharedMemory( Tint memsize, Tint maxevt )
00021 : theSharedMemoryID( -1 ), theMemorySize( memsize ),
00022 theMaxEvent( maxevt ), theCurrentPositionOfMemorySpace( 0 ),
00023 theReadable( 0 ), theBaseAddress( 0 ), theAddress( 0 )
00024 {
00025 Tstring head = "TObjectSharedMemory::TObjectSharedMemory: ";
00026
00027 theSharedMemoryID =
00028 shmget( ftok( getenv( "HOME" ), Tkey ), theMemorySize, 0666 | IPC_CREAT );
00029 if ( theSharedMemoryID == -1 ) {
00030 Tcerr << head << "failed getting shared memory ID." << Tendl;
00031 exit( -errno );
00032 }
00033 Tvoid* voidbuf = Attach();
00034 if ( voidbuf == (Tvoid*)-1 ) {
00035 Tcerr << head << "failed attach." << Tendl;
00036 exit( -errno );
00037 }
00038
00039 theReadable = (Tbool*)voidbuf;
00040 SetReadable( Tfalse );
00041
00042 ( (Tbool*)voidbuf ) ++;
00043 theBaseAddress = voidbuf;
00044 theAddress = theBaseAddress;
00045 theObjectSharedMemory = this;
00046 }
00047
00048 TObjectSharedMemory::~TObjectSharedMemory()
00049
00050 {
00051 theObjectSharedMemory = 0;
00052 }
00053
00054 #ifdef __CLDAQ_ROOT_DLL
00055 ClassImp(TObjectSharedMemory)
00056 #endif