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

TObjectSharedMemory.cc

解説を見る。
00001 // =====================================================================
00002 //  $Id: TObjectSharedMemory.cc,v 1.4 2004/03/07 10:30:32 goiwai Exp $
00003 //  $Name: CLDAQ-1-14-03 $
00004 //  $Log: TObjectSharedMemory.cc,v $
00005 //  Revision 1.4  2004/03/07 10:30:32  goiwai
00006 //  ROOTに組みこむためのおまじないマクロを埋めこみました。
00007 //  全てにおいて完全に動作するわけではありません。
00008 //
00009 //  Revision 1.3  2003/10/06 17:02:42  goiwai
00010 //  *** empty log message ***
00011 //
00012 //  Revision 1.2  2003/07/30 16:19:31  goiwai
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 // When output object destruct, invoked Dettach(), Remove() functions.
00050 {
00051   theObjectSharedMemory = 0;
00052 }
00053 
00054 #ifdef __CLDAQ_ROOT_DLL
00055     ClassImp(TObjectSharedMemory)
00056 #endif


CLDAQ - a Class Library for DataAcQuisition (Version 1.14.3)
Go IWAI -- goiwai at users.sourceforge.jp