1 /*
2  * RGraphicsUtils.hpp
3  *
4  * Copyright (C) 2021 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant
7  * to the terms of a commercial license agreement with RStudio, then
8  * this program is licensed to you under the terms of version 3 of the
9  * GNU Affero General Public License. This program is distributed WITHOUT
10  * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
12  * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
13  *
14  */
15 
16 #ifndef R_SESSION_GRAPHICS_UTILS_HPP
17 #define R_SESSION_GRAPHICS_UTILS_HPP
18 
19 #include <boost/shared_ptr.hpp>
20 
21 namespace rstudio {
22 namespace core {
23    class Error;
24    class ErrorLocation;
25    class FilePath;
26 }
27 }
28 
29 namespace rstudio {
30 namespace r {
31 namespace session {
32 namespace graphics {
33 
34 void setCompatibleEngineVersion(int version);
35 bool validateRequirements(std::string* pMessage = nullptr);
36 
37 class RestorePreviousGraphicsDeviceScope
38 {
39 public:
40    RestorePreviousGraphicsDeviceScope();
41    virtual ~RestorePreviousGraphicsDeviceScope();
42 
43 private:
44    struct Impl;
45    boost::shared_ptr<Impl> pImpl_;
46 };
47 
48 void reportError(const core::Error& error);
49 
50 void logAndReportError(const core::Error& error,
51                        const core::ErrorLocation& location);
52 
53 } // namespace graphics
54 } // namespace session
55 } // namespace r
56 } // namespace rstudio
57 
58 
59 #endif // R_SESSION_GRAPHICS_UTILS_HPP
60 
61