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

TAnalyser.cc

解説を見る。
00001 // =====================================================================
00002 //  $Id: TAnalyser.cc,v 1.4 2004/03/07 10:30:27 goiwai Exp $
00003 //  $Name: CLDAQ-1-14-03 $
00004 //  $Log: TAnalyser.cc,v $
00005 //  Revision 1.4  2004/03/07 10:30:27  goiwai
00006 //  ROOTに組みこむためのおまじないマクロを埋めこみました。
00007 //  全てにおいて完全に動作するわけではありません。
00008 //
00009 //  Revision 1.3  2003/10/06 17:02:36  goiwai
00010 //  *** empty log message ***
00011 //
00012 //  Revision 1.2  2003/07/30 16:17:10  goiwai
00013 //  ファイルにコミットログをつけることにしました.
00014 //
00015 // =====================================================================
00016 #include "TAnalyser.hh"
00017 #include "TExtractor.hh"
00018 #include "TMatrixElement.hh"
00019 #include "TDataElement.hh"
00020 #include "TAnalysisStatus.hh"
00021 #include "TAnalysisManager.hh"
00022 
00023 TAnalyser::TAnalyser( const Tstring& id )
00024   : theAnalyserID( id ), theExtractorList( 0 ), 
00025     theExtractorListCapacity( 1 ), theNumberOfExtractors( 0 ), 
00026     theExtractorIndex( 0 )
00027 {
00028   allocate( theExtractorListCapacity );
00029 }
00030 
00031 TAnalyser::~TAnalyser()
00032 {
00033   Tstring head = "TAnalyser::~TAnalyser: ";
00034   free();
00035   Tcout << head << "analyser " << theAnalyserID << " was deleted." << Tendl;
00036 }
00037 
00038 Tint TAnalyser::AddExtractor( TExtractor* extractor )
00039 {
00040   const Tstring& strbuf = extractor -> GetExtractorID();
00041   for ( Tint i = 0; i < theNumberOfExtractors; i ++ ) {
00042     if ( theExtractorList[ i ] -> GetExtractorID() == strbuf ) {
00043       Tcerr << "TAnalyser::AddExtractor: already exist extractor identified as " << strbuf << "." << Tendl;
00044       return theNumberOfExtractors;
00045     }
00046   }
00047   if ( theNumberOfExtractors >= theExtractorListCapacity )
00048     ResizeExtractorList( theExtractorListCapacity *= 2 );
00049   theExtractorList[ theNumberOfExtractors ] = extractor;
00050   theNumberOfExtractors ++;
00051   theExtractorIndex = theNumberOfExtractors - 1;
00052   
00053   Tstring id = extractor -> GetExtractorID();
00054   Tobject_t objecttype = extractor -> GetMatrixElement().GetObjectType();
00055   TAnalysisStatus status( id, objecttype );
00056   TAnalysisManager* manager = TAnalysisManager::GetAnalysisManager();
00057   ( manager -> GetStatusTable() ).AddAnalysisStatus( status );
00058   ( manager -> GetStatusTable() ).SetStatus( id, tStatusStandby );
00059 
00060   return theNumberOfExtractors;
00061 }
00062 
00063 Tint TAnalyser::RemoveExtractor( Tint index )
00064 {
00065   Tstring head = "TAnalyser::RemoveExtractor: ";
00066   if ( index < 0 || index >= theNumberOfExtractors ) {
00067     Tcerr << head << "invalid index" << Tendl;
00068     return 0;
00069   }
00070   theExtractorIndex = index;
00071   Tstring id = theExtractorList[ theExtractorIndex ] -> GetExtractorID();
00072   delete theExtractorList[ theExtractorIndex ];
00073   Tcout << head << id << " extractor was deleted." << Tendl;
00074   for ( Tint i = theExtractorIndex; i < theNumberOfExtractors; i ++ )
00075     theExtractorList[ i ] = theExtractorList[ i + 1 ];
00076   theNumberOfExtractors --;
00077 
00078   TAnalysisManager* manager = TAnalysisManager::GetAnalysisManager();
00079   ( manager -> GetStatusTable() ).RemoveAnalysisStatus( id );
00080 
00081   return theNumberOfExtractors;
00082 }
00083 
00084 Tvoid TAnalyser::ClearExtractorList()
00085 {
00086   Tstring head = "TAnalyser::ClearExtractorList: ";
00087   for ( Tint i = 0; i < theNumberOfExtractors; i ++ ) {
00088     if ( theExtractorList[ i ] ) {
00089       Tstring id = theExtractorList[ i ] -> GetExtractorID();
00090       delete theExtractorList[ i ];
00091       Tcout << head << id << " extractor was deleted." << Tendl;      
00092     }
00093   }
00094 
00095   TAnalysisManager* manager = TAnalysisManager::GetAnalysisManager();
00096   ( manager -> GetStatusTable() ).Clear();
00097 
00098   theNumberOfExtractors = 0;
00099   theExtractorIndex = 0;
00100   return;
00101 }
00102 
00103 Tbool TAnalyser::ResizeExtractorList( Tint capacity )
00104 {
00105   if ( theNumberOfExtractors >= capacity ) {
00106     Tcerr << "TAnalyser::ResizeExtractorList: invalid capacity" << Tendl;
00107     return Tfalse;
00108   }
00109   theExtractorListCapacity = capacity;
00110   TExtractor** newExtractors = new TExtractor* [ theExtractorListCapacity ];
00111   for ( Tint i = 0; i < theNumberOfExtractors; i ++ )
00112     newExtractors[ i ] = theExtractorList[ i ];
00113   delete [] theExtractorList;
00114   theExtractorList = newExtractors;
00115   theExtractorIndex = theNumberOfExtractors - 1;
00116   return Ttrue;
00117 }
00118 
00119 TExtractor* TAnalyser::NextExtractor()
00120 {
00121   if ( theExtractorIndex < 0 || theExtractorIndex >= theNumberOfExtractors )
00122     return 0;
00123   return theExtractorList[ theExtractorIndex ++ ];
00124 }
00125 
00126 TExtractor* TAnalyser::FindExtractor( const Tstring& id )
00127 {
00128   Tint indexbuf = theExtractorIndex;
00129   theExtractorIndex = 0;
00130   TExtractor* ext = 0;
00131   while ( ( ext = NextExtractor() ) ) {
00132     if ( ext -> GetExtractorID() == id ) {
00133       theExtractorIndex = indexbuf;
00134       return ext;
00135     }
00136   }
00137   theExtractorIndex = indexbuf;
00138   return 0;
00139 }
00140 
00141 TExtractor* TAnalyser::GetExtractor( Tint index )
00142 {
00143   if ( index < 0 || index >= theNumberOfExtractors ) {
00144     Tcerr << "TAnalyser::GetExtractor: invalid index" << Tendl;
00145     return 0;
00146   }
00147   theExtractorIndex = index;
00148   return theExtractorList[ theExtractorIndex ];
00149 }
00150 
00151 TExtractor* TAnalyser::GetExtractor()
00152 {
00153   return GetExtractor( theExtractorIndex );
00154 }
00155 
00156 Tvoid TAnalyser::NotFoundExtractor()
00157 {
00158   Tint indexbuf = theExtractorIndex;
00159   TExtractor* ext = 0;
00160   theExtractorIndex = 0;
00161   Tcout << "Candidates for extractor identification:";
00162   while ( ( ext = NextExtractor() ) )
00163     Tcout << Tspace << ext -> GetExtractorID();
00164   Tcout << Tendl;
00165   theExtractorIndex = indexbuf;
00166   return;
00167 }
00168 
00169 Tvoid TAnalyser::free()
00170 {
00171   Tstring head = "TAnalyser::free: ";
00172   for ( Tint i = 0; i < theNumberOfExtractors; i ++ ) {
00173     if ( theExtractorList[ i ] ) {
00174       Tstring id = theExtractorList[ i ] -> GetExtractorID();
00175       delete theExtractorList[ i ];
00176       Tcout << head << id << " extractor was deleted." << Tendl;
00177     }
00178   }
00179   delete [] theExtractorList;
00180 
00181   TAnalysisManager* manager = TAnalysisManager::GetAnalysisManager();
00182   ( manager -> GetStatusTable() ).Clear();
00183 
00184   theExtractorListCapacity = 0;
00185   theNumberOfExtractors = 0;
00186   theExtractorIndex = 0;
00187   return;
00188 }
00189 
00190 Tvoid TAnalyser::allocate( Tint capacity )
00191 {
00192   theExtractorListCapacity = capacity;
00193   theExtractorList = new TExtractor* [ theExtractorListCapacity ];
00194   return;
00195 }
00196 
00197 #ifdef __CLDAQ_ROOT_DLL
00198     ClassImp(TAnalyser)
00199 #endif


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