Effective C++ changes (Andrei)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 Aug 2006 07:57:07 +0000 (07:57 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 Aug 2006 07:57:07 +0000 (07:57 +0000)
ANALYSIS/AliAnalysisDataContainer.cxx
ANALYSIS/AliAnalysisDataContainer.h
ANALYSIS/AliAnalysisDataSlot.cxx
ANALYSIS/AliAnalysisDataSlot.h
ANALYSIS/AliAnalysisManager.cxx
ANALYSIS/AliAnalysisRLContainer.cxx
ANALYSIS/AliAnalysisRLContainer.h
ANALYSIS/AliAnalysisTask.cxx
ANALYSIS/AliAnalysisTask.h

index ed782a8..1326ebd 100644 (file)
 ClassImp(AliAnalysisDataContainer)
 
 //______________________________________________________________________________
-AliAnalysisDataContainer::AliAnalysisDataContainer()
+AliAnalysisDataContainer::AliAnalysisDataContainer() : TNamed(),
+                          fDataReady(kFALSE),
+                          fOwnedData(kFALSE),
+                          fFileName(),
+                          fData(NULL),
+                          fType(NULL),
+                          fProducer(NULL),
+                          fConsumers(NULL)
 {
 // Default ctor.
-   fDataReady = kFALSE;
-   fOwnedData  = kFALSE;
-   fFileName = "";
-   fData  = 0;
-   fType  = 0;
-   fProducer  = 0; 
-   fConsumers = 0;
 }
+
 //______________________________________________________________________________
 AliAnalysisDataContainer::AliAnalysisDataContainer(const char *name, TClass *type)
-                         :TNamed(name,"")
+                         :TNamed(name,""),
+                          fDataReady(kFALSE),
+                          fOwnedData(kTRUE),
+                          fFileName(),
+                          fData(NULL),
+                          fType(type),
+                          fProducer(NULL),
+                          fConsumers(NULL)
 {
 // Normal constructor.
-   fDataReady = kFALSE;
-   fOwnedData = kTRUE;
-   fFileName = "";
-   fData  = 0;
-   fType  = type;
-   fProducer  = 0; 
-   fConsumers = 0;
+}
+
+//______________________________________________________________________________
+AliAnalysisDataContainer::AliAnalysisDataContainer(const AliAnalysisDataContainer &cont)
+                         :TNamed(cont),
+                          fDataReady(cont.fDataReady),
+                          fOwnedData(kFALSE),
+                          fFileName(cont.fFileName),
+                          fData(cont.fData),
+                          fType(cont.fType),
+                          fProducer(cont.fProducer),
+                          fConsumers(NULL)
+{
+// Copy ctor.
+   if (cont.fConsumers) {
+      fConsumers = new TObjArray(2);
+      Int_t ncons = cont.fConsumers->GetEntriesFast();
+      for (Int_t i=0; i<ncons; i++) fConsumers->Add(cont.fConsumers->At(i));
+   }   
 }
 
 //______________________________________________________________________________
@@ -88,6 +108,27 @@ AliAnalysisDataContainer::~AliAnalysisDataContainer()
 }
 
 //______________________________________________________________________________
+AliAnalysisDataContainer &AliAnalysisDataContainer::operator=(const AliAnalysisDataContainer &cont)
+{
+// Assignment.
+   if (&cont != this) {
+      TNamed::operator=(cont);
+      fDataReady = cont.fDataReady;
+      fOwnedData = kFALSE;  // !!! Data owned by cont.
+      fFileName = cont.fFileName;
+      fData = cont.fData;
+      fType = cont.fType;
+      fProducer = cont.fProducer;
+      if (cont.fConsumers) {
+         fConsumers = new TObjArray(2);
+         Int_t ncons = cont.fConsumers->GetEntriesFast();
+         for (Int_t i=0; i<ncons; i++) fConsumers->Add(cont.fConsumers->At(i));
+      }   
+   }   
+   return *this;
+}      
+
+//______________________________________________________________________________
 Bool_t AliAnalysisDataContainer::SetData(TObject *data, Option_t *option)
 {
 // Set the data as READY only if it was published by the producer.
index dc16665..4c49ca2 100644 (file)
@@ -34,9 +34,12 @@ enum ENotifyMessage {
    kFileChange
 };   
    AliAnalysisDataContainer();
+   AliAnalysisDataContainer(const AliAnalysisDataContainer &cont);
    AliAnalysisDataContainer(const char *name, TClass *type);
    virtual ~AliAnalysisDataContainer();
 
+   // Assignment
+   AliAnalysisDataContainer &operator=(const AliAnalysisDataContainer &cont);
    // Getters
    TObject                  *GetData() const      {return fData;}
    TClass                   *GetType() const      {return fType;}
index 9804a95..ffbc848 100644 (file)
 ClassImp(AliAnalysisDataSlot)
 
 //______________________________________________________________________________
+AliAnalysisDataSlot& AliAnalysisDataSlot::operator=(const AliAnalysisDataSlot &slot)
+{
+// Assignment
+   if (&slot == this) return *this;
+   TObject::operator=(slot);
+   fType = slot.fType;
+   fParent = slot.fParent;
+   fContainer = slot.fContainer;   
+   return *this;
+}
+
+//______________________________________________________________________________
 Bool_t AliAnalysisDataSlot::ConnectContainer(AliAnalysisDataContainer *cont)
 {
 // Connect the data slot with a given container. The operation will succeed only
index 2062bf3..b0513e8 100644 (file)
@@ -24,10 +24,13 @@ class AliAnalysisTask;
 class AliAnalysisDataSlot : public TObject {
 
 public:
-   AliAnalysisDataSlot() : fType(NULL), fParent(NULL), fContainer(NULL) { }
-   AliAnalysisDataSlot(TClass *type, AliAnalysisTask *task) : fType(type), fParent(task), fContainer(NULL) { }
-   virtual ~AliAnalysisDataSlot() { }
-   
+   AliAnalysisDataSlot() : fType(NULL), fParent(NULL), fContainer(NULL) {}
+   AliAnalysisDataSlot(TClass *type, AliAnalysisTask *task) : fType(type), fParent(task), fContainer(NULL) {}
+   AliAnalysisDataSlot(const AliAnalysisDataSlot &slot) : TObject(), fType(slot.fType), fParent(slot.fParent), fContainer(slot.fContainer) {}
+   virtual ~AliAnalysisDataSlot() {}
+
+   // Assignment
+   AliAnalysisDataSlot &operator=(const AliAnalysisDataSlot &slot);
    // Connect some container to the slot
    Bool_t                    ConnectContainer(AliAnalysisDataContainer *cont);
    // Getters
index b5cbda9..e9c6ed1 100644 (file)
 ClassImp(AliAnalysisManager)
 
 //______________________________________________________________________________
-AliAnalysisManager::AliAnalysisManager() : TSelector()
+AliAnalysisManager::AliAnalysisManager() : TSelector(),
+                    fInitOK(kFALSE),
+                    fContainers(NULL),
+                    fInputs(NULL),
+                    fOutputs(NULL),
+                    fTasks(NULL),
+                    fTopTasks(NULL),
+                    fZombies(NULL)
 {
 // Default constructor.
-   if (TClass::IsCallingNew() == TClass::kDummyNew) {
-      fInitOK     = kFALSE;
-      fContainers = 0;
-      fInputs     = 0;
-      fOutputs    = 0;  
-      fTasks      = 0;
-      fTopTasks   = 0;
-      fZombies    = 0;
-      fStatus     = 0;
-   } else {    
-      fInitOK     = kFALSE;
+   if (TClass::IsCallingNew() != TClass::kDummyNew) {
       fContainers = new TObjArray();
       fInputs     = new TObjArray();
       fOutputs    = new TObjArray();  
@@ -62,16 +59,23 @@ AliAnalysisManager::AliAnalysisManager() : TSelector()
 
 //______________________________________________________________________________
 AliAnalysisManager::AliAnalysisManager(const AliAnalysisManager& other)
-                   :TSelector(other)
+                   :TSelector(other),
+                    fInitOK(kFALSE),
+                    fContainers(NULL),
+                    fInputs(NULL),
+                    fOutputs(NULL),
+                    fTasks(NULL),
+                    fTopTasks(NULL),
+                    fZombies(NULL)
 {
 // Copy constructor.
-   fInitOK     = other.IsInitialized();
-   fContainers = new TObjArray(*other.GetContainers());
-   fInputs     = new TObjArray(*other.GetInputs());
-   fOutputs    = new TObjArray(*other.GetOutputs());
-   fTasks      = new TObjArray(*other.GetTasks());
-   fTopTasks   = new TObjArray(*other.GetTopTasks());
-   fZombies    = new TObjArray(*other.GetZombieTasks());
+   fInitOK     = other.fInitOK;
+   fContainers = new TObjArray(*other.fContainers);
+   fInputs     = new TObjArray(*other.fInputs);
+   fOutputs    = new TObjArray(*other.fOutputs);
+   fTasks      = new TObjArray(*other.fTasks);
+   fTopTasks   = new TObjArray(*other.fTopTasks);
+   fZombies    = new TObjArray(*other.fZombies);
 //   fStatus     = new AliAnalysisInfo(this);
 }
    
@@ -81,13 +85,13 @@ AliAnalysisManager& AliAnalysisManager::operator=(const AliAnalysisManager& othe
 // Assignment
    if (&other != this) {
       TSelector::operator=(other);
-      fInitOK     = other.IsInitialized();
-      fContainers = new TObjArray(*other.GetContainers());
-      fInputs     = new TObjArray(*other.GetInputs());
-      fOutputs    = new TObjArray(*other.GetOutputs());
-      fTasks      = new TObjArray(*other.GetTasks());
-      fTopTasks   = new TObjArray(*other.GetTopTasks());
-      fZombies    = new TObjArray(*other.GetZombieTasks());
+      fInitOK     = other.fInitOK;
+      fContainers = new TObjArray(*other.fContainers);
+      fInputs     = new TObjArray(*other.fInputs);
+      fOutputs    = new TObjArray(*other.fOutputs);
+      fTasks      = new TObjArray(*other.fTasks);
+      fTopTasks   = new TObjArray(*other.fTopTasks);
+      fZombies    = new TObjArray(*other.fZombies);
 //      fStatus     = new AliAnalysisInfo(this);
    }
    return *this;
index 7bfaf2e..6c35e24 100644 (file)
@@ -37,34 +37,62 @@ ClassImp(AliAnalysisRLContainer)
 
 //______________________________________________________________________________
 AliAnalysisRLContainer::AliAnalysisRLContainer()
+                       :AliAnalysisDataContainer(),
+                        fRunLoader(NULL),
+                        fESD(NULL),
+                        fKineFile(NULL),
+                        fKinematicsLoaded(kFALSE),
+                        fHeaderLoaded(kFALSE)
 {
 // Dummy ctor.
-   fRunLoader = 0;
-   fESD = 0;
-   fKineFile = 0;
-   fKinematicsLoaded = kFALSE;
-   fHeaderLoaded = kFALSE;
 }
 
 //______________________________________________________________________________
 AliAnalysisRLContainer::AliAnalysisRLContainer(const char *name)
-                       :AliAnalysisDataContainer(name, TTree::Class())
+                       :AliAnalysisDataContainer(name, TTree::Class()),
+                        fRunLoader(NULL),
+                        fESD(NULL),
+                        fKineFile(NULL),
+                        fKinematicsLoaded(kFALSE),
+                        fHeaderLoaded(kFALSE)
 {
 // Normal constructor.
-   fRunLoader = 0;
-   fESD = 0;
-   fKineFile = 0;
-   fKinematicsLoaded = kFALSE;
-   fHeaderLoaded = kFALSE;
 }
 
 //______________________________________________________________________________
+AliAnalysisRLContainer::AliAnalysisRLContainer(const AliAnalysisRLContainer &rlc)
+                       :AliAnalysisDataContainer(rlc),
+                        fRunLoader(rlc.fRunLoader),
+                        fESD(rlc.fESD),
+                        fKineFile(rlc.fKineFile),
+                        fKinematicsLoaded(rlc.fKinematicsLoaded),
+                        fHeaderLoaded(rlc.fHeaderLoaded)
+{
+// Copy constructor.
+}   
+
+//______________________________________________________________________________
 AliAnalysisRLContainer::~AliAnalysisRLContainer()
 {
 // Destructor. Deletes data ! (What happens if data is a container ???)
 }
 
 //______________________________________________________________________________
+AliAnalysisRLContainer &AliAnalysisRLContainer::operator=(const AliAnalysisRLContainer &rlc)
+{
+// Assignment.
+   if (&rlc != this) {
+      AliAnalysisDataContainer::operator=(rlc);
+      fRunLoader = rlc.fRunLoader;
+      fESD = rlc.fESD;
+      fKineFile = rlc.fKineFile;
+      fKinematicsLoaded = rlc.fKinematicsLoaded;
+      fHeaderLoaded = rlc.fHeaderLoaded;
+   }
+   return *this;   
+}
+
+//______________________________________________________________________________
 Bool_t AliAnalysisRLContainer::SetData(TObject *data, Option_t */*option*/)
 {
 // Data must be a tree here.
index 3eca65b..8a24f82 100644 (file)
@@ -26,9 +26,10 @@ class AliAnalysisRLContainer : public AliAnalysisDataContainer {
 public:
    AliAnalysisRLContainer();
    AliAnalysisRLContainer(const char *name);
+   AliAnalysisRLContainer(const AliAnalysisRLContainer &rlc);
    virtual ~AliAnalysisRLContainer();
    
-//protected:
+   AliAnalysisRLContainer &operator=(const AliAnalysisRLContainer &rlc);
    AliRunLoader             *GetRunLoader();
    AliHeader                *GetHeader();
    AliStack                 *GetStack();
index 68cd15b..a61b2d8 100644 (file)
@@ -58,39 +58,45 @@ ClassImp(AliAnalysisTask)
 
 //______________________________________________________________________________
 AliAnalysisTask::AliAnalysisTask()
+                :fReady(kFALSE),
+                 fNinputs(0),
+                 fNoutputs(0),
+                 fOutputReady(NULL),
+                 fPublishedData(NULL),
+                 fInputs(NULL),
+                 fOutputs(NULL)
 {
 // Default constructor.
-   fReady       = kFALSE;
-   fNinputs     = 0;
-   fNoutputs    = 0;
-   fOutputReady = 0;
-   fPublishedData = 0;
-   fInputs      = 0;
-   fOutputs     = 0;
 }
 
 //______________________________________________________________________________
 AliAnalysisTask::AliAnalysisTask(const char *name, const char *title)
-                :TTask(name,title)
+                :TTask(name,title),
+                 fReady(kFALSE),
+                 fNinputs(0),
+                 fNoutputs(0),
+                 fOutputReady(NULL),
+                 fPublishedData(NULL),
+                 fInputs(NULL),
+                 fOutputs(NULL)                 
 {
-// Named constructor.
-   fReady       = kFALSE;
-   fNinputs     = 0;
-   fNoutputs    = 0;
-   fOutputReady = 0;
-   fPublishedData = 0;
+// Constructor.
    fInputs      = new TObjArray(2);
    fOutputs     = new TObjArray(2);
 }
 
 //______________________________________________________________________________
 AliAnalysisTask::AliAnalysisTask(const AliAnalysisTask &task)
-                :TTask(task)
+                :TTask(task),
+                 fReady(task.fReady),
+                 fNinputs(task.fNinputs),
+                 fNoutputs(task.fNoutputs),                 
+                 fOutputReady(NULL),
+                 fPublishedData(NULL),
+                 fInputs(NULL),
+                 fOutputs(NULL)                 
 {
 // Copy ctor.
-   fReady       = task.IsReady();
-   fNinputs     = task.GetNinputs();
-   fNoutputs    = task.GetNoutputs();
    fInputs      = new TObjArray((fNinputs)?fNinputs:2);
    fOutputs     = new TObjArray((fNoutputs)?fNoutputs:2);
    fPublishedData = 0;
@@ -115,22 +121,21 @@ AliAnalysisTask::~AliAnalysisTask()
 AliAnalysisTask& AliAnalysisTask::operator=(const AliAnalysisTask& task)
 {
 // Assignment
-   if (&task != this) {
-      TTask::operator=(task);
-      fReady       = task.IsReady();
-      fNinputs     = task.GetNinputs();
-      fNoutputs    = task.GetNoutputs();
-      fInputs      = new TObjArray((fNinputs)?fNinputs:2);
-      fOutputs     = new TObjArray((fNoutputs)?fNoutputs:2);
-      fPublishedData = 0;
-      Int_t i;
-      for (i=0; i<fNinputs; i++) fInputs->AddAt(task.GetInputSlot(i),i);
-      fOutputReady = new Bool_t[(fNoutputs)?fNoutputs:2];
-      for (i=0; i<fNoutputs; i++) {
-         fOutputReady[i] = IsOutputReady(i);
-         fOutputs->AddAt(task.GetOutputSlot(i),i);
-      }         
-   }
+   if (&task == this) return *this;
+   TTask::operator=(task);
+   fReady       = task.IsReady();
+   fNinputs     = task.GetNinputs();
+   fNoutputs    = task.GetNoutputs();
+   fInputs      = new TObjArray((fNinputs)?fNinputs:2);
+   fOutputs     = new TObjArray((fNoutputs)?fNoutputs:2);
+   fPublishedData = 0;
+   Int_t i;
+   for (i=0; i<fNinputs; i++) fInputs->AddAt(new AliAnalysisDataSlot(*task.GetInputSlot(i)),i);
+   fOutputReady = new Bool_t[(fNoutputs)?fNoutputs:2];
+   for (i=0; i<fNoutputs; i++) {
+      fOutputReady[i] = IsOutputReady(i);
+      fOutputs->AddAt(new AliAnalysisDataSlot(*task.GetOutputSlot(i)),i);
+   }         
    return *this;
 }
 
index bf99b20..cb53b22 100644 (file)
@@ -32,8 +32,6 @@ enum EAnalysisTaskFlags {
    kTaskChecked = BIT(16)
 };   
 protected:
-   AliAnalysisTask& operator=(const AliAnalysisTask &task);
-
    // Define the input/output slots (called by user in the ctor of the derived class)
    //=== CALL IN THE CONSTRUCTOR OF DERIVED CLASS TO DEFINE INPUTS/OUTPUTS ===
    void                      DefineInput(Int_t islot, TClass *type);
@@ -51,6 +49,8 @@ public:
    AliAnalysisTask(const AliAnalysisTask &task); 
    virtual ~AliAnalysisTask();
    
+   // Assignment
+   AliAnalysisTask& operator=(const AliAnalysisTask &task);
    // Conect inputs/outputs to data containers (by AliAnalysisModule)
    Bool_t                    ConnectInput(Int_t islot, AliAnalysisDataContainer *cont);
    Bool_t                    ConnectOutput(Int_t islot, AliAnalysisDataContainer *cont);