Logo ROOT  
Reference Guide
RVirtualCanvasPainter.cxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
10
11#include <ROOT/RLogger.hxx>
12#include <TSystem.h> // TSystem::Load
13
14#include <exception>
15
16namespace {
17static int LoadCanvasPainterLibraryOnce() {
18 static int loadResult = gSystem->Load("libROOTCanvasPainter");
19 if (loadResult != 0)
20 R__ERROR_HERE("Gpad") << "Loading of libROOTCanvasPainter failed!";
21 return loadResult;
22}
23static void LoadCanvasPainterLibrary() {
24 static int loadResult = LoadCanvasPainterLibraryOnce();
25 (void) loadResult;
26}
27} // unnamed namespace
28
29using namespace ROOT::Experimental::Internal;
30
31/// The implementation is here to pin the vtable.
32RVirtualCanvasPainter::~RVirtualCanvasPainter() = default;
33
34std::unique_ptr<RVirtualCanvasPainter::Generator> &RVirtualCanvasPainter::GetGenerator()
35{
36 /// The generator for implementations.
37 static std::unique_ptr<Generator> generator;
38 return generator;
39}
40
41std::unique_ptr<RVirtualCanvasPainter> RVirtualCanvasPainter::Create(ROOT::Experimental::RCanvas &canv)
42{
43 if (!GetGenerator()) {
44 LoadCanvasPainterLibrary();
45 if (!GetGenerator()) {
46 R__ERROR_HERE("Gpad") << "RVirtualCanvasPainter::Generator failed to register!";
47 throw std::runtime_error("RVirtualCanvasPainter::Generator failed to initialize");
48 }
49 }
50 return GetGenerator()->Create(canv);
51}
52
53/// The implementation is here to pin the vtable.
55
#define R__ERROR_HERE(GROUP)
Definition: RLogger.hxx:183
typedef void((*Func_t)())
R__EXTERN TSystem * gSystem
Definition: TSystem.h:556
static std::unique_ptr< Generator > & GetGenerator()
generator getter
static std::unique_ptr< RVirtualCanvasPainter > Create(RCanvas &canv)
Loads the plugin that implements this class.
A window's topmost RPad.
Definition: RCanvas.hxx:46
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1850