Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
16 namespace {
17 static 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 }
23 static void LoadCanvasPainterLibrary() {
24  static int loadResult = LoadCanvasPainterLibraryOnce();
25  (void) loadResult;
26 }
27 } // unnamed namespace
28 
29 
30 /// The implementation is here to pin the vtable.
31 ROOT::Experimental::Internal::RVirtualCanvasPainter::~RVirtualCanvasPainter() = default;
32 
33 std::unique_ptr<ROOT::Experimental::Internal::RVirtualCanvasPainter::Generator>
34  &ROOT::Experimental::Internal::RVirtualCanvasPainter::GetGenerator()
35 {
36  /// The generator for implementations.
37  static std::unique_ptr<Generator> generator;
38  return generator;
39 }
40 
41 std::unique_ptr<ROOT::Experimental::Internal::RVirtualCanvasPainter> ROOT::Experimental::Internal::
42  RVirtualCanvasPainter::Create(const RCanvas &canv)
43 {
44  if (!GetGenerator()) {
45  LoadCanvasPainterLibrary();
46  if (!GetGenerator()) {
47  R__ERROR_HERE("Gpad") << "RVirtualCanvasPainter::Generator failed to register!";
48  throw std::runtime_error("RVirtualCanvasPainter::Generator failed to initialize");
49  }
50  }
51  return GetGenerator()->Create(canv);
52 }
53 
54 /// The implementation is here to pin the vtable.
55 ROOT::Experimental::Internal::RVirtualCanvasPainter::Generator::~Generator() = default;
56