Logo ROOT   6.16/01
Reference Guide
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* (*gPtr2Interpreter)() = nullptr; // returns pointer to global object, NOT USED!
25TInterpreter* gCling = nullptr; // returns pointer to global TCling object
26static TInterpreter *gInterpreterLocal = nullptr; // The real holder of the pointer.
27
28
29namespace {
30static struct AddPseudoGlobals {
31AddPseudoGlobals() {
32
33 // use special functor to extract pointer on gInterpreterLocal variable
34 TGlobalMappedFunction::MakeFunctor("gInterpreter", "TInterpreter*", TInterpreter::Instance, [] {
36 return (void *) &gInterpreterLocal;
37 });
38
39}
40} gAddPseudoGlobals;
41}
42
43
45
46////////////////////////////////////////////////////////////////////////////////
47/// TInterpreter ctor only called by derived classes.
48
49TInterpreter::TInterpreter(const char *name, const char *title)
50 : TNamed(name, title)
51{
52 gInterpreterLocal = this;
53 gCling = this;
54}
55
56////////////////////////////////////////////////////////////////////////////////
57/// returns gInterpreter global
58
60{
61 if (gInterpreterLocal == 0) {
62 static TROOT *getROOT = ROOT::GetROOT(); // Make sure gInterpreterLocal is set
63 if (!getROOT) {
64 ::Fatal("TInterpreter::Instance","TROOT object is required before accessing a TInterpreter");
65 }
66 }
68 return gInterpreterLocal;
69}
#define ClassImp(name)
Definition: Rtypes.h:363
static TInterpreter * gInterpreterLocal
TInterpreter *(* gPtr2Interpreter)()
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.
Definition: TInterpreter.h:60
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:908
ROOT top level object description.
Definition: TROOT.h:100
TROOT * GetROOT()
Definition: TROOT.cxx:519