IoInputStreamItr Class Reference

#include <IoInputStreamItr.h>

Inheritance diagram for IoInputStreamItr:
IoDataStreamItr

List of all members.

Public Member Functions

 IoInputStreamItr (const char *streamlist="")
 ~IoInputStreamItr ()
bool IsValid () const
const char * GetFormat () const
int LoadRecords (MomNavigator *m)
int Increment (int n=1, MomNavigator *m=0)
int Decrement (int n=1, MomNavigator *m=0)
JobCResult GoTo (const VldContext &vld, MomNavigator *m=0)
int GoToEOF ()
int DefineStream (const char *streamname, const char *treename)
int Streams (const char *streamlist)
int Select (const char *stream, const char *selection, bool isRequired=false)
int SetSequenceMode (const char *stream, Per::ESequenceMode sequencemode)
int SetPerOwnedDisabled (const char *stream, bool perowneddisabled=true)
int SetTestMode (const char *stream, bool testmode)
int SetWindow (const char *stream, double lower, double upper)
int SetMaxFileRepeat (const char *stream, int numRepeat)
int SetMeanMom (const char *stream, double mean)
int SetPushRandom (const char *stream, bool setRandom)
void SetRandomSeed (int rSeed)
void AddFile (const char *fullfilepathname, int at=-1, const char *streamlist="*")
const char * GetCurrentFile (const char *streamname="*") const
JobCResult GoToFile (int i, const char *streamlist="*")
JobCResult GoToFile (const char *fullfilepathname, const char *streamlist="*")
JobCResult NextFile (int n=1, const char *streamlist="*")
JobCResult PrevFile (int n=1, const char *streamlist="*")
void RemoveFile (const char *fullfilepathname="*", const char *streamlist="*")
std::ostream & ListFile (std::ostream &os, const char *streamlist="*") const

Private Attributes

PerInputStreamManager fInputStreamManager
bool fIsValid

Detailed Description

Definition at line 19 of file IoInputStreamItr.h.


Constructor & Destructor Documentation

IoInputStreamItr::IoInputStreamItr ( const char *  streamlist = ""  ) 

Definition at line 27 of file IoInputStreamItr.cxx.

References Streams().

00027                                                          : fIsValid(true) {
00028 //======================================================================
00029 // Argument: Delimiter separated list of streams to open.
00030 //======================================================================
00031   this -> Streams(streamlist);
00032 }

IoInputStreamItr::~IoInputStreamItr (  ) 

Definition at line 36 of file IoInputStreamItr.cxx.

References PerInputStreamManager::CloseStream(), fInputStreamManager, IoDataStreamItr::GetSourceName(), Msg::kDebug, and MSG.

00036                                     {
00037 //======================================================================
00038 // Destructor
00039 //======================================================================
00040   MSG("Io",Msg::kDebug) << 
00041     "Close streams " << this->GetSourceName() << "\n";
00042   fInputStreamManager.CloseStream(); 
00043 }


Member Function Documentation

void IoInputStreamItr::AddFile ( const char *  fullfilepathname,
int  at = -1,
const char *  streamlist = "*" 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 377 of file IoInputStreamItr.cxx.

References PerInputStreamManager::AddFile(), find(), fInputStreamManager, Per::GetAssociatedStreamList(), PerInputStreamManager::GetOpenedStream(), and UtilString::StringTok().

00378                                                         { 
00379 //======================================================================
00380 // Purpose: Add file fullfilepathname to index position at in filelist
00381 //          associated with the stream(s) in streamlist. If streamlist == "*",
00382 //          files will be applied to all managed streams, otherwise streamlist
00383 //          is a delimiter separated list of streams.
00384 //
00385 // Arguments: fullfilepathname  filename.
00386 //            at        the index position in the file list at which to
00387 //                      insert the new file. Set = -1 (default) => insert
00388 //                      at end of file list.
00389 //            streamlist Delimiter separated list of streams (e.g.
00390 //                       "DaqSnarl,DaqMonitor") on which to apply action.
00391 //                       If streamlist = "*" (default) => apply to all streams.
00392 //
00393 // Return: none.
00394 //         
00395 // Contact: S. Kasahara
00396 //======================================================================
00397 
00398   // parse delimiter separate streamlist into a vector of streamnames
00399   std::vector<std::string> vstreams;
00400   UtilString::StringTok(vstreams,streamlist,":,;/ ");
00401   std::vector<std::string>::iterator vsItr;
00402 
00403   int nstream = 0;
00404   for ( vsItr = vstreams.begin(); vsItr != vstreams.end(); vsItr++ ) {
00405     std::string streamname = *vsItr;
00406     if ( fInputStreamManager.GetOpenedStream(streamname) ) { 
00407       nstream += fInputStreamManager.AddFile(fullfilepathname,at,streamname);
00408     }
00409     std::string assocstreams 
00410                      = Per::GetAssociatedStreamList(streamname.c_str());
00411     if ( !assocstreams.empty() ) {
00412       // parse delimiter separated streamlist into a vector of streamnames
00413       std::vector<std::string> assocstreamlist;
00414       UtilString::StringTok(assocstreamlist,
00415                             std::string(assocstreams),":,;/ ");
00416       std::vector<std::string>::iterator astrItr;
00417       // Add file to associated streams 
00418       for ( astrItr = assocstreamlist.begin(); 
00419             astrItr!= assocstreamlist.end(); astrItr++ ) {
00420         std::string assocstreamname = *astrItr;
00421         // Check to see if assocstreamname isn't already in input streamlist
00422         // This is lame at best and needs to be fixed.
00423         typedef std::vector<std::string>::const_iterator vs_citer;
00424         vs_citer aspos = std::find(vstreams.begin(),vstreams.end(),
00425                                    assocstreamname);
00426         if ( aspos == vstreams.end() ) { 
00427           if ( fInputStreamManager.GetOpenedStream(assocstreamname) ) {
00428             nstream 
00429             +=fInputStreamManager.AddFile(fullfilepathname,at,assocstreamname);
00430           }
00431         }
00432       }
00433     }
00434   }
00435 
00436   return;
00437 }

int IoInputStreamItr::Decrement ( int  n = 1,
MomNavigator m = 0 
) [virtual]

Implements IoDataStreamItr.

Definition at line 68 of file IoInputStreamItr.cxx.

References fInputStreamManager, and PerInputStreamManager::Previous().

00068                                                       {
00069 //======================================================================
00070 // Rewind n record sets. Returns number of record sets rewound.
00071 //======================================================================
00072   return fInputStreamManager.Previous(m,n);
00073 }

int IoInputStreamItr::DefineStream ( const char *  streamname,
const char *  treename 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 106 of file IoInputStreamItr.cxx.

References PerInputStreamManager::CloseStream(), fInputStreamManager, PerInputStreamManager::GetOpenedStream(), Msg::kDebug, MSG, and PerInputStreamManager::OpenStream().

00107 {
00108 //======================================================================
00109 // Define stream with name streamname to serve tree of name treename.
00110 //======================================================================
00111 
00112   MSG("Io",Msg::kDebug) <<
00113     "Define stream " << streamname << " to serve tree " << treename << endl;
00114 
00115   if ( fInputStreamManager.GetOpenedStream(streamname) ) {
00116     fInputStreamManager.CloseStream(streamname);
00117   }
00118   fInputStreamManager.OpenStream(streamname,treename);
00119 
00120   return 1;
00121 }

const char * IoInputStreamItr::GetCurrentFile ( const char *  streamname = "*"  )  const [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 439 of file IoInputStreamItr.cxx.

References fInputStreamManager, and PerStreamManager::GetCurrentFile().

00439                                                                          { 
00440 //======================================================================
00441 // Purpose: Return current file of specified stream.
00442 //
00443 // Arguments: streamname If specified as "*", returns current file of
00444 //                       first open stream.
00445 //
00446 // Return: current file name
00447 //         
00448 // Contact: S. Kasahara
00449 //======================================================================
00450 
00451   return (fInputStreamManager.GetCurrentFile(streamname)).c_str();
00452 
00453 }

const char* IoInputStreamItr::GetFormat (  )  const [inline, virtual]

Implements IoDataStreamItr.

Definition at line 27 of file IoInputStreamItr.h.

00027 { return "input"; }

JobCResult IoInputStreamItr::GoTo ( const VldContext vld,
MomNavigator m = 0 
) [virtual]

Implements IoDataStreamItr.

Definition at line 77 of file IoInputStreamItr.cxx.

References fInputStreamManager, Per::GetVldBegin(), Per::GetVldEnd(), JobCResult::kAOK, JobCResult::kBeginOfInputStream, JobCResult::kEndOfInputStream, and PerInputStreamManager::RecordsAt().

00077                                                                         {
00078 //======================================================================
00079 // Go directly to a record with a specified validity context. Will
00080 // stop at record set one past requested validity if exact match not 
00081 // available.  Returns:
00082 //      JobCResult::kBeginOfInputStream if at begin of streams
00083 //      JobCResult::kEndOfInputStream if at end of streams
00084 //      JobCResult::kAOK if all okay
00085 //======================================================================
00086   const VldContext& newVld = fInputStreamManager.RecordsAt(m,vld);
00087   if ( newVld == Per::GetVldEnd() ) return JobCResult::kEndOfInputStream;
00088   if ( newVld == Per::GetVldBegin() ) return JobCResult::kBeginOfInputStream;
00089   return JobCResult::kAOK; // success
00090 }

int IoInputStreamItr::GoToEOF (  )  [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 94 of file IoInputStreamItr.cxx.

References fInputStreamManager, Per::GetVldEnd(), and PerInputStreamManager::RecordsAt().

00094                               {
00095 //======================================================================
00096 // Advance to the end of all files
00097 //======================================================================
00098 
00099   fInputStreamManager.RecordsAt((MomNavigator*)0,Per::GetVldEnd());
00100   return 1;
00101 
00102 }

JobCResult IoInputStreamItr::GoToFile ( const char *  fullfilepathname,
const char *  streamlist = "*" 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 490 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::GoToFile(), JobCResult::kAOK, JobCResult::kWarning, and UtilString::StringTok().

00491                                                               { 
00492 //======================================================================
00493 // Purpose: GoToFile filename in filelist of specified streams.
00494 //
00495 // Arguments: filename   full file path name of file in streamlist.
00496 //            streamlist Delimiter separated list of streams (e.g.
00497 //                       "DaqSnarl,DaqMonitor") on which to apply action.
00498 //                       If streamlist = "*" (default) => apply to all streams.
00499 // 
00500 // Return: JobCResult::kAOK if advance successful and file opened okay on
00501 //                          at least one requested stream, or
00502 //         JobCResult::kWarning, if requested file not found in file list or
00503 //                               file open error occured on all requested
00504 //                               streams.
00505 // 
00506 // Contact: S. Kasahara
00507 //======================================================================
00508 
00509   int nstream = 0;
00510 
00511   // parse delimiter separate streamlist into a vector of streamnames
00512   std::vector<std::string> vstreams;
00513   UtilString::StringTok(vstreams,streamlist,":,;/ ");
00514   std::vector<std::string>::iterator vsItr;
00515 
00516   for ( vsItr = vstreams.begin(); vsItr != vstreams.end(); vsItr++ ) {
00517     std::string streamname = *vsItr;
00518     nstream += fInputStreamManager.GoToFile(filename,streamname);
00519   }
00520 
00521   if ( !nstream ) return JobCResult::kWarning;
00522   return JobCResult::kAOK;
00523 }

JobCResult IoInputStreamItr::GoToFile ( int  i,
const char *  streamlist = "*" 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 455 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::GoToFile(), JobCResult::kAOK, JobCResult::kWarning, and UtilString::StringTok().

00455                                                                      { 
00456 //======================================================================
00457 // Purpose: GoToFile at position n in filelist of specified streams.
00458 //
00459 // Arguments: n          index of file in filelist.
00460 //            streamlist Delimiter separated list of streams (e.g.
00461 //                       "DaqSnarl,DaqMonitor") on which to apply action.
00462 //                       If streamlist = "*" (default) => apply to all streams.
00463 // 
00464 // Return: JobCResult::kAOK if advance successful and file opened okay on
00465 //                          at least one requested stream, or
00466 //         JobCResult::kWarning, if requested file number out of range, or
00467 //                               file open error occured on all requested
00468 //                               streams.
00469 // 
00470 // Contact: S. Kasahara
00471 //======================================================================
00472 
00473   int nstream = 0;
00474 
00475   // parse delimiter separate streamlist into a vector of streamnames
00476   std::vector<std::string> vstreams;
00477   UtilString::StringTok(vstreams,streamlist,":,;/ ");
00478   std::vector<std::string>::iterator vsItr;
00479 
00480   for ( vsItr = vstreams.begin(); vsItr != vstreams.end(); vsItr++ ) {
00481     std::string streamname = *vsItr;
00482     nstream += fInputStreamManager.GoToFile(n,streamname);
00483   }
00484 
00485   if ( !nstream ) return JobCResult::kWarning;
00486   return JobCResult::kAOK;
00487 
00488 }

int IoInputStreamItr::Increment ( int  n = 1,
MomNavigator m = 0 
) [virtual]

Implements IoDataStreamItr.

Definition at line 58 of file IoInputStreamItr.cxx.

References fInputStreamManager, and PerInputStreamManager::Next().

00058                                                       {
00059 //======================================================================
00060 // Advance n record sets.  Returns number of record sets advanced.
00061 //======================================================================
00062 
00063   return fInputStreamManager.Next(m,n);
00064 }

bool IoInputStreamItr::IsValid (  )  const [inline, virtual]

Implements IoDataStreamItr.

Definition at line 26 of file IoInputStreamItr.h.

References fIsValid.

00026 { return fIsValid; }

std::ostream & IoInputStreamItr::ListFile ( std::ostream &  os,
const char *  streamlist = "*" 
) const [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 653 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::ListFile(), and UtilString::StringTok().

00654                                                                        { 
00655 //======================================================================
00656 // Purpose: List files in file list of specified stream(s).
00657 //
00658 // Arguments: os  ostream to direct print.
00659 //            streamlist Delimiter separated list of streams (e.g.
00660 //                       "DaqSnarl,DaqMonitor") on which to apply action.
00661 //                       If streamlist = "*" (default) => apply to all streams.
00662 // 
00663 // Return: ostream reference.
00664 // 
00665 // Contact: S. Kasahara
00666 //======================================================================
00667 
00668   // parse delimiter separated streamlist into a vector of streamnames
00669   std::vector<std::string> vstreams;
00670   UtilString::StringTok(vstreams,streamlist,":,;/ ");
00671   std::vector<std::string>::iterator vsItr;
00672 
00673   for ( vsItr = vstreams.begin(); vsItr != vstreams.end(); vsItr++ ) {
00674     std::string streamname = *vsItr;
00675     fInputStreamManager.ListFile(os,streamname);
00676   }
00677 
00678   return os;
00679 }

int IoInputStreamItr::LoadRecords ( MomNavigator m  )  [virtual]

Implements IoDataStreamItr.

Definition at line 47 of file IoInputStreamItr.cxx.

References fInputStreamManager, and PerInputStreamManager::Get().

00047                                                  {
00048 //======================================================================
00049 // Retrieve current record set from manager. Returns number of records
00050 // loaded.
00051 //======================================================================
00052   int nrecord = fInputStreamManager.Get(m);
00053   return nrecord;
00054 }

JobCResult IoInputStreamItr::NextFile ( int  n = 1,
const char *  streamlist = "*" 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 525 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::IsEndOfFiles(), JobCResult::kAOK, JobCResult::kEndOfInputStream, JobCResult::kWarning, PerInputStreamManager::NextFile(), and UtilString::StringTok().

00525                                                                    { 
00526 //======================================================================
00527 // Purpose: Advance forward n files in filelist of specified stream(s).
00528 //
00529 // Arguments: n   number of files by which to advance.(default = 1)
00530 //            streamlist Delimiter separated list of streams (e.g.
00531 //                       "DaqSnarl,DaqMonitor") on which to apply action.
00532 //                       If streamlist = "*" (default) => apply to all streams.
00533 // 
00534 // Return: JobCResult::kAOK if advance successful and file opened okay for
00535 //                          at least one stream, or
00536 //         JobCResult::kWarning if advance successful, but file open
00537 //                              failed.
00538 //         JobCResult::kEndOfInputStream, if at end of file list for
00539 //                                        all requested streams.
00540 // 
00541 // Contact: S. Kasahara
00542 //======================================================================
00543 
00544   int nstream = 0;
00545 
00546   // parse delimiter separate streamlist into a vector of streamnames
00547   std::vector<std::string> vstreams;
00548   UtilString::StringTok(vstreams,streamlist,":,;/ ");
00549   std::vector<std::string>::iterator vsItr;
00550 
00551   if ( vstreams.empty() ) return JobCResult::kAOK; // no streams requested
00552 
00553   bool isWarning = false;
00554   for ( vsItr = vstreams.begin(); vsItr != vstreams.end(); vsItr++ ) {
00555     std::string streamname = *vsItr;
00556     int nOK = fInputStreamManager.NextFile(n,streamname);
00557     if ( !nOK ) { 
00558       // Failed to advance to file but not at end of files means open failure
00559       if ( !fInputStreamManager.IsEndOfFiles(streamname) ) isWarning = true;
00560     }
00561     else nstream += nOK;
00562   }
00563 
00564   if ( !nstream ) {
00565     if ( isWarning ) return JobCResult::kWarning;
00566     else return JobCResult::kEndOfInputStream;
00567   }
00568 
00569   return JobCResult::kAOK;
00570 
00571 }

JobCResult IoInputStreamItr::PrevFile ( int  n = 1,
const char *  streamlist = "*" 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 573 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::IsBeginOfFiles(), JobCResult::kAOK, JobCResult::kBeginOfInputStream, JobCResult::kWarning, PerInputStreamManager::PrevFile(), and UtilString::StringTok().

00573                                                                    { 
00574 //======================================================================
00575 // Purpose: Rewind backward n files in filelist of specified stream(s).
00576 //
00577 // Arguments: n   number of files by which to rewind.(default = 1)
00578 //            streamlist Delimiter separated list of streams (e.g.
00579 //                       "DaqSnarl,DaqMonitor") on which to apply action.
00580 //                       Set = "*" (default) => apply to all streams.
00581 // 
00582 // Return: JobCResult::kAOK if rewind successful and file opened okay for
00583 //                          at least one stream, or
00584 //         JobCResult::kWarning if rewind successful, but file open
00585 //                              failed.
00586 //         JobCResult::kBeginOfInputStream, if at end of file list for
00587 //                                          all requested streams.
00588 //
00589 // Contact: S. Kasahara
00590 //======================================================================
00591 
00592   int nstream = 0;
00593 
00594   // parse delimiter separate streamlist into a vector of streamnames
00595   std::vector<std::string> vstreams;
00596   UtilString::StringTok(vstreams,streamlist,":,;/ ");
00597   std::vector<std::string>::iterator vsItr;
00598 
00599   if ( vstreams.empty() ) return JobCResult::kAOK; // no streams requested
00600 
00601   bool isWarning = false;
00602   for ( vsItr = vstreams.begin(); vsItr != vstreams.end(); vsItr++ ) {
00603     std::string streamname = *vsItr;
00604     int nOK = fInputStreamManager.PrevFile(n,streamname);
00605     if ( !nOK ) { 
00606       // Failed to advance to file but not at begin of files means open failure
00607       if ( !fInputStreamManager.IsBeginOfFiles(streamname) ) isWarning = true;
00608     }
00609     else nstream += nOK;
00610   }
00611 
00612   if ( !nstream ) {
00613     if ( isWarning ) return JobCResult::kWarning;
00614     else return JobCResult::kBeginOfInputStream;
00615   }
00616 
00617   return JobCResult::kAOK;
00618 
00619 }

void IoInputStreamItr::RemoveFile ( const char *  fullfilepathname = "*",
const char *  streamlist = "*" 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 621 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::RemoveFile(), and UtilString::StringTok().

00621                                                                             {
00622 //======================================================================
00623 // Purpose: Remove file filename from filelist associated with the
00624 //          stream(s) in streamlist.  If filename = "*", all files are
00625 //          removed.  
00626 //
00627 // Arguments: filename  full file path name of file to remove.  If "*",
00628 //                      all files will be removed from file list. 
00629 //            streamlist Delimiter separated list of streams (e.g.
00630 //                       "DaqSnarl,DaqMonitor") on which to apply action.
00631 //                       If streamlist = "*" (default) => apply to all streams.
00632 //
00633 // Return: none.
00634 //
00635 // Contact: S. Kasahara
00636 //======================================================================
00637 
00638   int nstream = 0;
00639 
00640   // parse delimiter separate streamlist into a vector of streamnames
00641   std::vector<std::string> vstreams;
00642   UtilString::StringTok(vstreams,streamlist,":,;/ ");
00643   std::vector<std::string>::iterator vsItr;
00644 
00645   for ( vsItr = vstreams.begin(); vsItr != vstreams.end(); vsItr++ ) {
00646     std::string streamname = *vsItr;
00647     nstream += fInputStreamManager.RemoveFile(filename,streamname);
00648   }
00649 
00650   return;
00651 }

int IoInputStreamItr::Select ( const char *  stream,
const char *  selection,
bool  isRequired = false 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 196 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::GetOpenedStream(), Msg::kDebug, MSG, and PerInputStreamManager::SetSelection().

00197                                               {
00198 //======================================================================
00199 // Set the selection cuts for named stream.  Returns 0 if stream not
00200 // open, else 1.
00201 //======================================================================
00202   int isOpen = 0;
00203   MSG("Io",Msg::kDebug) <<
00204     "Set selection string " << selection << " for stream " << stream << endl;
00205 
00206   if ( std::string(stream) == "*" ) {
00207     fInputStreamManager.SetSelection(stream,selection,isRequired);
00208     isOpen = 1;
00209   }
00210   else if ( fInputStreamManager.GetOpenedStream(stream) ) {
00211     fInputStreamManager.SetSelection(stream,selection,isRequired);
00212     isOpen = 1;
00213   }
00214   return isOpen;
00215 }

int IoInputStreamItr::SetMaxFileRepeat ( const char *  stream,
int  numRepeat 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 306 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::GetOpenedStream(), Msg::kDebug, MSG, and PerInputStreamManager::SetMaxFileRepeat().

00307 {
00308 //======================================================================
00309 // Set the number of times to reuse a file before moving to the next one
00310 // in the named stream.
00311 // Returns 0 if stream not open, else 1.
00312 //======================================================================
00313   int isOpen = 0;
00314   if (numRepeat < 0) numRepeat = 0;
00315   MSG("Io",Msg::kDebug)
00316     << "Set number of times to reuse each file from stream " << stream
00317     << " = " << numRepeat << endl;
00318 
00319   if ( fInputStreamManager.GetOpenedStream(stream) ) {
00320     fInputStreamManager.SetMaxFileRepeat(stream,numRepeat);
00321     isOpen = 1;
00322   }
00323   return isOpen;
00324 }

int IoInputStreamItr::SetMeanMom ( const char *  stream,
double  mean 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 326 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::GetOpenedStream(), Msg::kDebug, MSG, and PerInputStreamManager::SetMeanMom().

00327 {
00328 //======================================================================
00329 // Set the mean #evts for named stream.
00330 // Returns 0 if stream not open, else 1.
00331 //======================================================================
00332   int isOpen = 0;
00333   MSG("Io",Msg::kDebug)
00334     << "Set mean number of events to push to Mom from stream " << stream
00335     << " = " << mean << endl;
00336 
00337   if ( fInputStreamManager.GetOpenedStream(stream) ) {
00338     fInputStreamManager.SetMeanMom(stream,mean);
00339     isOpen = 1;
00340   }
00341   return isOpen;
00342 }

int IoInputStreamItr::SetPerOwnedDisabled ( const char *  stream,
bool  perowneddisabled = true 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 219 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::GetOpenedStream(), Msg::kDebug, MSG, and PerInputStreamManager::SetPerOwnedDisabled().

00220                                                                  {
00221 //======================================================================
00222 // Used to disable PerOwned for named stream.  Returns 0 if stream not
00223 // open, else 1.
00224 //======================================================================
00225   int isOpen = 0;
00226   MSG("Io",Msg::kDebug) << "SetPerOwnedDisabled " << perowneddisabled 
00227                         << " for stream " << stream << endl;
00228 
00229   if ( std::string(stream) == "*" ) {
00230     fInputStreamManager.SetPerOwnedDisabled(stream,perowneddisabled);
00231     isOpen = 1;
00232   }
00233   else if ( fInputStreamManager.GetOpenedStream(stream) ) {
00234     fInputStreamManager.SetPerOwnedDisabled(stream,perowneddisabled);
00235     isOpen = 1;
00236   }
00237   return isOpen;
00238 }

int IoInputStreamItr::SetPushRandom ( const char *  stream,
bool  setRandom 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 344 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::GetOpenedStream(), Msg::kDebug, MSG, and PerInputStreamManager::SetPushRandom().

00345 {
00346 //======================================================================
00347 // Set whether to push a random/constant #evts for named stream to Mom.
00348 // Returns 0 if stream not open, else 1.
00349 //======================================================================
00350   int isOpen = 0;
00351   MSG("Io",Msg::kDebug)
00352     << "Set push " << ((setRandom)? "random " : "constant ")
00353     << "number of events to push to Mom from stream " << stream
00354     << endl;
00355 
00356   if ( fInputStreamManager.GetOpenedStream(stream) ) {
00357     fInputStreamManager.SetPushRandom(stream,setRandom);
00358     isOpen = 1;
00359   }
00360   return isOpen;
00361 }

void IoInputStreamItr::SetRandomSeed ( int  rSeed  )  [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 363 of file IoInputStreamItr.cxx.

References fInputStreamManager, Msg::kDebug, MSG, and PerInputStreamManager::SetRandomSeed().

00364 {
00365 //======================================================================
00366 // Set the random seet for the InputStreamManager
00367 //======================================================================
00368 
00369   MSG("Io",Msg::kDebug)
00370     << "Set InputStreamManager random seed to " << rSeed << endl;
00371 
00372   fInputStreamManager.SetRandomSeed(rSeed);
00373 
00374 }

int IoInputStreamItr::SetSequenceMode ( const char *  stream,
Per::ESequenceMode  sequencemode 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 242 of file IoInputStreamItr.cxx.

References bfld::AsString(), fInputStreamManager, PerInputStreamManager::GetOpenedStream(), Msg::kDebug, MSG, and PerInputStreamManager::SetSequenceMode().

00243                                                                   {
00244 //======================================================================
00245 // Set the sequence mode for named stream.  Returns 0 if stream not
00246 // open, else 1.
00247 //======================================================================
00248   int isOpen = 0;
00249   MSG("Io",Msg::kDebug) <<
00250     "Set sequence mode " << Per::AsString(sequenceMode) << " for stream " 
00251                          << stream << endl;
00252 
00253   if ( fInputStreamManager.GetOpenedStream(stream) ) {
00254     fInputStreamManager.SetSequenceMode(stream,sequenceMode);
00255     isOpen = 1;
00256   }
00257   return isOpen;
00258 }

int IoInputStreamItr::SetTestMode ( const char *  stream,
bool  testmode 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 262 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::GetOpenedStream(), Msg::kDebug, MSG, and PerStreamManager::SetTestMode().

00263                                                  {
00264 //======================================================================
00265 // Set the test mode for named stream.  Returns 0 if stream not
00266 // open, else 1.
00267 //======================================================================
00268   int isOpen = 0;
00269   std::string testModeStr = "false";
00270   if ( testMode ) testModeStr = "true";
00271 
00272   MSG("Io",Msg::kDebug) <<
00273     "Set test mode " << testModeStr.c_str() << " for stream " 
00274                      << stream << endl;
00275 
00276   if ( std::string(stream) == "*" ) {
00277     fInputStreamManager.SetTestMode(stream,testMode);
00278     isOpen = 1;
00279   }
00280   else if ( fInputStreamManager.GetOpenedStream(stream) ) {
00281     fInputStreamManager.SetTestMode(stream,testMode);
00282     isOpen = 1;
00283   }
00284   return isOpen;
00285 
00286 }

int IoInputStreamItr::SetWindow ( const char *  stream,
double  lower,
double  upper 
) [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 288 of file IoInputStreamItr.cxx.

References fInputStreamManager, PerInputStreamManager::GetOpenedStream(), Msg::kDebug, MSG, and PerInputStreamManager::SetWindow().

00289 {
00290 //======================================================================
00291 //Set the window for named stream.  Returns 0 if stream not open, else
00292 //1.
00293 //======================================================================
00294   int isOpen = 0;
00295   MSG("Io",Msg::kDebug) <<
00296       "Set window [" << lower << ", " << upper << "] for stream " 
00297                         << stream << endl;
00298 
00299   if ( fInputStreamManager.GetOpenedStream(stream) ) {
00300     fInputStreamManager.SetWindow(stream,lower,upper);
00301     isOpen = 1;
00302   }
00303   return isOpen;
00304 }

int IoInputStreamItr::Streams ( const char *  streamlist  )  [virtual]

Reimplemented from IoDataStreamItr.

Definition at line 125 of file IoInputStreamItr.cxx.

References PerInputStreamManager::CloseStream(), find(), fInputStreamManager, Per::GetAssociatedStreamList(), PerStreamManager::GetNumStream(), PerInputStreamManager::GetOpenedStream(), PerStreamManager::GetStreamMap(), Msg::kDebug, MSG, PerInputStreamManager::OpenStream(), IoDataStreamItr::SetSourceName(), and UtilString::StringTok().

Referenced by IoInputStreamItr().

00125                                                  {
00126 //======================================================================
00127 // Modify open streams to match those specified in streams.  streams
00128 // is a delimiter separated list of streamnames. Returns number of
00129 // streams open.
00130 //======================================================================
00131 
00132   this -> SetSourceName(streams);
00133   MSG("Io",Msg::kDebug) << "Set streams " << streams << endl;
00134 
00135   // parse delimiter separate streamlist into a vector of streamnames
00136   std::vector<std::string> streamlist;
00137   UtilString::StringTok(streamlist,std::string(streams),":,;/ ");
00138 
00139   std::vector<std::string>::iterator strItr;
00140   // Add streams not previously opened
00141   for ( strItr = streamlist.begin(); strItr != streamlist.end(); strItr++ ) {
00142     std::string streamname = *strItr;
00143     if ( !fInputStreamManager.GetOpenedStream(streamname) ) {
00144       fInputStreamManager.OpenStream(streamname,streamname);
00145     }
00146   }
00147   
00148   // Close streams not in requested list
00149   const PerStreamManager::StreamMap& smap = fInputStreamManager.GetStreamMap();
00150   for ( PerStreamManager::StreamMapConstItr citr = smap.begin();
00151                                             citr!= smap.end(); ++citr ) {
00152     std::string streamname = citr->first;
00153     typedef std::vector<std::string>::const_iterator vs_citer;
00154     vs_citer vpos = std::find(streamlist.begin(),streamlist.end(),streamname);
00155     if ( vpos == streamlist.end() ) { 
00156       fInputStreamManager.CloseStream(streamname);
00157     }
00158   }
00159 
00160   // Open streams associated with those in requested list.  Since assocated
00161   // streams may in turn have associated streams, this is done as a while
00162   // loop until no more streams are added
00163   bool isNewStream = true;
00164   while ( isNewStream ) {
00165     isNewStream = false;
00166     for ( PerStreamManager::StreamMapConstItr citr = smap.begin();
00167                                               citr!= smap.end(); ++citr ) {
00168       std::string streamname = citr->first;
00169       std::string assocstreams 
00170                           = Per::GetAssociatedStreamList(streamname.c_str());
00171       if ( !assocstreams.empty() ) {
00172         // parse delimiter separated streamlist into a vector of streamnames
00173         std::vector<std::string> assocstreamlist;
00174         UtilString::StringTok(assocstreamlist,
00175                               std::string(assocstreams),":,;/ ");
00176         std::vector<std::string>::iterator astrItr;
00177         // Add associated streams not previously opened
00178         for ( astrItr = assocstreamlist.begin(); 
00179               astrItr!= assocstreamlist.end(); astrItr++ ) {
00180           std::string assocstreamname = *astrItr;
00181           if ( !fInputStreamManager.GetOpenedStream(assocstreamname) ) {
00182             fInputStreamManager.OpenStream(assocstreamname,assocstreamname);
00183             isNewStream = true;
00184           }
00185         }
00186       }
00187     }
00188   }
00189 
00190 
00191   return fInputStreamManager.GetNumStream();
00192 }


Member Data Documentation

Definition at line 64 of file IoInputStreamItr.h.

Referenced by IsValid().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1