Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TInterpreter.cxx
Go to the documentation of this file.
1// @(#)root/meta:$Id$
2// Author: Fons Rademakers 01/03/96
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TInterpreter
13This class defines an abstract interface to a generic command line
14interpreter.
15*/
16
17#include "TInterpreter.h"
18
19#include "TROOT.h"
20#include "TError.h"
21#include "TGlobal.h"
22
23
24TInterpreter* gCling = nullptr; // returns pointer to global TCling object
25static TInterpreter *gInterpreterLocal = nullptr; // The real holder of the pointer.
26
27
28namespace {
29static struct AddPseudoGlobals {
30AddPseudoGlobals() {
31
32 // use special functor to extract pointer on gInterpreterLocal variable
33 TGlobalMappedFunction::MakeFunctor("gInterpreter", "TInterpreter*", TInterpreter::Instance, [] {
35 return (void *) &gInterpreterLocal;
36 });
37
38}
39} gAddPseudoGlobals;
40}
41
42
44
45////////////////////////////////////////////////////////////////////////////////
46/// TInterpreter ctor only called by derived classes.
47
48TInterpreter::TInterpreter(const char *name, const char *title)
49 : TNamed(name, title)
50{
51 gInterpreterLocal = this;
52 gCling = this;
53}
54
55////////////////////////////////////////////////////////////////////////////////
56/// returns gInterpreter global
57
59{
60 if (gInterpreterLocal == nullptr) {
61 static TROOT *getROOT = ROOT::GetROOT(); // Make sure gInterpreterLocal is set
62 if (!getROOT) {
63 ::Fatal("TInterpreter::Instance","TROOT object is required before accessing a TInterpreter");
64 }
65 }
66 return gInterpreterLocal;
67}
#define ClassImp(name)
Definition Rtypes.h:377
char name[80]
Definition TGX11.cxx:110
static TInterpreter * gInterpreterLocal
TInterpreter * gCling
R__EXTERN TInterpreter * gCling
static void MakeFunctor(const char *name, const char *type, GlobFunc &func)
Definition TGlobal.h:73
This class defines an abstract interface to a generic command line interpreter.
static TInterpreter * Instance()
returns gInterpreter global
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:998
ROOT top level object description.
Definition TROOT.h:94
TROOT * GetROOT()
Definition TROOT.cxx:464