]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Reve/RMacro.cxx
Changed inheritance to include Reve::RenderElement; use ZTrans to store transformatio...
[u/mrichter/AliRoot.git] / EVE / Reve / RMacro.cxx
CommitLineData
6a187c6c 1// $Header$
2
3#include "RMacro.h"
4
5#include <TSystem.h>
6#include <TROOT.h>
7#include <G__ci.h>
8
9using namespace Reve;
10
11//______________________________________________________________________
12// RMacro
13//
14// Sub-class of TMacro, overriding Exec to unload the previous verison
15// and cleanup after the execution.
16
17ClassImp(RMacro)
18
19RMacro::RMacro() : TMacro() {}
20
21RMacro::RMacro(const RMacro& m) : TMacro(m) {}
22
8ca3710e 23RMacro::RMacro(const char* name) :
24 TMacro()
25{
26 if (!name) return;
27
28 fTitle = name;
29
30 char *dot = (char*)strrchr(name, '.');
31 char *slash = (char*)strrchr(name, '/');
32 if (dot) *dot = 0;
33 if (slash) fName = slash + 1;
34 else fName = name;
35
36 ReadFile(fTitle);
37}
6a187c6c 38
39/**************************************************************************/
40
41void RMacro::Exec(const char* params)
42{
23443913 43 if(Reve::CheckMacro(fTitle.Data()))
6a187c6c 44 G__unloadfile(fTitle.Data());
45
46 // Copy from TMacro::Exec. Difference is that the file is really placed
47 // into the /tmp.
48 TString fname = "/tmp/";
49 {
50 //the current implementation uses a file in the current directory.
51 //should be replaced by a direct execution from memory by CINT
52 fname += GetName();
23443913 53 fname += ".C";
6a187c6c 54 SaveSource(fname);
55 //disable a possible call to gROOT->Reset from the executed script
56 gROOT->SetExecutingMacro(kTRUE);
57 //execute script in /tmp
58 TString exec = ".x " + fname;
59 TString p = params;
60 if (p == "") p = fParams;
61 if (p != "")
62 exec += "(" + p + ")";
63 gROOT->ProcessLine(exec);
64 //enable gROOT->Reset
65 gROOT->SetExecutingMacro(kFALSE);
66 //delete the temporary file
67 gSystem->Unlink(fname);
68 }
69
70 G__unloadfile(fname);
71}