Merge changes from branches/dev/EVE. This branch was following development in ROOT...
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHOMERSourceMap.h
CommitLineData
a15e6d7d 1// $Id$
2// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
9
10#ifndef AliEveAliEveHOMERSourceMap_H
11#define AliEveAliEveHOMERSourceMap_H
12
13#include "AliEveHOMERSource.h"
14
15#include <TNamed.h>
16
17#include <map>
18
19class AliEveHOMERSourceMap : public TNamed
20{
21protected:
22 struct iterator_imp_base
23 {
24 virtual ~iterator_imp_base() {}
25
26 virtual const AliEveHOMERSource::SourceId& id() = 0;
27 virtual AliEveHOMERSource::SourceState& state() = 0;
28
29 virtual iterator_imp_base* clone() = 0;
30
31 virtual iterator_imp_base& operator++() = 0;
32 virtual bool operator!=(const iterator_imp_base& o) = 0;
33
34 virtual TString description() = 0;
35 };
36
37public:
38 struct iterator
39 {
40 iterator_imp_base* m_imp;
41
42 iterator() : m_imp(0) {}
43 iterator(iterator_imp_base* imp) : m_imp(imp) {}
44 ~iterator() { delete m_imp; }
45
46 iterator& operator= (const iterator& o) { delete m_imp; m_imp = o.m_imp->clone(); return *this; }
47 bool operator!=(const iterator& o) { return m_imp->operator!=(*o.m_imp); }
48
49 const AliEveHOMERSource::SourceId& id() { return m_imp->id(); }
50 AliEveHOMERSource::SourceState& state() { return m_imp->state(); }
51
52 Int_t level();
53 TString description() { return m_imp->description(); }
54
55 iterator& operator++() { m_imp->operator++(); return *this; }
56 iterator& skip_children()
57 {
58 Int_t lvl = level();
59 do operator++(); while (level() > lvl);
60 return *this;
61 }
62 };
63
64 iterator begin() { return iterator(iterator_imp_begin()); }
65 iterator end() { return iterator(iterator_imp_end()); }
66
67 enum ESourceGrouping_e { kSG_ByDet, kSG_ByType };
68
69protected:
70 ESourceGrouping_e fGrouping; // Not used so far ...
71
72 virtual iterator_imp_base* iterator_imp_new() = 0; // Not used so far ...
73 virtual iterator_imp_base* iterator_imp_begin() = 0;
74 virtual iterator_imp_base* iterator_imp_end() = 0;
75
76public:
77 AliEveHOMERSourceMap(ESourceGrouping_e grouping);
78 virtual ~AliEveHOMERSourceMap() {}
79
80 static AliEveHOMERSourceMap* Create(ESourceGrouping_e grouping);
81
82 virtual void FillMap(TList* handles, Bool_t def_state) = 0;
83
84 void PrintXXX();
85
86 ClassDef(AliEveHOMERSourceMap, 0);
87};
88
89/******************************************************************************/
90
91class AliEveHOMERSourceMapByDet : public AliEveHOMERSourceMap
92{
93protected:
94 typedef std::map<AliEveHOMERSource::SourceId,
95 AliEveHOMERSource::SourceState,
96 AliEveHOMERSource::SourceId::CmpByDet> Map_t;
97 typedef Map_t::iterator Map_i;
98
99 Map_t fMap;
100
101 struct iterator_imp : public iterator_imp_base,
102 public Map_i
103 {
104 iterator_imp() : Map_i() {}
105 iterator_imp(Map_i mi) : Map_i(mi) {}
106 virtual ~iterator_imp() {}
107
108 virtual const AliEveHOMERSource::SourceId& id() { return Map_i::operator*().first; }
109 virtual AliEveHOMERSource::SourceState& state() { return Map_i::operator*().second; }
110
111 virtual iterator_imp* clone()
112 { return new iterator_imp(*this); }
113
114 virtual iterator_imp& operator++()
115 { Map_i::operator++(); return *this; }
116
117 virtual bool operator!=(const iterator_imp_base& o)
118 { return Map_i::operator!=(dynamic_cast<const Map_i&>(o)); }
119
120 virtual TString description();
121 };
122
123 void insert(AliEveHOMERSource::SourceId& sid, AliEveHOMERSource::SourceState& sst, Bool_t def_state);
124
125 virtual iterator_imp_base* iterator_imp_new() { return new iterator_imp; }
126 virtual iterator_imp_base* iterator_imp_begin() { return new iterator_imp(fMap.begin()); }
127 virtual iterator_imp_base* iterator_imp_end() { return new iterator_imp(fMap.end()); }
128
129public:
130 AliEveHOMERSourceMapByDet(ESourceGrouping_e grouping);
131 virtual ~AliEveHOMERSourceMapByDet() {}
132
133 virtual void FillMap(TList* handles, Bool_t def_state);
134
135 // ClassDef(AliEveHOMERSourceMapByDet, 1);
136};
137
138/******************************************************************************/
139
140class AliEveHOMERSourceMapByType : public AliEveHOMERSourceMap
141{
142protected:
143 typedef std::map<AliEveHOMERSource::SourceId,
144 AliEveHOMERSource::SourceState,
145 AliEveHOMERSource::SourceId::CmpByType> Map_t;
146 typedef Map_t::iterator Map_i;
147
148 Map_t fMap;
149
150 struct iterator_imp : public iterator_imp_base,
151 public Map_i
152 {
153 iterator_imp() : Map_i() {}
154 iterator_imp(Map_i mi) : Map_i(mi) {}
155 virtual ~iterator_imp() {}
156
157 virtual const AliEveHOMERSource::SourceId& id() { return Map_i::operator*().first; }
158 virtual AliEveHOMERSource::SourceState& state() { return Map_i::operator*().second; }
159
160 virtual iterator_imp* clone()
161 { return new iterator_imp(*this); }
162
163 virtual iterator_imp& operator++()
164 { Map_i::operator++(); return *this; }
165
166 virtual bool operator!=(const iterator_imp_base& o)
167 { return Map_i::operator!=(dynamic_cast<const Map_i&>(o)); }
168
169 virtual TString description();
170 };
171
172 void insert(AliEveHOMERSource::SourceId& sid, AliEveHOMERSource::SourceState& sst, Bool_t def_state);
173
174 virtual iterator_imp_base* iterator_imp_new() { return new iterator_imp; }
175 virtual iterator_imp_base* iterator_imp_begin() { return new iterator_imp(fMap.begin()); }
176 virtual iterator_imp_base* iterator_imp_end() { return new iterator_imp(fMap.end()); }
177
178public:
179 AliEveHOMERSourceMapByType(ESourceGrouping_e grouping);
180 virtual ~AliEveHOMERSourceMapByType() {}
181
182 virtual void FillMap(TList* handles, Bool_t def_state);
183
184 // ClassDef(AliEveHOMERSourceMapByType, 1);
185};
186
187#endif