Blue Brain BioExplorer
ApplicationParameters.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2024, EPFL/Blue Brain Project
3  * All rights reserved. Do not distribute without permission.
4  *
5  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
6  *
7  * This library is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License version 3.0 as published
9  * by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include "ApplicationParameters.h"
26 
27 namespace
28 {
29 const std::string PARAM_BENCHMARKING = "enable-benchmark";
30 const std::string PARAM_ENGINE = "engine";
31 const std::string PARAM_HTTP_SERVER = "http-server";
32 const std::string PARAM_IMAGE_STREAM_FPS = "image-stream-fps";
33 const std::string PARAM_INPUT_PATHS = "input-paths";
34 const std::string PARAM_JPEG_COMPRESSION = "jpeg-compression";
35 const std::string PARAM_MAX_RENDER_FPS = "max-render-fps";
36 const std::string PARAM_MODULE = "module";
37 const std::string PARAM_PARALLEL_RENDERING = "parallel-rendering";
38 const std::string PARAM_PLUGIN = "plugin";
39 const std::string PARAM_WINDOW_SIZE = "window-size";
40 const std::string PARAM_ENV_MAP = "env-map";
41 const std::string PARAM_SANDBOX_PATH = "sandbox-path";
42 #ifdef BRAYNS_USE_FFMPEG
43 const std::string PARAM_VIDEOSTREAMING = "videostreaming";
44 #endif
45 
46 const size_t DEFAULT_WINDOW_WIDTH = 800;
47 const size_t DEFAULT_WINDOW_HEIGHT = 600;
48 const size_t DEFAULT_JPEG_COMPRESSION = 90;
49 const std::string DEFAULT_SANDBOX_PATH = "/gpfs/bbp.cscs.ch/project";
50 } // namespace
51 
52 namespace core
53 {
55  : AbstractParameters("Application")
56  , _windowSize(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT)
57  , _jpegCompression(DEFAULT_JPEG_COMPRESSION)
58  , _sandBoxPath(DEFAULT_SANDBOX_PATH)
59 {
60  _parameters.add_options() //
61  (PARAM_ENGINE.c_str(), po::value<std::string>(&_engine),
62  "Engine name [ospray|optix]") //
63  (PARAM_MODULE.c_str(), po::value<strings>(&_modules)->composing(),
64  "OSPRay module name [string]") //
65  (PARAM_HTTP_SERVER.c_str(), po::value<std::string>(&_httpServerURI),
66  "HTTP interface") //
67  (PARAM_INPUT_PATHS.c_str(), po::value<strings>(&_inputPaths),
68  "List of files/folders to load data from") //
69  (PARAM_PLUGIN.c_str(), po::value<strings>()->composing(),
70  "Dynamic plugin to load from LD_LIBRARY_PATH; "
71  "can be repeated to load multiple plugins. "
72  "Arguments to plugins can be added by inserting a space followed by "
73  "the arguments like: --plugin 'myPluginName arg0 arg1'") //
74  (PARAM_WINDOW_SIZE.c_str(), po::fixed_tokens_value<uints>(2, 2),
75  "Window size [uint uint]") //
76  (PARAM_BENCHMARKING.c_str(), po::bool_switch(&_benchmarking)->default_value(false),
77  "Enable benchmarking") //
78  (PARAM_JPEG_COMPRESSION.c_str(), po::value<size_t>(&_jpegCompression),
79  "JPEG compression rate (100 is full quality) [int]") //
80  (PARAM_PARALLEL_RENDERING.c_str(), po::bool_switch(&_parallelRendering)->default_value(false),
81  "Enable parallel rendering, equivalent to --osp:mpi") //
82  (CAMERA_PROPERTY_STEREO.name.c_str(), po::bool_switch(&_stereo)->default_value(DEFAULT_CAMERA_STEREO),
83  "Enable stereo rendering") //
84  (PARAM_IMAGE_STREAM_FPS.c_str(), po::value<size_t>(&_imageStreamFPS),
85  "Image stream FPS (60 default), [int]") //
86  (PARAM_MAX_RENDER_FPS.c_str(), po::value<size_t>(&_maxRenderFPS),
87  "Max. render FPS") //
88  (PARAM_ENV_MAP.c_str(), po::value<std::string>(&_envMap),
89  "Path to environment map")(PARAM_SANDBOX_PATH.c_str(), po::value<std::string>(&_sandBoxPath),
90  "Path to sandbox directory")
91 #ifdef BRAYNS_USE_FFMPEG
92  (PARAM_VIDEOSTREAMING.c_str(), po::bool_switch(&_useVideoStreaming)->default_value(false),
93  "Use videostreaming over websockets instead of JPEG")
94 #endif
95  ;
96 
97  _positionalArgs.add(PARAM_INPUT_PATHS.c_str(), -1);
98 }
99 
100 void ApplicationParameters::parse(const po::variables_map& vm)
101 {
102  if (vm.count(PARAM_WINDOW_SIZE))
103  {
104  uints values = vm[PARAM_WINDOW_SIZE].as<uints>();
105  _windowSize.x = values[0];
106  _windowSize.y = values[1];
107  }
108  markModified();
109 }
110 
112 {
114  CORE_INFO("Engine : " << _engine);
115  CORE_INFO("Ospray modules : ");
116  for (const auto& module : _modules)
117  CORE_INFO("- " << module);
118  CORE_INFO("Window size : " << _windowSize);
119  CORE_INFO("Benchmarking : " << asString(_benchmarking));
120  CORE_INFO("JPEG Compression : " << _jpegCompression);
121  CORE_INFO("Image stream FPS : " << _imageStreamFPS);
122  CORE_INFO("Max. render FPS : " << _maxRenderFPS);
123  CORE_INFO("Sandbox directory : " << _sandBoxPath);
124 }
125 } // namespace core
static std::string asString(const bool flag)
po::options_description _parameters
void parse(const po::variables_map &vm) final
std::vector< std::string > _modules
po::positional_options_description _positionalArgs
void markModified(const bool triggerCallback=true)
Definition: BaseObject.h:65
_LINK_LIBRARIES PRIVATE CorePluginRockets endif() add_executable($
Definition: CMakeLists.txt:37
#define CORE_INFO(__msg)
Definition: Logs.h:33
std::vector< unsigned int > uints
Definition: Types.h:47