]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliAnalysisDataSlot.cxx
EffC++ warnings corrected.
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisDataSlot.cxx
CommitLineData
d3106602 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17// Author: Andrei Gheata, 31/05/2006
18
19//==============================================================================
20// AliAnalysysDataSlot - Class representing a data slot of an analysis task.
21// An analysis slot enforces a certain data type required by the Exec()
22// method of the analysis task. The slot must be connected to a data
23// container with data of the same type.
24//
25// The class should not be directly created by users - it is created by
26// each AliAnalysisTask when defining its input/output slots using:
27//
28// AliAnalysisTask::SetInput(Int_t index, TClass *type);
29// AliAnalysisTask::SetOutput(TClass *type);
30//
31// An existing data contaner (AliAnalysisDataContainer) can be connected to the
32// input/output slots of an analysis task using:
33//
34// AliAnalysisModule::ConnectInput(AliAnalysisTask *task, Int_t islot,
35// AliAnalysisDataContainer *cont)
36// AliAnalysisModule::ConnectOutput(AliAnalysisTask *task,
37// AliAnalysisDataContainer *cont)
38// To connect a slot to a data container, the data types declared by both must
39// match.
40//==============================================================================
41
42#include "TClass.h"
43#include "AliLog.h"
44
45#include "AliAnalysisDataSlot.h"
46#include "AliAnalysisTask.h"
47#include "AliAnalysisDataContainer.h"
48
49ClassImp(AliAnalysisDataSlot)
50
37a26056 51//______________________________________________________________________________
52AliAnalysisDataSlot& AliAnalysisDataSlot::operator=(const AliAnalysisDataSlot &slot)
53{
54// Assignment
55 if (&slot == this) return *this;
56 TObject::operator=(slot);
57 fType = slot.fType;
58 fParent = slot.fParent;
59 fContainer = slot.fContainer;
60 return *this;
61}
62
d3106602 63//______________________________________________________________________________
64Bool_t AliAnalysisDataSlot::ConnectContainer(AliAnalysisDataContainer *cont)
65{
66// Connect the data slot with a given container. The operation will succeed only
67// if the type defined by the slot inherits from the type enforced by the container.
68// The error message in case of failure is posted by the caller.
69 if (!cont || !fType) return kFALSE;
70 if (!fType->InheritsFrom(cont->GetType())) {
71 AliError(Form("Data slot of type %s of task %s cannot be connected to data container %s of type %s",
72 fType->GetName(), fParent->GetName(), cont->GetName(), cont->GetType()->GetName()));
73 return kFALSE;
74 }
75 fContainer = cont;
76 return kTRUE;
77}
78
79//______________________________________________________________________________
80TObject *AliAnalysisDataSlot::GetData() const
81{
82// Retreives the data from the container if it is ready.
83 if (!fContainer) {
84 AliError(Form("Data slot of type %s of task %s has no connected data container",
85 fType->GetName(), fParent->GetName()));
86 return NULL;
87 }
88 if (!fContainer->IsDataReady()) return NULL;
89 return fContainer->GetData();
90}
91
92//______________________________________________________________________________
93Bool_t AliAnalysisDataSlot::IsDataReady() const
94{
95// Check if data for this slot is ready in its container.
96 if (!fContainer) {
97 AliError(Form("Data slot of type %s of task %s has no connected data container",
98 fType->GetName(), fParent->GetName()));
99 return kFALSE;
100 }
101 return fContainer->IsDataReady();
102}
103