]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveBase/AliEveMacroExecutor.cxx
Prototype for visualization-macro manager and gui.
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveMacroExecutor.cxx
CommitLineData
f6afd0e1 1// @(#)root/eve:$Id$
2// Author: Matevz Tadel 2007
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
9
10#include "AliEveMacroExecutor.h"
11#include "AliEveMacro.h"
12#include "AliEveEventManager.h"
13
14#include <TEveUtil.h>
15#include <TList.h>
16#include <TROOT.h>
17
18//______________________________________________________________________________
19// Full description of AliEveMacroExecutor
20//
21
22ClassImp(AliEveMacroExecutor)
23
24//______________________________________________________________________________
25AliEveMacroExecutor::AliEveMacroExecutor() :
26 TObject(),
27 fMacros(new TList)
28{
29 // Constructor.
30
31 fMacros->SetOwner(kTRUE);
32}
33
34//______________________________________________________________________________
35AliEveMacroExecutor::~AliEveMacroExecutor()
36{
37 // Destructor.
38
39 delete fMacros;
40}
41
42/******************************************************************************/
43
44void AliEveMacroExecutor::AddMacro(AliEveMacro* mac)
45{
46 // Add a new macro. Ownership transfered to the executor.
47
48 static const TEveException kEH("AliEveMacroExecutor::AddMacro ");
49
50 const TString mname = mac->GetMacro();
51 if ( ! mname.IsNull() && TEveUtil::CheckMacro(mname) == kFALSE)
52 {
53 TEveUtil::LoadMacro(mname);
54 }
55 fMacros->Add(mac);
56}
57
58/******************************************************************************/
59
60#include "Api.h"
61#include "TInterpreter.h"
62
63void AliEveMacroExecutor::ExecMacros()
64{
65 // Execute registered macros.
66
67 TIter next(fMacros);
68 AliEveMacro* mac;
69 while ((mac = (AliEveMacro*) next()))
70 {
71 // printf ("macro '%s'; func '%s'; args '%s'\n", mac->GetMacro().Data(), mac->GetFunc().Data(), mac->GetArgs().Data());
72
73 if (mac->GetActive() == kFALSE || mac->GetFunc().IsNull())
74 {
75 continue;
76 }
77
78 switch (mac->GetSources())
79 {
80 case AliEveMacro::kRunLoader:
81 if ( ! AliEveEventManager::HasRunLoader())
82 continue;
83 break;
84 case AliEveMacro::kESD:
85 if ( ! AliEveEventManager::HasESD())
86 continue;
87 break;
88 case AliEveMacro::kESDfriend:
89 if ( ! AliEveEventManager::HasESDfriend())
90 continue;
91 break;
92 case AliEveMacro::kRawReader:
93 if ( ! AliEveEventManager::HasRawReader())
94 continue;
95 break;
96 default:
97 break;
98 }
99
100 TString cmd(mac->FormForExec());
101 try
102 {
103 gInterpreter->ProcessLine(cmd);
104 // Try to fix broken cint state? Code taken form pyroot.
105 if ( G__get_return( 0 ) > G__RETURN_NORMAL )
106 {
107 printf ("***INFIXING***\n");
108 G__security_recover( 0 ); // 0 ensures silence
109 }
110 }
111 catch(TEveException& exc)
112 {
113 Error("ExecMacros", "Executing %s::%s, caught exception: '%s'.",
114 mac->GetMacro().Data(), cmd.Data(), exc.Data());
115 }
116
117 // Try to fix broken cint state? Code taken form pyroot.
118 if ( G__get_return( 0 ) > G__RETURN_NORMAL )
119 {
120 printf ("***POSTFIXING****\n");
121 G__security_recover( 0 ); // 0 ensures silence
122 }
123 }
124}