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

TReadoutBook.cc

解説を見る。
00001 // =====================================================================
00002 //  $Id: TReadoutBook.cc,v 1.4 2004/03/07 10:30:33 goiwai Exp $
00003 //  $Name: CLDAQ-1-14-03 $
00004 //  $Log: TReadoutBook.cc,v $
00005 //  Revision 1.4  2004/03/07 10:30:33  goiwai
00006 //  ROOTに組みこむためのおまじないマクロを埋めこみました。
00007 //  全てにおいて完全に動作するわけではありません。
00008 //
00009 //  Revision 1.3  2003/10/06 16:39:00  goiwai
00010 //  *** empty log message ***
00011 //
00012 //  Revision 1.2  2003/07/30 16:20:11  goiwai
00013 //  ファイルにコミットログをつけることにしました.
00014 //
00015 // =====================================================================
00016 #include "TReadoutBook.hh"
00017 #include "TReadoutList.hh"
00018 #include "TDataRecord.hh"
00019 
00020 TReadoutBook::TReadoutBook()
00021   : theReadoutIndex()
00022 {
00023   theReadoutIndex.Clear();
00024 }
00025 
00026 TReadoutBook::~TReadoutBook()
00027 {
00028   ClearReadoutBook();
00029 }
00030 
00031 Tint TReadoutBook::AddReadoutList( TReadoutList* readoutlist )
00032 {
00033   Tstring id = readoutlist -> GetID();
00034   if ( FindReadoutList( id ) != 0 ) {
00035     Tcerr << "TReadoutBook::AddReadoutList: already exist ReadoutList identified as " << id << "." << Tendl;
00036   } else {
00037     theReadoutIndex.AddReadoutList( id, readoutlist );
00038   }
00039   return theReadoutIndex.GetSize();
00040 }
00041 
00042 Tint TReadoutBook::RemoveReadoutList( Tint index )
00043 {
00044   Tstring head = "TReadoutBook::RemoveReadoutList: ";
00045   if ( index < 0 || index >= theReadoutIndex.GetSize() ) {
00046     Tcerr << head << "invalid index " << index << "." << Tendl;
00047     return theReadoutIndex.GetSize();
00048   }
00049   Tstring id = theReadoutIndex[ index ].GetListID();
00050   delete ( theReadoutIndex[ index ].GetReadoutList() );
00051   Tcout << head << "ReadoutList identified as " << id << " was deleted.";
00052   theReadoutIndex.RemoveReadoutList( index );
00053 
00054   return theReadoutIndex.GetSize();
00055 }
00056 
00057 Tint TReadoutBook::RemoveReadoutList( const Tstring& id )
00058 {
00059   for ( Tint index = 0; index < theReadoutIndex.GetSize(); index ++ ) {
00060     if ( theReadoutIndex[ index ].GetListID() == id ) {
00061       RemoveReadoutList( index );
00062     }
00063   }
00064   return theReadoutIndex.GetSize();
00065 }
00066 
00067 Tvoid TReadoutBook::ClearReadoutBook()
00068 {
00069   Tstring head = "TReadoutBook::ClearReadoutBook: ";
00070   for ( Tint i = 0; i < theReadoutIndex.GetSize(); i ++ ) {
00071     if ( theReadoutIndex[ i ].GetReadoutList() ) {
00072       Tstring id = theReadoutIndex[ i ].GetListID();
00073       delete ( theReadoutIndex[ i ].GetReadoutList() );
00074       Tcout << head << "ReadoutList identified as " << id << " was deleted." << Tendl;
00075     }
00076   }
00077   theReadoutIndex.Clear();
00078   return;
00079 }
00080 
00081 TReadoutList* TReadoutBook::FindReadoutList( const Tstring& id )
00082 {
00083   return theReadoutIndex.FindReadoutList( id );
00084 }
00085 
00086 TReadoutList* TReadoutBook::GetReadoutList( Tint index )
00087 {
00088   if ( index < 0 || index >= theReadoutIndex.GetSize() ) {
00089     Tcerr << "TReadoutBook::GetReadoutList: invalid index " << index << "." << Tendl;
00090     return 0;
00091   }
00092   return theReadoutIndex[ index ].GetReadoutList();
00093 }
00094 
00095 TReadoutList* TReadoutBook::GetReadoutList( const Tstring& id )
00096 {
00097   return FindReadoutList( id );
00098 }
00099 
00100 TDataRecord TReadoutBook::Read( const Tstring& id )
00101 {
00102   TReadoutList* readoutlist = FindReadoutList( id );
00103   TDataRecord record;
00104   if ( readoutlist ) {
00105     record = readoutlist -> Read();
00106   }
00107   return record;
00108 }
00109 
00110 #ifdef __CLDAQ_ROOT_DLL
00111     ClassImp(TReadoutBook)
00112 #endif


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