PerStream Class Reference

#include <PerStream.h>

Inheritance diagram for PerStream:
PerInputStream PerOutputStream

List of all members.

Public Member Functions

 PerStream (std::string treename)
virtual ~PerStream ()
std::string GetTreeName () const
std::string GetClassName () const
Per::EErrorCode GetErrorCode () const
std::string GetFullFilePathName () const
Int_t GetEntry () const
Int_t GetNumEntries () const
std::string GetStreamName () const
bool GetTestMode () const
bool IsEnabled () const
bool IsOpen () const
bool IsModified () const
bool IsPerOwned () const
bool IsPerOwnedDisabled () const
virtual std::ostream & Print (std::ostream &s) const
virtual void Close ()
virtual void CloseFile ()
void Reset (bool ishard=false)
void SetEnable (bool enable=true)
void SetPerOwned (bool perowned=true)
void SetPerOwnedDisabled (bool perowneddisabled=true)
void SetTestMode (bool testmode)
virtual bool SetFile (std::string fullfilepathname, Per::EAccessMode accessmode)=0
virtual void SetStreamName (std::string streamname)

Protected Attributes

std::string fTreeName
std::string fStreamName
std::string fClassName
std::string fFullFilePathName
TFile * fTFile
TTree * fTTree
TBranch * fTBranch
TObject * fTObject
Int_t fEntry
bool fEnable
bool fPerOwned
bool fPerOwnedDisabled
Per::EErrorCode fErrorCode
bool fTestMode

Detailed Description

Definition at line 26 of file PerStream.h.


Constructor & Destructor Documentation

PerStream::PerStream ( std::string  treename  ) 

Definition at line 97 of file PerStream.cxx.

00097                                        : 
00098   fTreeName(treename),fStreamName(""),fClassName(""),
00099   fFullFilePathName(""),fTFile(0),fTTree(0),fTBranch(0),fTObject(0),
00100   fEntry(-1),fEnable(true),fPerOwned(false),fPerOwnedDisabled(false),
00101   fErrorCode(Per::kErrSuccess),fTestMode(false) {
00102   //
00103   //  Purpose:  Default constructor.
00104   //
00105   //  Arguments: 
00106   //    treename   string   name of the tree served by this stream.
00107   //    streamname string   name of this stream (default = treename)
00108   //  Return:    n/a.
00109   //
00110   //  Contact:   S. Kasahara
00111   // 
00112 
00113   TTree::SetBranchStyle(1);  // use new 3.01 style of creating branches
00114 
00115 }

PerStream::~PerStream (  )  [virtual]

Definition at line 119 of file PerStream.cxx.

References Close().

00119                       {
00120   //
00121   //  Purpose:  PerStream destructor.  Closes stream and retrieves
00122   //            allocated memory.
00123   //
00124   //  Contact:   S. Kasahara
00125   // 
00126 
00127   Close();
00128 
00129 }


Member Function Documentation

void PerStream::Close (  )  [virtual]

Reimplemented in PerInputStream, and PerOutputStream.

Definition at line 40 of file PerStream.cxx.

Referenced by ~PerStream().

00040                       {
00041   //
00042   //  Purpose:  Close the stream.
00043   //
00044   //  Arguments: none.
00045   //
00046   //  Return:  none.
00047   //
00048   //  Contact:   S. Kasahara
00049   // 
00050 
00051   CloseFile();  // close file for this stream
00052 
00053 }

void PerStream::CloseFile ( void   )  [virtual]

Reimplemented in PerInputStream, and PerOutputStream.

Definition at line 57 of file PerStream.cxx.

References PerFileManager::CloseFile(), fEntry, fFullFilePathName, fPerOwned, fTBranch, fTFile, fTObject, fTTree, and PerFileManager::Instance().

00057                           {
00058   //
00059   //  Purpose:  Close current file serving this stream.
00060   //
00061   //  Arguments: none.
00062   //
00063   //  Return: none.
00064   //
00065   //  Contact:   S. Kasahara
00066   // 
00067 
00068   if ( fPerOwned && fTObject ) {
00069     delete fTObject;
00070   }
00071   fPerOwned = false;
00072   fTObject = 0;  // the cached object is not owned by the stream.
00073 
00074   // delete TTree.  This also deletes managed TBranches.
00075   if( fTTree) delete fTTree; fTTree = 0; fTBranch = 0; 
00076  
00077   // Starting with root ~v5.13 the fTTree dtor will create
00078   // a new object at the fTObject ptr address, but only 
00079   // some of the time (oddly). Check to see if a new object has
00080   // been created by the TTree dtor, and delete it if so.
00081   if ( fTObject ) delete fTObject;  fTObject = 0;
00082   
00083   if (!fFullFilePathName.empty()) {
00084     PerFileManager& filemanager = PerFileManager::Instance();
00085     filemanager.CloseFile(fFullFilePathName);
00086     fFullFilePathName = "";
00087     fTFile = 0;
00088     fEntry = -1;
00089   } 
00090 
00091   return;
00092 
00093 }

std::string PerStream::GetClassName (  )  const [inline]
Int_t PerStream::GetEntry (  )  const [inline]

Definition at line 41 of file PerStream.h.

References fEntry.

Referenced by PerInputStreamManager::Print().

00041 { return fEntry; }

Per::EErrorCode PerStream::GetErrorCode (  )  const [inline]

Definition at line 39 of file PerStream.h.

References fErrorCode.

Referenced by RotoServer::OpenFile(), OltNewModule::OpenFile(), and OltNewModule::OpenSpy().

00039 { return fErrorCode; }

std::string PerStream::GetFullFilePathName (  )  const [inline]
Int_t PerStream::GetNumEntries (  )  const [inline]
std::string PerStream::GetStreamName (  )  const [inline]
bool PerStream::GetTestMode (  )  const [inline]

Definition at line 45 of file PerStream.h.

References fTestMode.

Referenced by PerInputStream::GetObject().

00045 { return fTestMode; }

std::string PerStream::GetTreeName (  )  const [inline]
bool PerStream::IsEnabled (  )  const [inline]

Definition at line 47 of file PerStream.h.

References fEnable.

Referenced by Print(), PerOutputStream::SetObject(), PerOutputStream::Store(), and PerOutputStream::Write().

00047 { return fEnable;}

bool PerStream::IsModified (  )  const [inline]

Definition at line 51 of file PerStream.h.

References fTObject.

Referenced by PerOutputStream::SetObject(), and PerOutputStream::Store().

00051 { return (fTObject != (TObject*)0) ? true : false;}

bool PerStream::IsOpen (  )  const [inline]

Reimplemented in PerInputStream.

Definition at line 48 of file PerStream.h.

References fTFile, and fTTree.

Referenced by GetNumEntries(), PerOutputStream::IsFileChange(), PerInputStream::IsOpen(), Print(), PerOutputStream::SetObject(), PerOutputStream::Store(), and PerOutputStream::Write().

00048                       { 
00049     return (fTTree != (TTree*)0 && fTFile != (TFile*)0) ? true : false; 
00050   }

bool PerStream::IsPerOwned (  )  const [inline]

Definition at line 52 of file PerStream.h.

References fPerOwned.

Referenced by PerInputStream::GetVldContext(), Reset(), and SetPerOwnedDisabled().

00052 { return fPerOwned; }

bool PerStream::IsPerOwnedDisabled (  )  const [inline]

Definition at line 53 of file PerStream.h.

References fPerOwnedDisabled.

Referenced by PerInputStream::GetObject(), and SetPerOwned().

00053 { return fPerOwnedDisabled; }

std::ostream & PerStream::Print ( std::ostream &  s  )  const [virtual]

Reimplemented in PerInputStream, and PerOutputStream.

Definition at line 172 of file PerStream.cxx.

References fClassName, fTreeName, fTTree, IsEnabled(), and IsOpen().

Referenced by operator<<().

00172                                                  {
00173   //
00174   //  Purpose:  Print status of stream on std::ostream.
00175   //
00176   //  Arguments: ms std::ostream to display on.
00177   //
00178   //  Return:  std::ostream reference.
00179   //
00180   //  Contact:   S. Kasahara
00181   // 
00182 
00183   ms << "Stream serving tree " << fTreeName 
00184      << (IsOpen() ? " is open " : " is not open ")      << "and" 
00185      << (IsEnabled() ? " enabled." : " disabled.") << endl;
00186   if ( IsOpen() ) {
00187     ms << "  Total entries in stream tree = " << (Int_t)fTTree ->GetEntries() 
00188        << endl;
00189     ms << "  The current file assigned to this stream is " 
00190        << fTTree->GetCurrentFile()->GetName() << endl; 
00191   }
00192   ms << "  This stream serves objects of classname " << fClassName << "." 
00193      << endl;
00194 
00195   return ms;
00196 
00197 }

void PerStream::Reset ( bool  ishard = false  ) 

Definition at line 199 of file PerStream.cxx.

References fTObject, and IsPerOwned().

Referenced by PerInputStream::GetObject(), PerInputStreamManager::IsSelectedSet(), PerInputStream::Next(), PerInputStream::Previous(), and PerOutputStream::SetObject().

00199                                  {
00200   //
00201   //  Purpose:  Reset.
00202   //
00203   //  Arguments: ishard, true => implies delete or Clear object (object owned) 
00204   //                    false => implies set object ptr to 0 (default)
00205   //
00206   //  Return: none.
00207   //
00208   //  Contact:   S. Kasahara
00209   // 
00210 
00211   if (!fTObject) return;
00212   
00213   if ( IsPerOwned() ) {
00214     if (ishard) {
00215       RecRecord* recrecord = dynamic_cast<RecRecord*>(fTObject);
00216       recrecord -> Clear(); 
00217       recrecord -> HasBeenModified(); // clear tags so that i/o will repersist
00218     }
00219   }
00220   else {
00221     if ( ishard ) {
00222       if ( fTObject ) delete fTObject; 
00223       fTObject = 0;
00224     }
00225     else {
00226       // object cache not owned, reset
00227       fTObject = 0;
00228     }
00229   }
00230 
00231   return;
00232 
00233 }

void PerStream::SetEnable ( bool  enable = true  )  [inline]

Definition at line 62 of file PerStream.h.

References fEnable.

00062 { fEnable = enable; }

virtual bool PerStream::SetFile ( std::string  fullfilepathname,
Per::EAccessMode  accessmode 
) [pure virtual]

Implemented in PerOutputStream.

void PerStream::SetPerOwned ( bool  perowned = true  ) 

Definition at line 133 of file PerStream.cxx.

References fPerOwned, GetStreamName(), IsPerOwnedDisabled(), Msg::kWarning, and MSG.

Referenced by PerInputStream::GetObject().

00133                                          {
00134   //
00135   // Purpose: Designate this stream as owning it's records.  This will
00136   //          allow it to reuse the same record on each stream read to increase
00137   //          the efficiency of i/o.
00138   //
00139   // Contact: S. Kasahara
00140   //
00141 
00142   if ( perowned && IsPerOwnedDisabled() ) {
00143     MSG("Per",Msg::kWarning) 
00144       << "PerStream::SetPerOwned called for stream " << GetStreamName()
00145       << " but user has SetPerOwnedDisabled for this stream. Ignored." 
00146       << endl;
00147   }
00148   else fPerOwned = perowned;
00149 
00150   return;
00151   
00152 }

void PerStream::SetPerOwnedDisabled ( bool  perowneddisabled = true  ) 

Definition at line 156 of file PerStream.cxx.

References fPerOwned, fPerOwnedDisabled, and IsPerOwned().

00156                                                          {
00157   //
00158   // Purpose: Disable Per ownership for this stream.  
00159   //
00160   // Contact: S. Kasahara
00161   //
00162 
00163   if ( perowneddisabled && IsPerOwned() ) fPerOwned = false;
00164   fPerOwnedDisabled = perowneddisabled;
00165 
00166   return;
00167   
00168 }

virtual void PerStream::SetStreamName ( std::string  streamname  )  [inline, virtual]

Definition at line 69 of file PerStream.h.

References fStreamName.

00069 {fStreamName=streamname;} 

void PerStream::SetTestMode ( bool  testmode  )  [inline]

Definition at line 65 of file PerStream.h.

References fTestMode.

00065 { fTestMode = testmode; }


Member Data Documentation

std::string PerStream::fClassName [protected]
bool PerStream::fEnable [protected]

Definition at line 83 of file PerStream.h.

Referenced by IsEnabled(), and SetEnable().

Int_t PerStream::fEntry [protected]

Definition at line 86 of file PerStream.h.

Referenced by GetErrorCode(), and PerInputStream::SetFile().

std::string PerStream::fFullFilePathName [protected]
bool PerStream::fPerOwned [protected]
bool PerStream::fPerOwnedDisabled [protected]

Definition at line 85 of file PerStream.h.

Referenced by IsPerOwnedDisabled(), and SetPerOwnedDisabled().

std::string PerStream::fStreamName [protected]
TBranch* PerStream::fTBranch [protected]
bool PerStream::fTestMode [protected]

Definition at line 88 of file PerStream.h.

Referenced by GetTestMode(), and SetTestMode().

TFile* PerStream::fTFile [protected]
TObject* PerStream::fTObject [protected]
std::string PerStream::fTreeName [protected]
TTree* PerStream::fTTree [protected]

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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1