NVIDIA DeepStream SDK API Reference

9.2 Release
9.2/service-maker/sources/python/src/bindings/node.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include "nodedoc.h"
19 
20 class Node : public Element {
21 public:
22  Node& link(Node& target) {
23  Element::link(static_cast<Element&>(target));
24  return *this;
25  }
26 
27  Node& link(Node& target, pair<string, string> tips) {
28  Element::link(static_cast<Element&>(target), tips);
29  return *this;
30  }
31 
32  Node& attach(Probe* probe, const string tips) {
33  Element::addProbe(probe, tips);
34  return *this;
35  }
36 
37  Node& attach(Receiver_* receiver, const string tips) {
38  size_t begin = 0;
39  size_t end = 0;
40  while (end != std::string::npos) {
41  end = tips.find("/", begin);
42  std::string signal = tips.substr(begin, end);
43  Element::connectSignal(signal, receiver);
44  begin = end+1;
45  }
46  return *this;
47  }
48 
49  Node& attach(Feeder_* feeder, const string tips) {
50  size_t begin = 0;
51  size_t end = 0;
52  while (end != std::string::npos) {
53  end = tips.find("/", begin);
54  std::string signal = tips.substr(begin, end);
55  Element::connectSignal(signal, feeder);
56  begin = end+1;
57  }
58  return *this;
59  }
60 
61  CustomObject* find(const string& name) {
62  auto itr = objects_->find(name);
63  if (itr != objects_->end()) {
64  return itr->second.get();
65  }
66  return nullptr;
67  }
68 
69  virtual ~Node() {
70  if (objects_.use_count() == 1) {
72  for (auto& pair: *objects_) {
73  pair.second.release();
74  }
75  }
76  }
77 };
78 
79 void module_node_bind(py::module &m);
80 
81 void module_node_bind(py::module &m) {
82  py::class_<Node>(m, "Node", pydeepstreamdoc::node::NodeDoc::descr)
83  .def_property_readonly("name", &Object::getName)
85  .def("link", (Node& (Node::*)(Node&, pair<string, string>)) &Node::link, pydeepstreamdoc::node::NodeDoc::link_info)
86  .def("set", [](Node& self, py::dict args){
87  for (auto item : args) {
88  string key = item.first.cast<string>();
89  Object::Value value = item.second.cast<Object::Value>();
90  self.set(key, value);
91  }
93  .def("set", [](Node& self, py::list dicts){
94  for (auto dict : dicts) {
95  py::dict d = dict.cast<py::dict>();
96  for (auto item : d) {
97  string key = item.first.cast<string>();
98  Object::Value value = item.second.cast<Object::Value>();
99  self.set(key, value);
100  }
101  }
103  .def("get", [](Node& self, string& key) {
104  Object::Value value;
105  self.getProperty(key, value);
106  return value;
108  .def("attach", (Node& (Node::*)(Probe*, const string)) &Node::attach, py::keep_alive<1, 2>(), pydeepstreamdoc::node::NodeDoc::attach_probe, py::arg("probe"), py::arg("tips")="")
109  .def("attach", (Node& (Node::*)(Receiver_*, const string)) &Node::attach, py::keep_alive<1, 2>(), pydeepstreamdoc::node::NodeDoc::attach_receiver, py::arg("receiver"), py::arg("tips")="")
110  .def("attach", (Node& (Node::*)(Feeder_*, const string)) &Node::attach, py::keep_alive<1, 2>(), pydeepstreamdoc::node::NodeDoc::attach_feeder, py::arg("feeder"), py::arg("tips")="")
111  .def("find", &Node::find, py::return_value_policy::reference, pydeepstreamdoc::node::NodeDoc::find)
112  .def("__repr__", [](Node& self) {
113  return "Node(name=" + self.getName() + ")";
114  });
115 }
Node::~Node
virtual ~Node()
Definition: 9.2/service-maker/sources/python/src/bindings/node.h:69
pydeepstreamdoc::node::NodeDoc::find
constexpr const char * find
Definition: service-maker/sources/python/src/bindings/docstrings/nodedoc.h:38
pydeepstreamdoc::node::NodeDoc::get
constexpr const char * get
Definition: service-maker/sources/python/src/bindings/docstrings/nodedoc.h:34
pydeepstreamdoc::node::NodeDoc::set
constexpr const char * set
Definition: service-maker/sources/python/src/bindings/docstrings/nodedoc.h:32
Node::attach
Node & attach(Feeder_ *feeder, const string tips)
Definition: 9.2/service-maker/sources/python/src/bindings/node.h:49
pydeepstreamdoc::node::NodeDoc::link
constexpr const char * link
Definition: service-maker/sources/python/src/bindings/docstrings/nodedoc.h:30
Probe
Definition: service-maker/sources/python/src/bindings/probe.h:98
Node::attach
Node & attach(Receiver_ *receiver, const string tips)
Definition: 9.2/service-maker/sources/python/src/bindings/node.h:37
Node::attach
Node & attach(Probe *probe, const string tips)
Definition: 9.2/service-maker/sources/python/src/bindings/node.h:32
pydeepstreamdoc::node::NodeDoc::set2
constexpr const char * set2
Definition: service-maker/sources/python/src/bindings/docstrings/nodedoc.h:33
Node::find
CustomObject * find(const string &name)
Definition: 9.2/service-maker/sources/python/src/bindings/node.h:61
pydeepstreamdoc::node::NodeDoc::descr
constexpr const char * descr
Definition: service-maker/sources/python/src/bindings/docstrings/nodedoc.h:26
half_float::detail::signal
HALF_CONSTEXPR_NOERR unsigned int signal(unsigned int nan)
Signal and silence signaling NaN.
Definition: includes/half.hpp:708
Receiver_
Definition: service-maker/sources/python/src/bindings/buffer.h:80
pydeepstreamdoc::node::NodeDoc::attach_receiver
constexpr const char * attach_receiver
Definition: service-maker/sources/python/src/bindings/docstrings/nodedoc.h:36
Node::link
Node & link(Node &target)
Definition: 9.2/service-maker/sources/python/src/bindings/node.h:22
Node
Definition: service-maker/sources/python/src/bindings/node.h:20
pydeepstreamdoc::node::NodeDoc::link_info
constexpr const char * link_info
Definition: service-maker/sources/python/src/bindings/docstrings/nodedoc.h:31
pydeepstreamdoc::node::NodeDoc::attach_probe
constexpr const char * attach_probe
Definition: service-maker/sources/python/src/bindings/docstrings/nodedoc.h:35
module_node_bind
void module_node_bind(py::module &m)
Definition: 9.2/service-maker/sources/python/src/bindings/node.h:81
receiver
static deepstream::Cloud2DeviceReceiver receiver
Definition: service-maker/sources/modules/smart_recording_action/smart_recording_action.hpp:29
Node::link
Node & link(Node &target, pair< string, string > tips)
Definition: 9.2/service-maker/sources/python/src/bindings/node.h:27
Feeder_
Definition: service-maker/sources/python/src/bindings/buffer.h:47
pydeepstreamdoc::osd::ArrowHeadDoc::end
constexpr const char * end
Definition: service-maker/sources/python/src/bindings/docstrings/osddoc.h:34
pydeepstreamdoc::node::NodeDoc::attach_feeder
constexpr const char * attach_feeder
Definition: service-maker/sources/python/src/bindings/docstrings/nodedoc.h:37