1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz 04/2002 <mailto:tbretz@uni-sw.gwdg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2002
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MDataList
|
---|
28 | // Chain, catenation ?
|
---|
29 | //
|
---|
30 | /////////////////////////////////////////////////////////////////////////////
|
---|
31 |
|
---|
32 | #include "MDataMember.h"
|
---|
33 |
|
---|
34 | #include <TMethodCall.h>
|
---|
35 |
|
---|
36 | #include "MLog.h"
|
---|
37 | #include "MLogManip.h"
|
---|
38 |
|
---|
39 | #include "MParList.h"
|
---|
40 |
|
---|
41 | ClassImp(MDataMember);
|
---|
42 |
|
---|
43 | MDataMember::MDataMember(MParContainer *obj, TMethodCall *call)
|
---|
44 | {
|
---|
45 | fObject = obj;
|
---|
46 | fCall = call;
|
---|
47 | }
|
---|
48 |
|
---|
49 | Double_t MDataMember::GetValue() const
|
---|
50 | {
|
---|
51 | if (!fCall)
|
---|
52 | return 0;
|
---|
53 |
|
---|
54 | switch (fCall->ReturnType())
|
---|
55 | {
|
---|
56 | case TMethodCall::kLong:
|
---|
57 | Long_t l;
|
---|
58 | fCall->Execute(fObject, l);
|
---|
59 | return (Double_t)l;
|
---|
60 |
|
---|
61 | case TMethodCall::kDouble:
|
---|
62 | Double_t v;
|
---|
63 | fCall->Execute(fObject, v);
|
---|
64 | return v;
|
---|
65 |
|
---|
66 | default:
|
---|
67 | *fLog << err << "DataMember " << fName << " of ";
|
---|
68 | *fLog << fObject->GetName() << " neither int nor float... abort." << endl;
|
---|
69 | return 0;
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | Bool_t MDataMember::PreProcess(const MParList *plist)
|
---|
74 | {
|
---|
75 | TString cname(fName);
|
---|
76 | TString mname(fName);
|
---|
77 |
|
---|
78 | const char *dot = strrchr(cname, '.');
|
---|
79 |
|
---|
80 | if (dot)
|
---|
81 | {
|
---|
82 | const int pos = dot-cname;
|
---|
83 |
|
---|
84 | cname.Remove(pos);
|
---|
85 | mname.Remove(0, pos+1);
|
---|
86 | }
|
---|
87 |
|
---|
88 | fObject = (MParContainer*)plist->FindObject(cname);
|
---|
89 | if (!fObject)
|
---|
90 | {
|
---|
91 | *fLog << err << "Object '" << cname << "' not in parameter list... aborting." << endl;
|
---|
92 | return kFALSE;
|
---|
93 | }
|
---|
94 |
|
---|
95 | fCall = fObject->GetterMethod(mname);
|
---|
96 |
|
---|
97 | return fCall ? kTRUE : kFALSE;
|
---|
98 | }
|
---|
99 |
|
---|
100 | void MDataMember::Print(Option_t *opt = "") const
|
---|
101 | {
|
---|
102 | *fLog << fName << flush;
|
---|
103 | }
|
---|
104 |
|
---|