IDS peak genericC++ v1.16.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:

Classes

class  ScopedNodeMapLock
 RAII object that holds the NodeMap lock. 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)
 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)
 Find a node with the given name and type.
std::shared_ptr< nodes::Node > TryFindNode (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 > TryFindNode (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 ()
 Acquires the NodeMap lock. Use this function to synchronize sequences of dependent NodeMap operations across multiple threads.
std::unique_ptr< ScopedNodeMapLock > TryLock ()
 Attempts to acquire the NodeMap lock without blocking. Use this function to synchronize sequences of dependent NodeMap operations across multiple threads. If the NodeMap is currently locked by another thread, this function returns immediately without acquiring the lock.
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

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

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.

Note
This function does not consider the access status and whether a node is implemented or available.
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.

Note
This function does not consider the access status and whether a node is implemented or available.
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.

Note
The filePath is UTF-8 encoded.
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

Acquires the NodeMap lock. Use this function to synchronize sequences of dependent NodeMap operations across multiple threads.

Note
Individual NodeMap operations are already thread-safe and do not require explicit locking. However, if multiple operations must be performed as a single logical unit, they should be protected by this lock to prevent interleaving with operations from other threads.

A common example is the use of selectors: changing a selector (e.g. setting "GainSelector" to "DigitalRed") and then accessing the selected node (e.g. "Gain"). Without holding the lock, another thread could change the selector between these operations, causing the wrong setting to be accessed.

Returns
A ScopedNodeMapLock that holds the lock until it is destroyed.
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.

See Node Caching and Polling Concepts for conceptual guidance on polling and cache interaction.

This method implements node polling on node map level. Pass the real elapsed time since the previous call; it is used to determine when nodes with a polling time need to be updated.

The API does not poll automatically. Applications should call this method periodically, for example from a service or UI loop while dynamic node state is in use.

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.

Note
The filePath is UTF-8 encoded.
Since
1.1
Exceptions
InvalidArgumentExceptionThe given file path is invalid
InternalErrorExceptionAn internal error has occurred.

◆ TryFindNode() [1/2]

std::shared_ptr< nodes::Node > peak::core::NodeMap::TryFindNode ( 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 or nullptr if no node with the given name exists.
Since
1.10.0
Exceptions
InternalErrorExceptionAn internal error has occurred.

◆ TryFindNode() [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::TryFindNode ( 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 or nullptr if no node with the given name exists.
Since
1.10.0
Exceptions
InvalidCastExceptionThe node cannot be cast to the given type
InternalErrorExceptionAn internal error has occurred.

◆ TryLock()

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

Attempts to acquire the NodeMap lock without blocking. Use this function to synchronize sequences of dependent NodeMap operations across multiple threads. If the NodeMap is currently locked by another thread, this function returns immediately without acquiring the lock.

Note
Individual NodeMap operations are already thread-safe and do not require explicit locking. However, if multiple operations must be performed as a single logical unit, they should be protected by this lock to prevent interleaving with operations from other threads.

A common example is the use of selectors: changing a selector (e.g. setting "GainSelector" to "DigitalRed") and then accessing the selected node (e.g. "Gain"). Without holding the lock, another thread could change the selector between these operations, causing the wrong setting to be accessed.

Returns
A ScopedNodeMapLock if the lock was successfully acquired; otherwise, a null unique pointer.
Since
1.11
Exceptions
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: