Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RWebDisplayHandle.hxx
Go to the documentation of this file.
1// Author: Sergey Linev <s.linev@gsi.de>
2// Date: 2018-10-17
3// Warning: This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
4
5/*************************************************************************
6 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT7_RWebDisplayHandle
14#define ROOT7_RWebDisplayHandle
15
17
18#include <string>
19#include <map>
20#include <memory>
21
22namespace ROOT {
23namespace Experimental {
24
26
27 std::string fUrl; ///!< URL used to launch display
28
29 std::string fContent; ///!< page content
30
31protected:
32 class Creator {
33 public:
34 virtual std::unique_ptr<RWebDisplayHandle> Display(const RWebDisplayArgs &args) = 0;
35 virtual bool IsActive() const { return true; }
36 virtual ~Creator() = default;
37 };
38
39 class BrowserCreator : public Creator {
40 protected:
41 std::string fProg; ///< browser executable
42 std::string fExec; ///< standard execute line
43 std::string fBatchExec; ///< batch execute line
44
45 void TestProg(const std::string &nexttry, bool check_std_paths = false);
46
47 virtual void ProcessGeometry(std::string &, const RWebDisplayArgs &) {}
48 virtual std::string MakeProfile(std::string &, bool) { return ""; }
49
50 public:
51
52 BrowserCreator(bool custom = true, const std::string &exec = "");
53
54 std::unique_ptr<RWebDisplayHandle> Display(const RWebDisplayArgs &args) override;
55
56 virtual ~BrowserCreator() = default;
57 };
58
60 public:
62 virtual ~ChromeCreator() = default;
63 bool IsActive() const override { return !fProg.empty(); }
64 void ProcessGeometry(std::string &, const RWebDisplayArgs &args) override;
65 std::string MakeProfile(std::string &exec, bool) override;
66 };
67
69 public:
71 virtual ~FirefoxCreator() = default;
72 bool IsActive() const override { return !fProg.empty(); }
73 std::string MakeProfile(std::string &exec, bool batch) override;
74 };
75
76 static std::map<std::string, std::unique_ptr<Creator>> &GetMap();
77
78 static std::unique_ptr<Creator> &FindCreator(const std::string &name, const std::string &libname = "");
79
80public:
81
82 RWebDisplayHandle(const std::string &url) : fUrl(url) {}
83
84 // required virtual destructor for correct cleanup at the end
85 virtual ~RWebDisplayHandle() = default;
86
87 const std::string &GetUrl() const { return fUrl; }
88
89 void SetContent(const std::string &cont) { fContent = cont; }
90 const std::string &GetContent() const { return fContent; }
91
92 static std::unique_ptr<RWebDisplayHandle> Display(const RWebDisplayArgs &args);
93
94 static bool DisplayUrl(const std::string &url);
95
96 static bool ProduceImage(const std::string &fname, const std::string &json, int width = 800, int height = 600);
97};
98
99}
100}
101
102#endif
include TDocParser_001 C image html pict1_TDocParser_001 png width
char name[80]
Definition TGX11.cxx:110
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
virtual std::string MakeProfile(std::string &, bool)
std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args) override
Display given URL in web browser.
virtual void ProcessGeometry(std::string &, const RWebDisplayArgs &)
void TestProg(const std::string &nexttry, bool check_std_paths=false)
Check if browser executable exists and can be used.
void ProcessGeometry(std::string &, const RWebDisplayArgs &args) override
Replace $geometry placeholder with geometry settings Also RWebDisplayArgs::GetExtraArgs() are appende...
std::string MakeProfile(std::string &exec, bool) override
Handle profile argument.
virtual std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args)=0
std::string MakeProfile(std::string &exec, bool batch) override
Create Firefox profile to run independent browser window.
static std::map< std::string, std::unique_ptr< Creator > > & GetMap()
Static holder of registered creators of web displays.
static bool ProduceImage(const std::string &fname, const std::string &json, int width=800, int height=600)
Produce image file using JSON data as source Invokes JSROOT drawing functionality in headless browser...
void SetContent(const std::string &cont)
std::string fContent
!< URL used to launch display
const std::string & GetContent() const
static bool DisplayUrl(const std::string &url)
Display provided url in configured web browser.
static std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args)
Create web display.
static std::unique_ptr< Creator > & FindCreator(const std::string &name, const std::string &libname="")
Search for specific browser creator If not found, try to add one.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...