Blue Brain BioExplorer
DeflectParameters.h
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 #pragma once
22 
25 
26 #include <deflect/types.h>
27 
28 namespace core
29 {
30 constexpr auto PARAM_CHROMA_SUBSAMPLING = "chromaSubsampling";
31 constexpr auto PARAM_COMPRESSION = "compression";
32 constexpr auto PARAM_ENABLED = "enabled";
33 constexpr auto PARAM_HOSTNAME = "hostname";
34 constexpr auto PARAM_ID = "id";
35 constexpr auto PARAM_PORT = "port";
36 constexpr auto PARAM_QUALITY = "quality";
37 constexpr auto PARAM_RESIZING = "resizing";
38 constexpr auto PARAM_TOP_DOWN = "topDown";
39 constexpr auto PARAM_USE_PIXEL_OP = "usePixelop";
40 
42 {
43 public:
45 
46  bool getEnabled() const { return _props.getProperty<bool>(PARAM_ENABLED); }
47  void setEnabled(const bool enabled) { _updateProperty(PARAM_ENABLED, enabled); }
48  bool getCompression() const { return _props.getProperty<bool>(PARAM_COMPRESSION); }
49  void setCompression(const bool enabled) { _updateProperty(PARAM_COMPRESSION, enabled); }
50 
51  unsigned getQuality() const { return (unsigned)_props.getProperty<int32_t>(PARAM_QUALITY); }
52  void setQuality(const unsigned quality) { _updateProperty(PARAM_QUALITY, (int32_t)quality); }
53  std::string getId() const { return _props.getProperty<std::string>(PARAM_ID); }
54  void setId(const std::string& id) { _updateProperty(PARAM_ID, id); }
55  std::string getHostname() const { return _props.getProperty<std::string>(PARAM_HOSTNAME); }
56  void setHost(const std::string& host) { _updateProperty(PARAM_HOSTNAME, host); }
57 
58  unsigned getPort() const { return (unsigned)_props.getProperty<int32_t>(PARAM_PORT); }
59  void setPort(const unsigned port) { _updateProperty(PARAM_PORT, (int32_t)port); }
60 
61  bool isResizingEnabled() const { return _props.getProperty<bool>(PARAM_RESIZING); }
62 
63  bool isTopDown() const { return _props.getProperty<bool>(PARAM_TOP_DOWN); }
64  void setIsTopDown(const bool topDown) { _updateProperty(PARAM_TOP_DOWN, topDown); }
65 
66  bool usePixelOp() const { return _props.getProperty<bool>(PARAM_USE_PIXEL_OP); }
67  deflect::ChromaSubsampling getChromaSubsampling() const
68  {
69  return (deflect::ChromaSubsampling)_props.getProperty<int32_t>(PARAM_CHROMA_SUBSAMPLING);
70  }
71  void setChromaSubsampling(const deflect::ChromaSubsampling subsampling)
72  {
73  _updateProperty(PARAM_CHROMA_SUBSAMPLING, (int32_t)subsampling);
74  }
75 
76  const PropertyMap& getPropertyMap() const { return _props; }
77  PropertyMap& getPropertyMap() { return _props; }
78 
79 private:
80  PropertyMap _props;
81 
82  template <typename T>
83  void _updateProperty(const char* property, const T& newValue)
84  {
85  if (!_isEqual(_props.getProperty<T>(property), newValue))
86  {
87  _props.updateProperty(property, newValue);
88  markModified();
89  }
90  }
91 };
92 } // namespace core
void markModified(const bool triggerCallback=true)
Definition: BaseObject.h:65
bool _isEqual(const T &a, const T &b, typename std::enable_if< std::is_floating_point< T >::value >::type *=0)
Definition: BaseObject.h:97
PropertyMap & getPropertyMap()
unsigned getQuality() const
std::string getHostname() const
void setIsTopDown(const bool topDown)
void setCompression(const bool enabled)
const PropertyMap & getPropertyMap() const
void setChromaSubsampling(const deflect::ChromaSubsampling subsampling)
void setHost(const std::string &host)
std::string getId() const
void setId(const std::string &id)
void setQuality(const unsigned quality)
void setPort(const unsigned port)
unsigned getPort() const
deflect::ChromaSubsampling getChromaSubsampling() const
void setEnabled(const bool enabled)
void updateProperty(const std::string &name, const T &t)
Definition: PropertyMap.h:296
T getProperty(const std::string &name, T valIfNotFound) const
Definition: PropertyMap.h:323
constexpr auto PARAM_RESIZING
constexpr auto PARAM_QUALITY
constexpr auto PARAM_ID
constexpr auto PARAM_ENABLED
constexpr auto PARAM_TOP_DOWN
constexpr auto PARAM_HOSTNAME
constexpr auto PARAM_CHROMA_SUBSAMPLING
constexpr auto PARAM_COMPRESSION
constexpr auto PARAM_USE_PIXEL_OP
constexpr auto PARAM_PORT