PerStreamManager Class Reference

#include <PerStreamManager.h>

Inheritance diagram for PerStreamManager:

PerInputStreamManager PerOutputStreamManager List of all members.

Public Types

typedef std::map< std::string,
PerStream * > 
StreamMap
typedef StreamMap::iterator StreamMapItr
typedef StreamMap::const_iterator StreamMapConstItr

Public Member Functions

 PerStreamManager ()
virtual ~PerStreamManager ()
std::string GetCurrentFile (std::string streamname="*") const
UInt_t GetNumStream () const
UInt_t GetNumStreamOpen () const
virtual PerStreamGetOpenedStream (std::string streamname) const
const char * GetPrintOpt () const
const StreamMapGetStreamMap () const
virtual ostream & Print (ostream &os, Option_t *option="") const
virtual void CloseStream (string streamname="*")
virtual void CloseFile (string streamname="*")
void SetEnable (string streamname="*", bool enable=true)
virtual bool SetFile (string streamname, string fullfilepathname, Per::EAccessMode accessmode)
void SetPrintOpt (const char *option)
void SetTestMode (string streamname, bool testmode)

Protected Attributes

StreamMap fStreamMap
TString fPrintOpt

Detailed Description

Definition at line 28 of file PerStreamManager.h.


Member Typedef Documentation

typedef std::map<std::string,PerStream*> PerStreamManager::StreamMap

Definition at line 33 of file PerStreamManager.h.

typedef StreamMap::const_iterator PerStreamManager::StreamMapConstItr

Definition at line 35 of file PerStreamManager.h.

typedef StreamMap::iterator PerStreamManager::StreamMapItr

Definition at line 34 of file PerStreamManager.h.


Constructor & Destructor Documentation

PerStreamManager::PerStreamManager (  ) 

Definition at line 161 of file PerStreamManager.cxx.

00161                                    : fPrintOpt("") {
00162   // Purpose: Default constructor.
00163   //
00164   // Arguments: none.
00165   //
00166   // Return: none.
00167   //
00168   // Contact:  S. Kasahara
00169   //
00170 
00171 }

PerStreamManager::~PerStreamManager (  )  [virtual]

Definition at line 173 of file PerStreamManager.cxx.

References CloseStream().

00173                                     {
00174   //  Purpose:  Destructor.
00175   //
00176   //  Arguments: none.
00177   //
00178   //  Return:  none.
00179   //
00180   //  Contact:   S. Kasahara
00181   //
00182   
00183   // Close all managed streams and retrieve allocated memory
00184   CloseStream();
00185 
00186 }


Member Function Documentation

void PerStreamManager::CloseFile ( string  streamname = "*"  )  [virtual]

Reimplemented in PerInputStreamManager.

Definition at line 34 of file PerStreamManager.cxx.

References Munits::second.

Referenced by PerInputStreamManager::CloseFile(), IoOutputModule::CloseFile(), DemoDaqOutputModule::EndFile(), PerValidate::OutputStreamMgr(), and SpillTimeCreateKeyFile().

00034                                                   {
00035   //  Purpose:  Close current file serving specified stream(s).
00036   //
00037   //  Argument: streamname  string  name of stream on which to close file.
00038   //                                if streamname="*" (default), all
00039   //                                streams will have their files closed.
00040   //
00041   //  Return:  none.
00042   //
00043   //  Contact:   S. Kasahara
00044   //
00045   //  Notes:  Invokes PerStream::CloseFile for each requested stream.
00046   //
00047 
00048 
00049   if (streamname == "*") {
00050     // Close file on all streams
00051     for (StreamMapConstItr citr = fStreamMap.begin(); 
00052          citr != fStreamMap.end(); ++citr) 
00053       citr -> second -> CloseFile(); 
00054   }
00055   else {
00056     // Close stream of specified streamname
00057     PerStream* stream = GetOpenedStream(streamname);
00058     if (stream) stream -> CloseFile();
00059   }
00060 
00061 }

void PerStreamManager::CloseStream ( string  streamname = "*"  )  [virtual]

Reimplemented in PerInputStreamManager.

Definition at line 63 of file PerStreamManager.cxx.

References fStreamMap, and Munits::second.

Referenced by RotoServer::CloseFile(), OltNewModule::CloseFile(), OltNewModule::CloseSpy(), PerInputStreamManager::CloseStream(), IoOutputModule::DefineStream(), IoOutputModule::EndJob(), DemoDaqOutputModule::EndJob(), PerValidate::OutputStreamMgr(), RotoServer::Run(), SpillTimeCreateKeyFile(), ~PerStreamManager(), and RotoServer::~RotoServer().

00063                                                     {
00064   //  Purpose:  Close specified stream(s) and erase from stream manager's map.
00065   //
00066   //  Argument: streamname  string  name of stream to be closed.
00067   //                                if streamname ="*" (default), all
00068   //                                streams will be closed.
00069   //
00070   //  Return:  none.
00071   //
00072   //  Contact:   S. Kasahara
00073   //
00074 
00075   if ( streamname == "*" ) {
00076     // Close all streams managed by streammanager.
00077     for (StreamMapItr itr=fStreamMap.begin();itr != fStreamMap.end(); ++itr) 
00078       delete (itr -> second); // retrieve stream memory
00079     fStreamMap.clear(); // clear all map entries
00080   }
00081   else {
00082     // Close stream of specified streamname
00083     StreamMapItr itr = fStreamMap.find(streamname);
00084     if (itr != fStreamMap.end()) {
00085       delete (itr -> second); // retrieve stream memory
00086       fStreamMap.erase(itr);
00087     }
00088   }
00089 
00090 }

std::string PerStreamManager::GetCurrentFile ( std::string  streamname = "*"  )  const

Definition at line 92 of file PerStreamManager.cxx.

References fStreamMap, PerStream::GetFullFilePathName(), and GetOpenedStream().

Referenced by IoInputStreamItr::GetCurrentFile().

00092                                                                      {
00093   //  Purpose:  Return current file name for specified stream.
00094   //
00095   //  Argument: streamname  If specified as "*", returns current file of
00096   //                        first open stream.
00097   //
00098   //  Return: current file name
00099   //
00100   //  Contact:   S. Kasahara
00101   //
00102 
00103   if ( streamname == "*" ) {
00104     for (StreamMapConstItr itr=fStreamMap.begin();itr!=fStreamMap.end();++itr){
00105       PerStream* stream = itr->second; 
00106       if ( stream -> IsOpen() ) return stream->GetFullFilePathName();
00107     }
00108   }
00109   else {
00110     PerStream* stream = this -> GetOpenedStream(streamname);
00111     if ( stream ) return stream->GetFullFilePathName();
00112   }
00113 
00114   return "";
00115 
00116 }

UInt_t PerStreamManager::GetNumStream (  )  const [inline]

Definition at line 43 of file PerStreamManager.h.

References fStreamMap.

Referenced by IoOutputModule::EnableStreamList(), Print(), IoInputStreamItr::Streams(), and PerInputStreamManager::UpdateTreeFormula().

00043 {return fStreamMap.size();}

UInt_t PerStreamManager::GetNumStreamOpen (  )  const

Definition at line 139 of file PerStreamManager.cxx.

References fStreamMap.

Referenced by PerInputStreamManager::AddFile(), PerInputStreamManager::SetFile(), and PerInputStreamManager::UpdateTreeFormula().

00139                                                 {
00140   //
00141   //  Purpose:  Return count of number of streams that are IsOpen() (both
00142   //            tree and file pointers are non-null)
00143   //
00144   //  Argument: none.
00145   //
00146   //  Return:  number of open streams.
00147   //
00148   //  Contact:   S. Kasahara
00149   //
00150 
00151   UInt_t nopen = 0;
00152 
00153   for(StreamMapConstItr citr=fStreamMap.begin();citr!=fStreamMap.end();++citr){
00154     if ( citr->second->IsOpen() ) nopen++;
00155   }
00156 
00157   return nopen; 
00158 
00159 }

PerStream * PerStreamManager::GetOpenedStream ( std::string  streamname  )  const [virtual]

Reimplemented in PerInputStreamManager.

Definition at line 118 of file PerStreamManager.cxx.

References fStreamMap, and Munits::second.

Referenced by IoOutputModule::BeginJob(), IoOutputModule::DefineStream(), GetCurrentFile(), PerInputStreamManager::GetOpenedStream(), OltNewModule::Reco(), PerOutputStreamManager::SetAutoSave(), SetEnable(), SetFile(), SetTestMode(), PerOutputStreamManager::Write(), OltNewModule::WriteMom(), and RotoServer::WriteRawRecord().

00118                                                                        {
00119   //
00120   //  Purpose:  Retrieve stream corresponding to streamname.
00121   //            Stream must have been previously opened with OpenStream method.
00122   //
00123   //  Argument: streamname  string  containing name of stream of interest.
00124   //
00125   //  Return:  pointer to a PerStream. If member with name
00126   //           streamname does not exist, returns (PerStream*)0.  
00127   //
00128   //  Contact:   S. Kasahara
00129   //
00130   //  Notes: PerStream objects are owned by the PerStreamManager and
00131   //         should only be deleted through the PerStreamManager::Close method.
00132   //
00133 
00134   StreamMapConstItr citr = fStreamMap.find(streamname);
00135   return (citr != fStreamMap.end()) ? citr -> second : (PerStream*)0;
00136 
00137 }

const char* PerStreamManager::GetPrintOpt (  )  const [inline]

Definition at line 46 of file PerStreamManager.h.

References fPrintOpt.

Referenced by IoOutputModule::BeginJob().

00046 { return fPrintOpt.Data(); }

const StreamMap& PerStreamManager::GetStreamMap (  )  const [inline]

Definition at line 47 of file PerStreamManager.h.

References fStreamMap.

Referenced by IoOutputModule::EnableStreamList(), DDSChildServer::Next(), IoInputStreamItr::Streams(), and DDSChildServer::Subscribe().

00047 { return fStreamMap; } 

ostream & PerStreamManager::Print ( ostream &  os,
Option_t *  option = "" 
) const [virtual]

Definition at line 188 of file PerStreamManager.cxx.

References fStreamMap, GetNumStream(), and Munits::second.

Referenced by operator<<(), PerOutputStreamManager::Print(), and PerInputStreamManager::Print().

00189                                                                {
00190   //  Purpose:  Print current map of streams maintained by stream manager on
00191   //            std::ostream.
00192   //
00193   //  Arguments: ms       std::ostream to display on.
00194   //             option   print option
00195   //
00196   //  Return:  std::ostream reference.
00197   //
00198   //  Contact:   S. Kasahara
00199   //
00200 
00201   ms << "StreamManager is currently managing " << GetNumStream() 
00202      << " stream(s):" << endl;
00203 
00204   Int_t nstream=0;
00205   for( StreamMapConstItr citr = fStreamMap.begin();
00206        citr != fStreamMap.end(); ++citr ) {
00207     ms << ++nstream << ")" << "Streamname " << citr -> first << endl;
00208     ms << *(citr -> second);
00209   }
00210 
00211   return ms;
00212 
00213 }

void PerStreamManager::SetEnable ( string  streamname = "*",
bool  enable = true 
)

Definition at line 215 of file PerStreamManager.cxx.

References fStreamMap, GetOpenedStream(), and Munits::second.

Referenced by IoOutputModule::EnableStreamList().

00215                                                                {
00216   //
00217   //  Purpose:  Enable/disable specified stream(s).
00218   //
00219   //  Argument: streamname  string  name of stream on which to close file.
00220   //                                if streamname="*" (default), all
00221   //                                streams will have their files closed.
00222   //            enable      bool    if true (default) stream is enabled.
00223   //                                disabled streams are skipped over
00224   //                                during stream manager i/o calls.
00225   //
00226   //  Return:  none.
00227   //
00228   //  Contact:   S. Kasahara
00229   //
00230   //  Notes:  Invokes PerStream::SetEnable for each requested stream.
00231   //
00232 
00233   if (streamname == "*") {
00234     // Close file on all streams
00235     for (StreamMapConstItr citr = fStreamMap.begin(); 
00236          citr != fStreamMap.end(); ++citr) 
00237       citr -> second -> SetEnable(enable); 
00238   }
00239   else {
00240     // Close stream of specified streamname
00241     PerStream* stream = GetOpenedStream(streamname);
00242     if (stream) stream -> SetEnable(enable);
00243   }
00244   
00245 }

bool PerStreamManager::SetFile ( string  streamname,
string  fullfilepathname,
Per::EAccessMode  accessmode 
) [virtual]

Reimplemented in PerInputStreamManager.

Definition at line 248 of file PerStreamManager.cxx.

References fStreamMap, GetOpenedStream(), Msg::kWarning, MSG, and Munits::second.

Referenced by RotoServer::OpenFile(), OltNewModule::OpenFile(), IoOutputModule::OpenFile(), OltNewModule::OpenSpy(), PerValidate::OutputStreamMgr(), PerInputStreamManager::SetFile(), and SpillTimeCreateKeyFile().

00249                                                           {
00250   //  Purpose:  Sets new file for specified stream.
00251   //
00252   //  Arguments:streamname       string  name of stream to set file.
00253   //                             if streamname="*", all streams will have
00254   //                             their file set.
00255   //            fullfilepathname string  new filename.
00256   //            accessmode       Per::EAccessMode accessmode in which to open
00257   //                                              file.
00258   //
00259   //  Return:  bool  set true if PerStream::SetFile returned true
00260   //                 for at least one of the requested streams. 
00261   //
00262   //  Contact:   S. Kasahara
00263   //
00264   //  Notes: Invokes PerStream::SetFile (or PerOutputStream/
00265   //         PerInputStream::SetFile as appropriate) for each requested stream.
00266   //         Note that PerOutputStream::SetFile enforces the uniqueness
00267   //         of treenames in any given file to avoid overwriting trees.
00268 
00269   bool openok = false;
00270 
00271   if (streamname == "*") {
00272     // Set new file for all streams.  
00273     for (StreamMapConstItr citr=fStreamMap.begin();
00274                           citr!=fStreamMap.end();++citr) { 
00275       if (  citr -> second -> IsEnabled() && 
00276           !(citr -> second -> SetFile(fullfilepathname,accessmode)) ) {
00277         MSG("Per",Msg::kWarning) << "Failed to set new file for stream "
00278                                  << citr->first << endl;
00279       }
00280       else {
00281         openok=true;
00282       } 
00283     }
00284   }
00285   else {
00286     // SetFile for stream of specified streamname
00287     PerStream* stream = GetOpenedStream(streamname);
00288     if (stream) {
00289       if (!stream -> SetFile(fullfilepathname,accessmode)) {
00290         MSG("Per",Msg::kWarning) << "Failed to set new file for stream "
00291                                  << streamname << endl;
00292       }
00293       else {
00294         openok=true;
00295       }
00296     }
00297   }
00298 
00299   return openok;
00300 
00301 }

void PerStreamManager::SetPrintOpt ( const char *  option  )  [inline]

Definition at line 57 of file PerStreamManager.h.

References fPrintOpt.

Referenced by IoOutputModule::BeginJob().

00057 {fPrintOpt=option; fPrintOpt.ToLower();}

void PerStreamManager::SetTestMode ( string  streamname,
bool  testmode 
)

Definition at line 303 of file PerStreamManager.cxx.

References fStreamMap, GetOpenedStream(), and Munits::second.

Referenced by IoInputStreamItr::SetTestMode().

00303                                                                    {
00304   //
00305   //  Purpose:  Set streams to i/o test mode.
00306   //
00307   //  Argument: streamname  string  name of stream.
00308   //                                if streamname="*" (default), action
00309   //                                is applied to all streams.
00310   //            testmode    bool    if true, testmode is enabled.
00311   //                                one application is that the job
00312   //                                won't abort on the read of corrupt 
00313   //                                record.
00314   //
00315   //  Return:  none.
00316   //
00317   //  Contact:   S. Kasahara
00318   //
00319 
00320   if (streamname == "*") {
00321     // Apply to all streams
00322     for (StreamMapConstItr citr = fStreamMap.begin(); 
00323          citr != fStreamMap.end(); ++citr) 
00324       citr -> second -> SetTestMode(testmode); 
00325   }
00326   else {
00327     // Apply to specified stream
00328     PerStream* stream = GetOpenedStream(streamname);
00329     if (stream) stream -> SetTestMode(testmode);
00330   }
00331   
00332 }


Member Data Documentation

TString PerStreamManager::fPrintOpt [protected]

Definition at line 64 of file PerStreamManager.h.

Referenced by GetPrintOpt(), PerOutputStreamManager::Print(), PerInputStreamManager::Print(), and SetPrintOpt().

StreamMap PerStreamManager::fStreamMap [protected]

Definition at line 63 of file PerStreamManager.h.

Referenced by PerInputStreamManager::AddFile(), PerInputStreamManager::AdvanceLowerBoundTags(), PerInputStreamManager::AdvanceRecordTags(), PerInputStreamManager::AdvanceSequentialTags(), PerInputStreamManager::AdvanceWindowTags(), CloseStream(), GetCurrentFile(), PerInputStreamManager::GetCurrentKeyVld(), PerInputStreamManager::GetLastEntryVld(), GetNumStream(), GetNumStreamOpen(), GetOpenedStream(), GetStreamMap(), PerInputStreamManager::GoToFile(), PerInputStreamManager::IsBeginOfFiles(), PerInputStreamManager::IsEndOfFiles(), PerInputStreamManager::IsFileEnd(), PerInputStreamManager::IsSelectedSet(), PerInputStreamManager::IsValidSelectionString(), PerInputStreamManager::ListFile(), PerInputStreamManager::LoadRecord(), PerInputStreamManager::NextFile(), PerOutputStreamManager::OpenStream(), PerInputStreamManager::OpenStream(), PerInputStreamManager::PrevFile(), Print(), PerOutputStreamManager::Print(), PerInputStreamManager::Print(), PerOutputStreamManager::Put(), PerInputStreamManager::RemoveFile(), PerInputStreamManager::RewindRecordTags(), PerOutputStreamManager::SetAutoSave(), SetEnable(), SetFile(), PerInputStreamManager::SetFileEnd(), PerInputStreamManager::SetMaxFileRepeat(), PerInputStreamManager::SetMeanMom(), PerInputStreamManager::SetPushRandom(), SetTestMode(), PerInputStreamManager::SetUpdateMode(), PerInputStreamManager::UpdateTreeFormula(), and PerOutputStreamManager::Write().


The documentation for this class was generated from the following files:
Generated on Mon Nov 10 00:56:14 2014 for loon by  doxygen 1.4.7