Compute Graph Framework SDK Reference
5.4.5418 Release
For Test and Development only

JsonParameterProvider.hpp
Go to the documentation of this file.
1 //
3 // Notice
4 // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
5 // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
6 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
7 // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 //
9 // NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
10 // information or for any infringement of patents or other rights of third parties that may
11 // result from its use. No license is granted by implication or otherwise under any patent
12 // or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
13 // expressly authorized by NVIDIA. Details are subject to change without notice.
14 // This code supersedes and replaces all information previously supplied.
15 // NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
16 // components in life support devices or systems without express written approval of
17 // NVIDIA CORPORATION & AFFILIATES.
18 //
19 // SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
20 // SPDX-License-Identifier: LicenseRef-NvidiaProprietary
21 //
22 // NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
23 // property and proprietary rights in and to this material, related
24 // documentation and any modifications thereto. Any use, reproduction,
25 // disclosure or distribution of this material and related documentation
26 // without an express license agreement from NVIDIA CORPORATION or
27 // its affiliates is strictly prohibited.
28 //
30 
31 #ifndef DW_FRAMEWORK_JSONPARAMETERPROVIDER_HPP_
32 #define DW_FRAMEWORK_JSONPARAMETERPROVIDER_HPP_
33 
35 
36 #include <modern-json/json.hpp>
37 
38 namespace dw
39 {
40 namespace framework
41 {
42 
45 {
46 protected:
55 
56 public:
58  JsonParameterProvider(nlohmann::json const* const data) noexcept;
60  ~JsonParameterProvider() override = default;
61 
63  void setJson(nlohmann::json const* const data) noexcept;
64 
66  nlohmann::json data() const noexcept;
67 
69  void registerAt(TypeBasedParameterProvider& provider) const override;
70 
71 protected:
73  nlohmann::json const* getJson(dw::core::StringView const& key) const;
74 
76  bool getBool(dw::core::StringView const& key, void* const out) const;
78  bool getInt8(dw::core::StringView const& key, void* const out) const;
80  bool getInt16(dw::core::StringView const& key, void* const out) const;
82  bool getInt32(dw::core::StringView const& key, void* const out) const;
84  bool getInt64(dw::core::StringView const& key, void* const out) const;
86  bool getUint8(dw::core::StringView const& key, void* const out) const;
88  bool getUint16(dw::core::StringView const& key, void* const out) const;
90  bool getUint32(dw::core::StringView const& key, void* const out) const;
92  bool getUint64(dw::core::StringView const& key, void* const out) const;
94  bool getFloat32(dw::core::StringView const& key, void* const out) const;
96  bool getFloat64(dw::core::StringView const& key, void* const out) const;
98  bool getString(dw::core::StringView const& key, void* const out) const;
100  bool getStringView(dw::core::StringView const& key, void* const out) const;
101 
103  bool getVectorBool(dw::core::StringView const& key, void* const out) const;
105  bool getVectorInt8(dw::core::StringView const& key, void* const out) const;
107  bool getVectorInt16(dw::core::StringView const& key, void* const out) const;
109  bool getVectorInt32(dw::core::StringView const& key, void* const out) const;
111  bool getVectorInt64(dw::core::StringView const& key, void* const out) const;
113  bool getVectorUint8(dw::core::StringView const& key, void* const out) const;
115  bool getVectorUint16(dw::core::StringView const& key, void* const out) const;
117  bool getVectorUint32(dw::core::StringView const& key, void* const out) const;
119  bool getVectorUint64(dw::core::StringView const& key, void* const out) const;
121  bool getVectorFloat32(dw::core::StringView const& key, void* const out) const;
123  bool getVectorFloat64(dw::core::StringView const& key, void* const out) const;
125  bool getVectorString(dw::core::StringView const& key, void* const out) const;
127  bool getVectorStringView(dw::core::StringView const& key, void* const out) const;
128 
130  bool getBoolByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
132  bool getInt8ByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
134  bool getInt16ByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
136  bool getInt32ByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
138  bool getInt64ByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
140  bool getUint8ByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
142  bool getUint16ByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
144  bool getUint32ByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
146  bool getUint64ByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
148  bool getFloat32ByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
150  bool getFloat64ByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
152  bool getStringByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
154  bool getStringViewByIndex(dw::core::StringView const& key, size_t const index, void* const out) const;
155 
156 private:
158  nlohmann::json const* m_data;
159 };
160 
161 } // namespace framework
162 } // namespace dw
163 
164 #endif // DW_FRAMEWORK_JSONPARAMETERPROVIDER_HPP_
bool getFloat64(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a float64_t value.
JsonParameterProvider(JsonParameterProvider const &)=default
Copy constructor.
bool getVectorInt16(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of int16_t value.
bool getBool(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a bool value.
bool getUint32ByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a uint32_t value from an array by index.
void setJson(nlohmann::json const *const data) noexcept
Set the JSON data.
bool getUint64(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a uint64_t value.
bool getInt64ByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a int64_t value from an array by index.
bool getVectorFloat32(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of float32_t value.
bool getVectorUint32(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of uint32_t value.
nlohmann::json data() const noexcept
Get the JSON data.
bool getFloat32ByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a float32_t value from an array by index.
A parameter provider which dispatches the retrieval of the parameter value to registered handlers whi...
bool getVectorUint64(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of uint64_t value.
bool getVectorFloat64(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of float64_t value.
bool getUint16ByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a uint16_t value from an array by index.
A parameter provider which retrieves parameter values from JSON data.
bool getUint8(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a uint8_t value.
bool getVectorStringView(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of dw::core::StringView value.
bool getVectorUint8(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of uint8_t value.
bool getFloat32(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a float32_t value.
~JsonParameterProvider() override=default
Destructor.
JsonParameterProvider & operator=(JsonParameterProvider const &)=default
Copy assignment operator.
bool getInt32(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a int32_t value.
bool getVectorInt8(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of int8_t value.
bool getStringView(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a dw::core::StringView value.
bool getInt16(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a int16_t value.
bool getFloat64ByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a float64_t value from an array by index.
nlohmann::json const * getJson(dw::core::StringView const &key) const
Get JSON value for the passed key.
bool getUint32(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a uint32_t value.
bool getUint16(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a uint16_t value.
bool getInt32ByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a int32_t value from an array by index.
void registerAt(TypeBasedParameterProvider &provider) const override
bool getInt64(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a int64_t value.
bool getInt8(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a int8_t value.
bool getStringViewByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a dw::core::StringView value from an array by index. ...
bool getVectorInt32(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of int32_t value.
bool getVectorBool(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of bool value.
bool getStringByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a std::string value from an array by index.
bool getVectorString(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of std::string value.
bool getInt16ByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a int16_t value from an array by index.
bool getBoolByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a bool value from an array by index.
Definition: Exception.hpp:46
bool getVectorInt64(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of int64_t value.
bool getInt8ByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a int8_t value from an array by index.
bool getUint64ByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a uint64_t value from an array by index.
bool getString(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a std::string value.
bool getVectorUint16(dw::core::StringView const &key, void *const out) const
Handler function to retrieve a vector of uint16_t value.
bool getUint8ByIndex(dw::core::StringView const &key, size_t const index, void *const out) const
Handler function to retrieve a uint8_t value from an array by index.
The additional interface a ParameterProvider can implement so it can be registered at a TypeBasedPara...