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

TOutputObjectSharedMemory.cc

解説を見る。
00001 // =====================================================================
00002 //  $Id: TOutputObjectSharedMemory.cc,v 1.7 2004/06/24 15:15:25 goiwai Exp $
00003 //  $Name: CLDAQ-1-14-03 $
00004 //  $Log: TOutputObjectSharedMemory.cc,v $
00005 //  Revision 1.7  2004/06/24 15:15:25  goiwai
00006 //  たくさんの変更
00007 //  Tcout,Tcerr,Tlogをバッファ経由にした。
00008 //  何個かexternした。Tlog,Tcout,Tcerr,Tinfo...Tcritなど出力関係。
00009 //
00010 //  Revision 1.6  2004/03/07 16:52:34  goiwai
00011 //  __CLDAQ_ZLIB_USEプロプロセッサの位置をちょっとずらしただけです。
00012 //
00013 //  Revision 1.5  2004/03/07 10:30:32  goiwai
00014 //  ROOTに組みこむためのおまじないマクロを埋めこみました。
00015 //  全てにおいて完全に動作するわけではありません。
00016 //
00017 //  Revision 1.4  2003/12/06 10:56:19  goiwai
00018 //  フィルタ関連の修整と Read(),Write()の戻り値の修整です.
00019 //  Read()もWrite()も処理したレコードサイズを返します.
00020 //  フィルタがある場合も同様です.
00021 //  それぞれのストリームのDataSizeの扱いですが,これは扱ったレコードサイズ
00022 //  でなく扱ったファイルやソケットなどのサイズになります.レコードサイズと
00023 //  一致するとは限りません.
00024 //
00025 //  Revision 1.3  2003/10/06 17:02:42  goiwai
00026 //  *** empty log message ***
00027 //
00028 //  Revision 1.2  2003/07/30 16:19:31  goiwai
00029 //  ファイルにコミットログをつけることにしました.
00030 //
00031 // =====================================================================
00032 #include "TOutputObjectSharedMemory.hh"
00033 #include "TStreamableObject.hh"
00034 #include "TOutputObjectFilter.hh"
00035 
00036 TOutputObjectSharedMemory::TOutputObjectSharedMemory( Tint memsize, Tint maxevt )
00037   : TObjectSharedMemory( memsize, maxevt ),
00038     TOutputObjectStream( tSharedMemoryStream )
00039 {
00040   signal( SIGINT, TOutputObjectSharedMemory::catchSignal );
00041   signal( SIGSEGV, TOutputObjectSharedMemory::catchSignal );
00042 }
00043 
00044 TOutputObjectSharedMemory::TOutputObjectSharedMemory( TOutputObjectFilter* filter, Tint memsize, Tint maxevt )
00045   : TObjectSharedMemory( memsize, maxevt ),
00046     TOutputObjectStream( filter, tSharedMemoryStream )
00047 {
00048   signal( SIGINT, TOutputObjectSharedMemory::catchSignal );
00049   signal( SIGSEGV, TOutputObjectSharedMemory::catchSignal );
00050 }
00051 
00052 TOutputObjectSharedMemory::~TOutputObjectSharedMemory()
00053 {
00054   Detach();
00055   Remove();
00056 }
00057 
00058 Tint TOutputObjectSharedMemory::Write( TStreamableObject& object )
00059 {
00060   if ( HasFilter() ) {
00061     return theObjectFilter -> Filtering( object, this );
00062   }
00063 
00064   SetReadable( Tfalse );
00065 
00066   theLastDataSize = theDataSize;
00067   theDataSize = 0;
00068 
00069   if ( theCurrentPositionOfMemorySpace == theMaxEvent - 1 ) {
00070     // return to top
00071     theAddress = theBaseAddress;
00072     theCurrentPositionOfMemorySpace = 0;
00073   }
00074     
00075   theDataSize = object.Record( this );
00076 
00077   if ( theDataSize > 0 ) {
00078     theCurrentPositionOfMemorySpace ++;
00079   }
00080 
00081   //( (Tchar*)theAddress ) += theDataSize;
00082 
00083   SetReadable( Ttrue );
00084   theTotalDataSize += theDataSize;
00085   return theDataSize;
00086 }
00087 
00088 Tvoid TOutputObjectSharedMemory::catchSignal( Tint sigid )
00089 {
00090   Tstring head = "TOutputObjectSharedMemory::catchSignal: ";
00091   Tcout << head << "get signal " << sigid << "." << Tendl;
00092   Tcout << head << "detach/remove IPC resources." << Tendl;
00093   TObjectSharedMemory::GetObjectSharedMemory() -> Detach();
00094   TObjectSharedMemory::GetObjectSharedMemory() -> Remove();
00095 
00096 //   TRunManager* manager = TRunManager::GetRunManager();
00097 //   if ( manager ) {
00098 //     Tcout << head << "terminate RunManager by force." << Tendl;
00099 //     manager -> GetUserInterface() -> ExecuteCommand( "exit" );
00100 //     delete manager;
00101 //   }
00102 
00103   Tcout << head << "terminate by force." << Tendl;
00104   exit( EXIT_SUCCESS );
00105 
00106   return;
00107 }
00108 
00109 #ifdef __CLDAQ_ROOT_DLL
00110     ClassImp(TOutputObjectSharedMemory)
00111 #endif


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