12 #ifndef ROOT_TParameter
13 #define ROOT_TParameter
36 template <
class AParamType>
37 class TParameter :
public TObject {
41 enum EStatusBits { kMultiply = BIT(16),
53 void Reset() { ResetBit(kMultiply); ResetBit(kMax); ResetBit(kMin);
54 ResetBit(kFirst); ResetBit(kLast); }
57 TParameter(): fVal() { Reset(); SetBit(kIsConst); }
58 TParameter(
const char *name,
const AParamType &val)
59 : fName(name), fVal(val) { Reset(); SetBit(kIsConst);}
60 TParameter(
const char *name,
const AParamType &val,
char mergemode)
61 : fName(name), fVal(val) { SetMergeMode(mergemode); SetBit(kIsConst);}
65 ROOT::CallRecursiveRemoveIfNeeded(*
this);
68 const char *GetName()
const {
return fName; }
69 const AParamType &GetVal()
const {
return fVal; }
70 Bool_t IsConst()
const {
return (TestBit(kIsConst) ? kTRUE : kFALSE); }
71 void SetVal(
const AParamType &val) { fVal = val; }
80 void SetMergeMode(
char mergemode =
'+') {
82 if (mergemode ==
'*') {
84 }
else if (mergemode ==
'M') {
86 }
else if (mergemode ==
'm') {
88 }
else if (mergemode ==
'f') {
90 }
else if (mergemode ==
'l') {
94 virtual ULong_t Hash()
const {
return fName.Hash(); }
95 virtual Bool_t IsSortable()
const {
return kTRUE; }
96 virtual Int_t Compare(
const TObject *obj)
const {
100 if (
this == obj)
return 0;
101 return fName.CompareTo(obj->GetName());
104 virtual void ls(Option_t *)
const {
106 TROOT::IndentLevel();
107 std::cout <<
"OBJ: " << IsA()->GetName() <<
"\t" << fName <<
" = " << fVal << std::endl;
110 virtual void Print(Option_t *)
const {
112 TROOT::IndentLevel();
113 std::cout << IsA()->GetName() <<
"\t" << fName <<
" = " << fVal << std::endl;
116 virtual Int_t Merge(TCollection *in);
118 ClassDef(TParameter,2)
121 template <
class AParamType>
122 inline Int_t TParameter<AParamType>::Merge(TCollection *in) {
127 while (TObject *o = nxo()) {
128 TParameter<AParamType> *c =
dynamic_cast<TParameter<AParamType> *
>(o);
131 if (fVal != c->GetVal()) ResetBit(kIsConst);
132 if (TestBit(kMultiply)) {
135 }
else if (TestBit(kMax)) {
137 if (c->GetVal() > fVal) fVal = c->GetVal();
138 }
else if (TestBit(kMin)) {
140 if (c->GetVal() < fVal) fVal = c->GetVal();
141 }
else if (TestBit(kLast)) {
144 }
else if (!TestBit(kFirst)) {
157 inline Int_t TParameter<Bool_t>::Merge(TCollection *in)
163 while (TObject *o = nxo()) {
164 TParameter<Bool_t> *c =
dynamic_cast<TParameter<Bool_t> *
>(o);
167 if (fVal != (Bool_t) c->GetVal()) ResetBit(kIsConst);
168 if (TestBit(TParameter::kMultiply) || TestBit(kMin)) {
170 fVal &= (Bool_t) c->GetVal();
171 }
else if (TestBit(kLast)) {
173 fVal = (Bool_t) c->GetVal();
174 }
else if (!TestBit(kFirst) || TestBit(kMax)) {
176 fVal |= (Bool_t) c->GetVal();
193 template <>
void TParameter<Long64_t>::Streamer(TBuffer &R__b);
194 template<> TClass *TParameter<Long64_t>::Class();