Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ConfigRecord.cxx

Go to the documentation of this file.
00001 
00002 // $Id: ConfigRecord.cxx,v 1.4 2003/05/17 02:02:53 gmieg Exp $
00003 //
00004 // ConfigRecord.cxx
00005 //
00006 // ConfigRecord holds AlgConfig objects for retrieval via a TRef
00007 // in the Candidate base class, CandBase.
00008 //
00009 // Author:  G. Irwin 5/2003
00011 
00012 #include "TObjArray.h"
00013 
00014 #include "Algorithm/AlgConfig.h"
00015 #include "Algorithm/ConfigRecord.h"
00016 #include "Record/RecHeader.h"
00017 
00018 ClassImp(ConfigRecord)
00019 
00020 //______________________________________________________________________
00021 ConfigRecord::ConfigRecord() :
00022   RecDataRecord<RecHeader>()
00023 , fOwnsConfigs(kTRUE)       // ConfigRecord owns AlgConfigs when read-in
00024 {
00025 // Config ownership must be false in writing job and true in reading job
00026 // So use fOwnsConfigs(kTRUE) instead of TObjArray::SetOwner(kTRUE).
00027 }
00028 
00029 //______________________________________________________________________
00030 ConfigRecord::ConfigRecord(const RecHeader& header) :
00031   RecDataRecord<RecHeader>(header)
00032 , fOwnsConfigs(kFALSE)      // AlgFactory owns AlgConfigs in writing job
00033 {
00034 // Config ownership must be false in writing job and true in reading job
00035 // So use fOwnsConfigs(kFALSE) instead of TObjArray::SetOwner(kFALSE).
00036 }
00037 
00038 //______________________________________________________________________
00039 ConfigRecord::~ConfigRecord()
00040 {
00041 
00042 // TObjArray::Delete() crashes even when TObjArray is "non-owned" (bug?)
00043 // So use TObjArray::RemoveAll() before ~RecDataRecord invokes Delete().
00044 
00045 // Config ownership must be false in writing job and true in reading job
00046 // So test "fOwnsConfigs==kFALSE", not "TObjArray::IsOwner()==kFALSE"
00047 
00048 // RecDataRecord::fComponents should be "protected:" to avoid const_cast
00049    TObjArray &toa = (const_cast <TObjArray &> (GetComponents()));
00050    if (fOwnsConfigs == kFALSE) {
00051      toa.SetOwner(kFALSE); // Limits damage from ~RecDataRecord's Delete
00052      toa.RemoveAll();
00053    }
00054 }
00055 
00056 //______________________________________________________________________
00057 TIter ConfigRecord::GetConfigIter(Bool_t dir)
00058 {
00059    return TIter(&GetComponents(), dir);
00060 }
00061 
00062 
00063 //______________________________________________________________________
00064 void ConfigRecord::SecureConfig(AlgConfig &ac)
00065 {
00066 
00067 // Secure an AlgConfig object.  It saves a non-owned AlgConfig pointer.
00068    AdoptComponent(&ac);
00069 }

Generated on Mon Feb 15 11:06:32 2010 for loon by  doxygen 1.3.9.1