NVIDIA NvNeural SDK  2022.2
GPU inference framework for NVIDIA Nsight Deep Learning Designer
XmlParameterNode.h
Go to the documentation of this file.
1 /*
2 * SPDX-FileCopyrightText: Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: MIT
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23 
25 
26 #ifndef NVNEURAL_XMLPARAMETERNODE_H
27 #define NVNEURAL_XMLPARAMETERNODE_H
28 
29 #include <nvneural/CoreTypes.h>
30 #include <nvneural/CoreHelpers.h>
31 #include <Pugixml/pugixml.hpp>
32 
33 namespace nvneural {
34 
45 class XmlParameterNode : public refobj::RefObjectBase<refobj::Implements<IParameterNode>>
46 {
47 public:
53  explicit XmlParameterNode(pugi::xml_node node);
54 
56  NeuralResult getInteger(const char* pParameterName, int32_t* pIntOut) const noexcept override;
58  NeuralResult getSize(const char* pParameterName, size_t* pSizeOut) const noexcept override;
60  NeuralResult getFloat(const char* pParameterName, float* pFloatOut) const noexcept override;
62  NeuralResult getString(const char* pParameterName, const char** pStringOut) const noexcept override;
64  NeuralResult getDimension(const char* pParameterName, TensorDimension* pDimOut) const noexcept override;
65 
67  NeuralResult setInteger(const char* pParameterName, int32_t value) noexcept override;
69  NeuralResult setSize(const char* pParameterName, size_t value) noexcept override;
71  NeuralResult setFloat(const char* pParameterName, float value) noexcept override;
73  NeuralResult setString(const char* pParameterName, const char* pString) noexcept override;
75  NeuralResult setDimension(const char* pParameterName, TensorDimension value) noexcept override;
76 
77 private:
78  pugi::xml_node m_node;
79 
80  static std::string serializeFloat(float value);
81  NeuralResult setAttribute(const char* pParameterName, const std::string& value);
82 };
83 
84 } // namespace nvneural
85 
86 #endif // NVNEURAL_XMLPARAMETERNODE_H
Common helper classes and template function implementations.
Fundamental NvNeural data types are declared here.
NeuralResult
NeuralResult is a generic success/failure result type similar to COM HRESULT.
Definition: CoreTypes.h:275
IParameterNode implementation wrapping a pugi::xml_node.
Definition: XmlParameterNode.h:46
NeuralResult getFloat(const char *pParameterName, float *pFloatOut) const noexcept
Retrieves a floating-point value.
Definition: XmlParameterNode.cpp:91
NeuralResult getString(const char *pParameterName, const char **pStringOut) const noexcept
Retrieves a UTF-8 string value.
Definition: XmlParameterNode.cpp:111
NeuralResult getInteger(const char *pParameterName, int32_t *pIntOut) const noexcept
Retrieves a signed integer value.
Definition: XmlParameterNode.cpp:51
NeuralResult setDimension(const char *pParameterName, TensorDimension value) noexcept
Saves a tensor dimension.
Definition: XmlParameterNode.cpp:157
NeuralResult setString(const char *pParameterName, const char *pString) noexcept
Saves a UTF-8 string value.
Definition: XmlParameterNode.cpp:152
NeuralResult getDimension(const char *pParameterName, TensorDimension *pDimOut) const noexcept
Retrieves a tensor dimension.
Definition: XmlParameterNode.cpp:122
NeuralResult setSize(const char *pParameterName, size_t value) noexcept
Saves an unsigned integer that can represent the result of sizeof().
Definition: XmlParameterNode.cpp:140
XmlParameterNode(pugi::xml_node node)
Creates an XmlParameterNode.
Definition: XmlParameterNode.cpp:46
NeuralResult getSize(const char *pParameterName, size_t *pSizeOut) const noexcept
Retrieves an unsigned integer value that can represent the result of sizeof().
Definition: XmlParameterNode.cpp:71
NeuralResult setInteger(const char *pParameterName, int32_t value) noexcept
Saves an integer.
Definition: XmlParameterNode.cpp:134
NeuralResult setFloat(const char *pParameterName, float value) noexcept
Saves a floating-point value.
Definition: XmlParameterNode.cpp:146
TensorDimension describes the dimensions of a four-dimensional image tensor.
Definition: CoreTypes.h:136
Parameterized base class implementing common IRefObject operations.
Definition: RefObject.h:336