Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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/RAttrBase.hxx" // for GPadLog()
12#include <ROOT/RLogger.hxx>
13#include <TSystem.h> // TSystem::Load
14
15#include <exception>
16
17namespace {
18static int LoadCanvasPainterLibraryOnce() {
19 static int loadResult = gSystem->Load("libROOTCanvasPainter");
20 if (loadResult != 0)
21 R__LOG_ERROR(ROOT::Experimental::GPadLog()) << "Loading of libROOTCanvasPainter failed!";
22 return loadResult;
23}
24static void LoadCanvasPainterLibrary() {
25 static int loadResult = LoadCanvasPainterLibraryOnce();
26 (void) loadResult;
27}
28} // unnamed namespace
29
30using namespace ROOT::Experimental::Internal;
31
32/// The implementation is here to pin the vtable.
34
35std::unique_ptr<RVirtualCanvasPainter::Generator> &RVirtualCanvasPainter::GetGenerator()
36{
37 /// The generator for implementations.
38 static std::unique_ptr<Generator> generator;
39 return generator;
40}
41
42std::unique_ptr<RVirtualCanvasPainter> RVirtualCanvasPainter::Create(ROOT::Experimental::RCanvas &canv)
43{
44 if (!GetGenerator()) {
45 LoadCanvasPainterLibrary();
46 if (!GetGenerator()) {
47 R__LOG_ERROR(GPadLog()) << "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.
56
#define R__LOG_ERROR(...)
Definition RLogger.hxx:362
R__EXTERN TSystem * gSystem
Definition TSystem.h:560
static std::unique_ptr< Generator > & GetGenerator()
generator getter
virtual ~RVirtualCanvasPainter()
Default destructor.
static std::unique_ptr< RVirtualCanvasPainter > Create(RCanvas &canv)
Loads the plugin that implements this class.
A window's topmost RPad.
Definition RCanvas.hxx:47
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1858
RLogChannel & GPadLog()
Log channel for GPad diagnostics.
Definition RAttrBase.cxx:17
void(off) SmallVectorTemplateBase< T