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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MTaskInteractive
|
---|
28 | //
|
---|
29 | // Input Containers:
|
---|
30 | // -/-
|
---|
31 | //
|
---|
32 | // Output Containers:
|
---|
33 | // -/-
|
---|
34 | //
|
---|
35 | /////////////////////////////////////////////////////////////////////////////
|
---|
36 | #include "MTaskInteractive.h"
|
---|
37 |
|
---|
38 | #include <Api.h>
|
---|
39 | #include <TMethodCall.h>
|
---|
40 |
|
---|
41 | #include "MLog.h"
|
---|
42 | #include "MLogManip.h"
|
---|
43 |
|
---|
44 | ClassImp(MTaskInteractive);
|
---|
45 |
|
---|
46 | using namespace std;
|
---|
47 |
|
---|
48 | // --------------------------------------------------------------------------
|
---|
49 | //
|
---|
50 | //
|
---|
51 | MTaskInteractive::MTaskInteractive(const char *name, const char *title) :
|
---|
52 | fPreProcess(NULL), fProcess(NULL), fPostProcess(NULL)
|
---|
53 | {
|
---|
54 | fName = name ? name : "MTaskInteractive";
|
---|
55 | fTitle = title ? title : "Interactive task";
|
---|
56 |
|
---|
57 | fCall[0] = 0;
|
---|
58 | fCall[1] = 0;
|
---|
59 | fCall[2] = 0;
|
---|
60 | }
|
---|
61 |
|
---|
62 | MTaskInteractive::~MTaskInteractive()
|
---|
63 | {
|
---|
64 | Free(0);
|
---|
65 | Free(1);
|
---|
66 | Free(2);
|
---|
67 | }
|
---|
68 |
|
---|
69 | inline Bool_t MTaskInteractive::Return(Int_t no, void *params)
|
---|
70 | {
|
---|
71 | // Static function called when SetFCN is called in interactive mode
|
---|
72 | if (!fCall[no])
|
---|
73 | {
|
---|
74 | gLog << err << dbginf << "Return(" << no << ") - TMethodCall not set." << endl;
|
---|
75 | return kFALSE;
|
---|
76 | }
|
---|
77 |
|
---|
78 | Long_t result;
|
---|
79 | fCall[no]->Execute(params, result);
|
---|
80 | return result;
|
---|
81 | }
|
---|
82 |
|
---|
83 | Bool_t MTaskInteractive::Set(void *fcn, Int_t no, const char *params)
|
---|
84 | {
|
---|
85 | // this function is called by CINT instead of the function above
|
---|
86 | if (!fcn)
|
---|
87 | return kFALSE;
|
---|
88 |
|
---|
89 | char *funcname = G__p2f2funcname(fcn);
|
---|
90 | if (!funcname)
|
---|
91 | return kFALSE;
|
---|
92 |
|
---|
93 | Free(no);
|
---|
94 |
|
---|
95 | fCall[no] = new TMethodCall;
|
---|
96 | fCall[no]->InitWithPrototype(funcname, params);
|
---|
97 |
|
---|
98 | gLog << inf << GetDescriptor() << ": Using " << funcname << " as ";
|
---|
99 | switch (no)
|
---|
100 | {
|
---|
101 | case 0:
|
---|
102 | gLog << "Pre";
|
---|
103 | break;
|
---|
104 | case 2:
|
---|
105 | gLog << "Post";
|
---|
106 | break;
|
---|
107 |
|
---|
108 | }
|
---|
109 | gLog << "Process-function." << endl;
|
---|
110 |
|
---|
111 | return kTRUE;
|
---|
112 | }
|
---|
113 |
|
---|
114 | void MTaskInteractive::Free(Int_t no)
|
---|
115 | {
|
---|
116 | if (!fCall[no])
|
---|
117 | return;
|
---|
118 | delete fCall[no];
|
---|
119 | fCall[no] = 0;
|
---|
120 | }
|
---|