2 // Author: Matevz Tadel 2007
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 **************************************************************************/
10 #include "AliEveMacroExecutor.h"
11 #include "AliEveMacro.h"
12 #include "AliEveEventManager.h"
18 //______________________________________________________________________________
19 // Full description of AliEveMacroExecutor
22 ClassImp(AliEveMacroExecutor)
24 //______________________________________________________________________________
25 AliEveMacroExecutor::AliEveMacroExecutor() :
31 fMacros->SetOwner(kTRUE);
34 //______________________________________________________________________________
35 AliEveMacroExecutor::~AliEveMacroExecutor()
42 /******************************************************************************/
44 void AliEveMacroExecutor::AddMacro(AliEveMacro* mac)
46 // Add a new macro. Ownership transfered to the executor.
48 static const TEveException kEH("AliEveMacroExecutor::AddMacro ");
50 const TString mname = mac->GetMacro();
51 if ( ! mname.IsNull() && TEveUtil::CheckMacro(mname) == kFALSE)
53 TEveUtil::LoadMacro(mname);
58 AliEveMacro* AliEveMacroExecutor::FindMacro(const TString& func)
60 // Find macro with given function name (it is supposed to be unique).
61 // Returns 0 if not found.
65 while ((mac = (AliEveMacro*) next()))
67 if (mac->GetFunc() == func)
73 /******************************************************************************/
76 #include "TInterpreter.h"
78 void AliEveMacroExecutor::ExecMacros()
80 // Execute registered macros.
84 while ((mac = (AliEveMacro*) next()))
86 // printf ("macro '%s'; func '%s'; args '%s'\n", mac->GetMacro().Data(), mac->GetFunc().Data(), mac->GetArgs().Data());
88 if (mac->GetActive() == kFALSE || mac->GetFunc().IsNull())
93 switch (mac->GetSources())
95 case AliEveMacro::kRunLoader:
96 if ( ! AliEveEventManager::HasRunLoader())
99 case AliEveMacro::kESD:
100 if ( ! AliEveEventManager::HasESD())
103 case AliEveMacro::kESDfriend:
104 if ( ! AliEveEventManager::HasESDfriend())
107 case AliEveMacro::kRawReader:
108 if ( ! AliEveEventManager::HasRawReader())
115 TString cmd(mac->FormForExec());
118 gInterpreter->ProcessLine(cmd);
119 // Try to fix broken cint state? Code taken form pyroot.
120 if ( G__get_return( 0 ) > G__RETURN_NORMAL )
122 printf ("***INFIXING***\n");
123 G__security_recover( 0 ); // 0 ensures silence
126 catch(TEveException& exc)
128 Error("ExecMacros", "Executing %s::%s, caught exception: '%s'.",
129 mac->GetMacro().Data(), cmd.Data(), exc.Data());
132 // Try to fix broken cint state? Code taken form pyroot.
133 if ( G__get_return( 0 ) > G__RETURN_NORMAL )
135 printf ("***POSTFIXING****\n");
136 G__security_recover( 0 ); // 0 ensures silence