IDS peak genericC++ v1.9.0
Loading...
Searching...
No Matches
peak::core::NodeMap Class Reference

Represents a GenAPI node map. More...

#include <peak/node_map/peak_node_map.hpp>

Inheritance diagram for peak::core::NodeMap:

Data Structures

class  ScopedNodeMapLock
 Holds a recursive lock on the NodeMap. More...
 

Public Types

using NodeFilterFunction = std::function< bool(const std::shared_ptr< const nodes::Node > &nodeToFilter)>
 

Public Member Functions

 NodeMap ()=delete
 
 ~NodeMap ()=default
 
 NodeMap (const NodeMap &other)=delete
 
NodeMap & operator= (const NodeMap &other)=delete
 
 NodeMap (NodeMap &&other)=delete
 
NodeMap & operator= (NodeMap &&other)=delete
 
bool HasNode (const std::string &name) const
 Checks whether the node map contains a node with the given name.
 
template<class NodeType , typename std::enable_if< std::is_base_of< nodes::Node, NodeType >::value, int >::type = 0>
bool HasNode (const std::string &name)
 Checks whether the node map contains a node with the given name and type.
 
std::shared_ptr< nodes::Node > FindNode (const std::string &name)
 Tries to find a node with the given name.
 
template<class NodeType , typename std::enable_if< std::is_base_of< nodes::Node, NodeType >::value, int >::type = 0>
std::shared_ptr< NodeType > FindNode (const std::string &name)
 Tries to find a node with the given name and type.
 
void InvalidateNodes ()
 Invalidates all nodes.
 
void PollNodes (int64_t elapsedTime_ms)
 Polls all nodes having a polling time.
 
std::vector< std::shared_ptr< nodes::Node > > Nodes () const
 Returns the nodes.
 
bool HasBufferSupportedChunks (const std::shared_ptr< Buffer > &buffer) const
 Checks if the Buffer contains chunks corresponding to the NodeMap.
 
void UpdateChunkNodes (const std::shared_ptr< Buffer > &buffer)
 Updates chunk information in the NodeMap.
 
bool HasEventSupportedData (const std::unique_ptr< Event > &event) const
 Checks if the Event contains data corresponding to the NodeMap.
 
void UpdateEventNodes (const std::unique_ptr< Event > &event)
 Updates event information in the NodeMap.
 
void StoreToFile (const std::string &filePath) const
 Stores the values of streamable nodes to the file at the given file path.
 
void LoadFromFile (const std::string &filePath)
 Loads the values of streamable nodes from the file at the given file path.
 
std::unique_ptr< ScopedNodeMapLock > Lock ()
 Locks a recursive mutex on the NodeMap.
 
PEAK_NODE_MAP_HANDLE Handle () const
 Get the backend handle.
 

Detailed Description

Represents a GenAPI node map.

This class allows to interact with the nodes of a module.

Member Typedef Documentation

◆ NodeFilterFunction

using peak::core::NodeMap::NodeFilterFunction = std::function<bool(const std::shared_ptr<const nodes::Node>& nodeToFilter)>

The type of node filter functions.

Constructor & Destructor Documentation

◆ NodeMap() [1/3]

peak::core::NodeMap::NodeMap ( )
delete

◆ ~NodeMap()

peak::core::NodeMap::~NodeMap ( )
default

◆ NodeMap() [2/3]

peak::core::NodeMap::NodeMap ( const NodeMap &  other)
delete

◆ NodeMap() [3/3]

peak::core::NodeMap::NodeMap ( NodeMap &&  other)
delete

Member Function Documentation

◆ FindNode() [1/2]

std::shared_ptr< nodes::Node > peak::core::NodeMap::FindNode ( const std::string &  name)
inline

Tries to find a node with the given name.

Parameters
[in]nameThe name of the node to find.
Returns
Found node.
If no node with the given name exists, a NotFoundException is thrown.
Since
1.0
Exceptions
NotFoundExceptionThere is no node with the given name
InternalErrorExceptionAn internal error has occurred.

◆ FindNode() [2/2]

template<class NodeType , typename std::enable_if< std::is_base_of< nodes::Node, NodeType >::value, int >::type = 0>
std::shared_ptr< NodeType > peak::core::NodeMap::FindNode ( const std::string &  name)
inline

Tries to find a node with the given name and type.

Parameters
[in]nameThe name of the node to find.
Returns
Found node.
If no node with the given name exists, a NotFoundException is thrown.
Since
1.0
Exceptions
NotFoundExceptionThere is no node with the given name
InvalidCastExceptionThe node cannot be cast to the given type
InternalErrorExceptionAn internal error has occurred.

◆ Handle()

PEAK_NODE_MAP_HANDLE peak::core::NodeMap::Handle ( ) const
inline

Get the backend handle.

Use this to use the c interface directly (not recommended)

Returns
The PEAK_NODE_MAP_HANDLE
Since
1.5

◆ HasBufferSupportedChunks()

bool peak::core::NodeMap::HasBufferSupportedChunks ( const std::shared_ptr< Buffer > &  buffer) const
inline

Checks if the Buffer contains chunks corresponding to the NodeMap.

Parameters
[in]bufferThe Buffer to check.
Since
1.1
Exceptions
InvalidArgumentExceptionThe given buffer is invalid.
InternalErrorExceptionAn internal error has occurred.

◆ HasEventSupportedData()

bool peak::core::NodeMap::HasEventSupportedData ( const std::unique_ptr< Event > &  event) const
inline

Checks if the Event contains data corresponding to the NodeMap.

Parameters
[in]eventThe Event to check.
Since
1.2
Exceptions
InvalidArgumentExceptionThe given event is invalid.
InternalErrorExceptionAn internal error has occurred.

◆ HasNode() [1/2]

template<class NodeType , typename std::enable_if< std::is_base_of< nodes::Node, NodeType >::value, int >::type = 0>
bool peak::core::NodeMap::HasNode ( const std::string &  name)
inline

Checks whether the node map contains a node with the given name and type.

Parameters
[in]nameThe name of the node to find.
Since
1.2
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ HasNode() [2/2]

bool peak::core::NodeMap::HasNode ( const std::string &  name) const
inline

Checks whether the node map contains a node with the given name.

Parameters
[in]nameThe name of the node to find.
Since
1.2
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ InvalidateNodes()

void peak::core::NodeMap::InvalidateNodes ( )
inline

Invalidates all nodes.

Since
1.0
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ LoadFromFile()

void peak::core::NodeMap::LoadFromFile ( const std::string &  filePath)
inline

Loads the values of streamable nodes from the file at the given file path.

Parameters
[in]filePathThe path of the file to load from.

The file to load has to use the GenApi persistence file format. It is not recommended to edit files using this format manually unless you are familiar with the GenApi persistence functionality.

Since
1.1
Exceptions
InvalidArgumentExceptionThe given file path is invalid
InternalErrorExceptionAn internal error has occurred.

◆ Lock()

std::unique_ptr< NodeMap::ScopedNodeMapLock > peak::core::NodeMap::Lock ( )
inline

Locks a recursive mutex on the NodeMap.

Use this to synchronize NodeMap access from multiple threads.

Note
Each individual access is already protected by this mutex, so the nodemap doesn't need to be locked for those. But often, nodemap access consists of multiple calls, e.g.: First, (1.) change a selector value (e.g. set "GainSelector" node to "DigitalRed"), then (2.) access a selected node (e.g. set value in "Gain" node). If a different thread changes the selector value between (1.) and (2.), (2.) will access the wrong selected node. These kinds of calls should be protected by this lock.
Returns
A ScopedNodeMapLock, which holds the lock and releases it on destruction.
Since
1.2
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ Nodes()

std::vector< std::shared_ptr< nodes::Node > > peak::core::NodeMap::Nodes ( ) const
inline

Returns the nodes.

Returns
Nodes
Since
1.0
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ operator=() [1/2]

NodeMap & peak::core::NodeMap::operator= ( const NodeMap &  other)
delete

◆ operator=() [2/2]

NodeMap & peak::core::NodeMap::operator= ( NodeMap &&  other)
delete

◆ PollNodes()

void peak::core::NodeMap::PollNodes ( int64_t  elapsedTime_ms)
inline

Polls all nodes having a polling time.

Parameters
[in]elapsedTime_msThe elapsed time since the last poll in milliseconds.
Since
1.0
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ StoreToFile()

void peak::core::NodeMap::StoreToFile ( const std::string &  filePath) const
inline

Stores the values of streamable nodes to the file at the given file path.

Parameters
[in]filePathThe path of the file to store to.

The stored file uses the GenApi persistence file format. It is not recommended to edit files using this format manually unless you are familiar with the GenApi persistence functionality.

Since
1.1
Exceptions
InvalidArgumentExceptionThe given file path is invalid
InternalErrorExceptionAn internal error has occurred.

◆ UpdateChunkNodes()

void peak::core::NodeMap::UpdateChunkNodes ( const std::shared_ptr< Buffer > &  buffer)
inline

Updates chunk information in the NodeMap.

Parameters
[in]bufferThe Buffer to update from.

When chunks are active, pass each new buffer to this method to parse the chunks and update the corresponding chunk nodes in the NodeMap.

Since
1.1
Exceptions
InvalidArgumentExceptionThe given buffer is invalid.
InternalErrorExceptionAn internal error has occurred.

◆ UpdateEventNodes()

void peak::core::NodeMap::UpdateEventNodes ( const std::unique_ptr< Event > &  event)
inline

Updates event information in the NodeMap.

Parameters
[in]eventThe Event to update from.

When events are active, pass each new event to this method to parse the event data and update the corresponding nodes in the NodeMap.

Since
1.2
Exceptions
InvalidArgumentExceptionThe given Event does not have supported data
InternalErrorExceptionAn internal error has occurred.

The documentation for this class was generated from the following files: