Logo ROOT  
Reference Guide
RWebWindowsManager.hxx
Go to the documentation of this file.
1/// \file ROOT/RWebWindowsManager.hxx
2/// \ingroup WebGui ROOT7
3/// \author Sergey Linev <s.linev@gsi.de>
4/// \date 2017-10-16
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
16#ifndef ROOT7_RWebWindowsManager
17#define ROOT7_RWebWindowsManager
18
19#include <memory>
20#include <string>
21#include <thread>
22#include <mutex>
23
24#include "THttpEngine.h"
25
26#include <ROOT/RWebWindow.hxx>
27
28class THttpServer;
29class THttpWSHandler;
30
31namespace ROOT {
32namespace Experimental {
33
35
36 friend class RWebWindow;
37
38private:
39 std::unique_ptr<THttpServer> fServer; ///<! central communication with the all used displays
40 std::string fAddr; ///<! HTTP address of the server
41 std::recursive_mutex fMutex; ///<! main mutex, used for window creations
42 unsigned fIdCnt{0}; ///<! counter for identifiers
43 bool fUseHttpThrd{false}; ///<! use special thread for THttpServer
44 bool fUseSenderThreads{false}; ///<! use extra threads for sending data from RWebWindow to clients
45 float fLaunchTmout{30.}; ///<! timeout in seconds to start browser process, default 30s
46
47 /// Returns true if http server use special thread for requests processing (default off)
48 bool IsUseHttpThread() const { return fUseHttpThrd; }
49
50 /// Returns true if extra threads to send data via websockets will be used (default off)
51 bool IsUseSenderThreads() const { return fUseSenderThreads; }
52
53 /// Returns timeout for launching new browser process
54 float GetLaunchTmout() const { return fLaunchTmout; }
55
56 void Unregister(RWebWindow &win);
57
58 /// Show window in specified location, see Show() method for more details
59 unsigned ShowWindow(RWebWindow &win, bool batch_mode, const RWebDisplayArgs &args);
60
61 int WaitFor(RWebWindow &win, WebWindowWaitFunc_t check, bool timed = false, double tm = -1);
62
63 static bool IsMainThrd();
64
65 std::string GetUrl(const RWebWindow &win, bool remote = false);
66
67 bool CreateServer(bool with_http = false);
68
69public:
71
73
74 /// Returns THttpServer instance
75 THttpServer *GetServer() const { return fServer.get(); }
76
77 /// Returns http address of the server, empty string when not available
78 std::string GetServerAddr() const { return fAddr; }
79
80 static std::shared_ptr<RWebWindowsManager> &Instance();
81
82 std::shared_ptr<RWebWindow> CreateWindow();
83
84 void Terminate();
85};
86
87} // namespace Experimental
88} // namespace ROOT
89
90#endif
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
Represents web window, which can be shown in web browser or any other supported environment.
Definition: RWebWindow.hxx:56
Central instance to create and show web-based windows like Canvas or FitPanel.
std::shared_ptr< RWebWindow > CreateWindow()
Creates new window To show window, RWebWindow::Show() have to be called.
std::unique_ptr< THttpServer > fServer
! central communication with the all used displays
static std::shared_ptr< RWebWindowsManager > & Instance()
Returns default window manager Used to display all standard ROOT elements like TCanvas or TFitPanel.
float GetLaunchTmout() const
Returns timeout for launching new browser process.
std::string GetUrl(const RWebWindow &win, bool remote=false)
Provide URL address to access specified window from inside or from remote.
std::string GetServerAddr() const
Returns http address of the server, empty string when not available.
std::recursive_mutex fMutex
! main mutex, used for window creations
unsigned fIdCnt
! counter for identifiers
std::string fAddr
! HTTP address of the server
void Unregister(RWebWindow &win)
Release all references to specified window Called from RWebWindow destructor.
bool fUseSenderThreads
! use extra threads for sending data from RWebWindow to clients
static bool IsMainThrd()
Returns true when called from main process Main process recognized at the moment when library is load...
THttpServer * GetServer() const
Returns THttpServer instance.
RWebWindowsManager()
window manager constructor Required here for correct usage of unique_ptr<THttpServer>
unsigned ShowWindow(RWebWindow &win, bool batch_mode, const RWebDisplayArgs &args)
Show window in specified location, see Show() method for more details.
bool CreateServer(bool with_http=false)
Creates http server, if required - with real http engine (civetweb) One could configure concrete HTTP...
bool IsUseSenderThreads() const
Returns true if extra threads to send data via websockets will be used (default off)
~RWebWindowsManager()
window manager destructor Required here for correct usage of unique_ptr<THttpServer>
int WaitFor(RWebWindow &win, WebWindowWaitFunc_t check, bool timed=false, double tm=-1)
Waits until provided check function or lambdas returns non-zero value Regularly calls WebWindow::Sync...
bool IsUseHttpThread() const
Returns true if http server use special thread for requests processing (default off)
bool fUseHttpThrd
! use special thread for THttpServer
void Terminate()
Terminate http server and ROOT application.
float fLaunchTmout
! timeout in seconds to start browser process, default 30s
std::function< int(double)> WebWindowWaitFunc_t
function signature for waiting call-backs Such callback used when calling thread need to waits for so...
Definition: RWebWindow.hxx:51
VSD Structures.
Definition: StringConv.hxx:21