How to know if node exist

Hello team,

Hope you are doing well.

I have a question that seem to be rather easy, but I can’t find the answer… I have multiple camera without the same firmware. They have a few nodes that the name isn’t the same (exposure time abs and exposure time for example).

So my question is : how can I know if a node exist ? Like if I want to use ExposureTime node, is there a device->Nodes()->Exist(“Std::ExposureTime”); ? or maybe there is another way to know that ?

For now, the only way I get is to use a try catch for each node… That seems rather badly.

Thanks in advance.

Cheers,
Axel

Hi @AxelDosSantosDoAlto,

if you dont want to stick with the general way of handling CvbExceptions, you could try the following:

https://help.commonvisionblox.com/NextGen/14.1/cvbpp/dd/dff/class_cvb_1_1_gen_api_1_1_node_map.html#a82d6ac7e2d944dd0310b2c1bdcc65a5e

The NodeMap class has a Nodes() function that basically gives you a dictionary of all Nodes in the NodeMap.
So with this information you can check if the node you are looking for is on your NodeMap bevorehand.

Cheers
Chris

With CVB 14.1 you can also use the TryGetNode function like this:

if (auto intNode = devNodeMap_->TryGetNode<Cvb::IntegerNode>(featureName))
{

}
1 Like

Hello guy,

Sorry for my late answer. Everything is ok for me thanks to @Sebastian and the TryGetNode method !

Thanks you very much.

There is an exemple of how I’m dealing with the nodes for whoever need an exemple :

[...]
m_node_scpsp_packet_size = getCvbIntegerNode("TLDevice", "PacketSize");
if (m_node_scpsp_packet_size == nullptr)
	throw std::runtime_error("Error with node PacketSize / TLDevice.");
[...]

where

[...]
const std::string m_node_name_for_device = "Device";
[...]
Cvb::IntegerNodePtr CCameraCvbGenicam::getCvbIntegerNode(std::string node_map_name, std::string node_name) {
	return m_device->NodeMap(node_map_name)->TryGetNode<Cvb::IntegerNode>(node_name);
}
[...]
``