]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New class Reve::RMacro: a sub-class of TMacro that tries to unload the macros properl...
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 21 Jun 2006 16:11:13 +0000 (16:11 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 21 Jun 2006 16:11:13 +0000 (16:11 +0000)
EVE/Reve/LinkDef.h
EVE/Reve/RMacro.cxx [new file with mode: 0644]
EVE/Reve/RMacro.h [new file with mode: 0644]

index 2b934b4dbeeb137235bd008cfd573f34123588ca..7132b4ab2c72ec403bfb1cfd1ab50c1c1f72132a 100644 (file)
 // Reve
 #pragma link C++ function Reve::ColorFromIdx;
 #pragma link C++ function Reve::SetupEnvironment;
+
+#pragma link C++ function Reve::CheckMacro;
 #pragma link C++ function Reve::AssertMacro;
 #pragma link C++ function Reve::Macro;
 #pragma link C++ function Reve::LoadMacro;
+
 #pragma link C++ function Reve::PushPad;
 #pragma link C++ function Reve::PopPad;
 #pragma link C++ class Reve::Exc_t+;
@@ -65,6 +68,9 @@
 // RGEditor
 #pragma link C++ class Reve::RGEditor+;
 
+// RMacro
+#pragma link C++ class Reve::RMacro+;
+
 // RGTopFrame
 #pragma link C++ class Reve::RGTopFrame+;
 
diff --git a/EVE/Reve/RMacro.cxx b/EVE/Reve/RMacro.cxx
new file mode 100644 (file)
index 0000000..67e3c52
--- /dev/null
@@ -0,0 +1,57 @@
+// $Header$
+
+#include "RMacro.h"
+
+#include <TSystem.h>
+#include <TROOT.h>
+#include <G__ci.h>
+
+using namespace Reve;
+
+//______________________________________________________________________
+// RMacro
+//
+// Sub-class of TMacro, overriding Exec to unload the previous verison
+// and cleanup after the execution.
+
+ClassImp(RMacro)
+
+RMacro::RMacro() : TMacro() {}
+
+RMacro::RMacro(const RMacro& m) : TMacro(m) {}
+
+RMacro::RMacro(const char* name, const char* /*title*/) : TMacro(name, "") {}
+
+/**************************************************************************/
+
+void RMacro::Exec(const char* params)
+{
+  if(Reve::CheckMacro(fName))
+    G__unloadfile(fTitle.Data());
+
+  // Copy from TMacro::Exec. Difference is that the file is really placed
+  // into the /tmp.
+  TString fname = "/tmp/";
+  {
+    //the current implementation uses a file in the current directory.
+    //should be replaced by a direct execution from memory by CINT
+    fname += GetName();
+    fname += ".Cexec";
+    SaveSource(fname);
+    //disable a possible call to gROOT->Reset from the executed script
+    gROOT->SetExecutingMacro(kTRUE);
+    //execute script in /tmp
+    TString exec = ".x " + fname;
+    TString p = params;
+    if (p == "") p = fParams;
+    if (p != "")
+      exec += "(" + p + ")";
+    gROOT->ProcessLine(exec);
+    //enable gROOT->Reset
+    gROOT->SetExecutingMacro(kFALSE);
+    //delete the temporary file
+    gSystem->Unlink(fname);
+  }
+
+  G__unloadfile(fname);
+}
diff --git a/EVE/Reve/RMacro.h b/EVE/Reve/RMacro.h
new file mode 100644 (file)
index 0000000..3d98542
--- /dev/null
@@ -0,0 +1,29 @@
+// $Header$
+
+#ifndef REVE_RMacro_H
+#define REVE_RMacro_H
+
+#include <Reve/Reve.h>
+
+#include <TMacro.h>
+
+namespace Reve {
+
+class RMacro : public TMacro
+{
+protected:
+
+public:
+  RMacro();
+  RMacro(const RMacro&);
+  RMacro(const char* name, const char* title="");
+  virtual ~RMacro() {}
+
+  virtual void Exec(const char* params = "0");
+
+  ClassDef(RMacro, 1);
+}; // endclass RMacro
+
+}
+
+#endif