CVB++ 14.0
IntSwissKnifeNode Class Reference

Read only node to calculate formulas on the client side with integer arithmetic. More...

#include <cvb/gevserver/int_swiss_knife_node.hpp>

Inherits IntegerBaseNode.

Public Member Functions

GenApi::AccessMode AccessMode () const override
 Swiss knifes are always read only. More...
 
GenApi::CacheMode CacheMode () const override
 Here we may have multiple ones and can give no sane answer. More...
 
template<class Rep , class Period >
std::chrono::duration< Rep, Period > PollingTime () const
 Always time span zero as there may be multiple values. More...
 
std::vector< IntegerBaseNodePtrVariables () const
 Dictionary containing all variables of this node. More...
 
String Formula () const
 Formula that is evaluated when the value is read. More...
 
void SetFormula (const String &value)
 Formula that is evaluated when the value is read. More...
 
void Add (const NodePtr &item, const NodeList &kind, const String &key)
 Adds a Node item with a key string. More...
 
- Public Member Functions inherited from IntegerBaseNode
std::int64_t Increment () const
 Gets the increment of this value. More...
 
std::int64_t Max () const
 Gets the maximal allowed number for this value. More...
 
std::int64_t Min () const
 Gets the minimal allowed number for this value. More...
 
GenApi::NumberRepresentation Representation () const
 Gets how the value is to be represented. More...
 
void SetRepresentation (const GenApi::NumberRepresentation &representation)
 Sets how the value is to be represented. More...
 
virtual String Unit () const
 Gets the unit of this node's value. More...
 
std::int64_t Value () const
 Gets the value of this integer node. More...
 
void SetValue (const std::int64_t &value)
 Sets the value of this integer node. More...
 
void FromString (const String &value) override
 Sets this node's value from the string value . More...
 
String ToString () const override
 Gets the string representation of this node. More...
 
- Public Member Functions inherited from SelectorNode
bool IsSelector () const
 Gets whether this node selects at least one other. More...
 
std::vector< ValueNodePtrSelectedNodes () const
 Gets all nodes selected by this one. More...
 
- Public Member Functions inherited from ValueNode
virtual bool IsStreamable () const
 Gets whether this node should be used when the camera settings are stored. More...
 
virtual void SetIsStreamable (const std::int64_t &value)
 Sets whether this node should be used when the camera settings are stored. More...
 
template<class Rep , class Period >
std::chrono::duration< Rep, Period > PollingTime () const
 Gets the polling time of this value. More...
 
virtual String ToString () const
 Returns this node's value as a string representation. More...
 
virtual void FromString (const String &value)
 Sets this node's value from the string value. More...
 
EventCookie RegisterEventWrittenUpdated (std::function< void(ValueNode &)> handler)
 Register a listener to node written event. More...
 
void UnregisterEventWrittenUpdated (EventCookie eventCookie) noexcept
 Manually unregister a listener to the node written event. More...
 
EventCookie RegisterEventOnReadUpdated (std::function< void(ValueNode &)> handler)
 Register a listener to node on read event. More...
 
void UnregisterEventOnReadUpdated (EventCookie eventCookie) noexcept
 Manually unregister a listener to the node on read event. More...
 
- Public Member Functions inherited from Node
void Add (const NodePtr &item, const NodeList &kind)
 Adds a Node item . More...
 
bool Remove (const NodePtr &item, const NodeList &kind)
 Remove a single Node item from this collection. More...
 
void * Handle () const noexcept
 Classic API node handle. More...
 
NodeMapPtr NodeMap () const
 Gets the node map of this GevServer node.
 
String ToolTip () const
 Gets the short descriptive text of this node. More...
 
void SetToolTip (const String &value)
 Sets the short descriptive text of this node. More...
 
String Description () const
 Gets the long descriptive text of this node. More...
 
void SetDescription (const String &value)
 Sets the long descriptive text of this node. More...
 
virtual GenApi::AccessMode AccessMode () const
 Gets the GenApi::AccessMode of this node.
 
Cvb::GenApi::AccessMode ImposedAccessMode () const
 Gets the node's default AccessMode. More...
 
void SetImposedAccessMode (const Cvb::GenApi::AccessMode &accessMode)
 Overrides the node's default AccessMode.
 
bool IsImplemented () const
 Helper to check whether this node is implemented. More...
 
IntegerBaseNodePtr IsImplementedConfig () const
 Gets the node that specifies whether a node is implemented in the device or not.
 
void SetIsImplementedConfig (const IntegerBaseNodePtr &node)
 Sets the node that specifies whether a node is implemented in the device or not. More...
 
bool IsAvailable () const
 Helper to check whether this node is available. More...
 
IntegerBaseNodePtr IsAvailableConfig () const
 Gets the node that specifies whether a node is currently available or not. More...
 
void SetIsAvailableConfig (const IntegerBaseNodePtr &node)
 Sets the node that specifies whether a node is currently available or not. More...
 
bool IsReadable () const
 Helper to check whether this node is readable. More...
 
bool IsWritable () const
 Helper to check whether this node is writable. More...
 
IntegerBaseNodePtr IsLockedConfig () const
 Gets the node that specifies whether a node is currently read only or not. More...
 
void SetIsLockedConfig (const IntegerBaseNodePtr &node)
 Sets the node that specifies whether a node is currently read only or not. More...
 
virtual Cvb::GenApi::CacheMode CacheMode () const
 Gets the cache mode of this node. More...
 
Cvb::GenApi::Visibility Visibility () const
 Gets the complexity level of this node. More...
 
void SetVisibility (const Cvb::GenApi::Visibility &value)
 Gets the complexity level of this node. More...
 
NodePtr AliasNode () const
 Gets the node that is an alias value for this node. More...
 
void SetAliasNode (const NodePtr &value)
 Sets the node that is an alias value for this node. More...
 
String Name () const
 Gets the full name of this node. More...
 
String NameOnly () const
 Gets the name of this node without namespace. More...
 
GevServer::Namespace Namespace () const
 Gets the namespace this node is in. More...
 
String EventID () const
 Nodes with an event identifier may become invalidated if an event/message is delivered from the device. More...
 
bool IsFeature () const
 Gets whether this node is considered a feature node. More...
 
bool IsDeprecated () const
 Gets whether this node is considered deprecated. More...
 
String DisplayName () const
 Gets the display name of this node. More...
 
void SetDisplayName (const String &value)
 Sets the display name of this node. More...
 
EventCookie RegisterEventUpdated (std::function< void(Node &)> handler)
 Register a listener to node updated event. More...
 
void UnregisterEventUpdated (EventCookie eventCookie) noexcept
 Manually unregister a listener to the node updated event. More...
 
template<class NodeT , class ValueConfigNodeType >
ValueNodePtr GetTerminalRegisterNode (const NodeT *node, std::function< bool(Node *)> f) const
 Try to get terminal register node. More...
 

Static Public Member Functions

static IntSwissKnifeNodePtr Create (const String &name, const GevServer::Namespace &nameSpace)
 Creates a new IntSwissKnifeNode with the given name and nameSpace . More...
 
static IntSwissKnifeNodePtr Create (const String &name)
 Creates a new IntSwissKnifeNode with the given name . More...
 
- Static Public Member Functions inherited from Node
static NodePtr FromName (const NodeMapPtr &nodeMap, const String &name)
 Factory to create the appropriate Node object on the given nodeMap based on the given name . More...
 
template<class T , class... ARGS>
static std::shared_ptr< T > FromHandle (HandleGuard< Node > &&guard, ARGS &&... args)
 Factory to create the appropriate Node object based on the given handle . More...
 

Additional Inherited Members

- Protected Member Functions inherited from Node
template<class T >
std::vector< std::shared_ptr< T > > GetDependentNodes (const NodeList &type) const
 Gets the nodes categorized by this node. More...
 
- Static Protected Member Functions inherited from Node
static String EnsureNodeNameOnly (const String &name)
 Throws if the given name has a namespace prefix. More...
 
static NodePtr FromHandle (HandleGuard< Node > &&guard, const NodeMapPtr &nodeMap)
 Factory to create the appropriate Node object based on the given handle . More...
 
static GevServer::Namespace ParseNamespace (const String &name)
 Gets the Namespace from the given name . More...
 
static String ParseName (const String &name)
 Gets the name part of the given node name . More...
 
static GevServer::NodeType NodeType (void *handle)
 Gets the node type from the nodes native handle. More...
 

Detailed Description

Read only node to calculate formulas on the client side with integer arithmetic.

Due to the integer arithmetic used in this node a System.Math.Floor(double) operation is performed after each calculation: The computation 2 * (3 / 2) results to two and not three.

See the Formula property for available operations.

Member Function Documentation

◆ AccessMode()

GenApi::AccessMode AccessMode ( ) const
inlineoverridevirtual

Swiss knifes are always read only.

Returns
AccessMode.RO.

Reimplemented from Node.

◆ Add()

void Add ( const NodePtr item,
const NodeList kind,
const String key 
)
inline

Adds a Node item with a key string.

Parameters
itemNode Object to add.
kindGevServer::NodeList Kind of node.
keyCvb::String Key string.

If item is added as a child then key will be appended as its variable name that can be referenced by this node's formula.

◆ CacheMode()

GenApi::CacheMode CacheMode ( ) const
inlineoverridevirtual

Here we may have multiple ones and can give no sane answer.

Returns
CacheMode.NoCache.

Reimplemented from Node.

◆ Create() [1/2]

static IntSwissKnifeNodePtr Create ( const String name)
inlinestatic

Creates a new IntSwissKnifeNode with the given name .

If the name does not contain a namespace prefix the Namespace::Custom is used.

You must add this node to a NodeMap before most operations are possible!

Parameters
nameName with optional namespace prefix.

◆ Create() [2/2]

static IntSwissKnifeNodePtr Create ( const String name,
const GevServer::Namespace nameSpace 
)
inlinestatic

Creates a new IntSwissKnifeNode with the given name and nameSpace .

You must add this node to a NodeMap before most operations are possible!

Parameters
nameNode name without namespace prefix.
nameSpaceNamespace to place the node in.

◆ Formula()

String Formula ( ) const
inline

Formula that is evaluated when the value is read.

String containing the formula.

◆ PollingTime()

std::chrono::duration< Rep, Period > PollingTime ( ) const
inline

Always time span zero as there may be multiple values.

Returns
TimeSpan.Zero.

◆ SetFormula()

void SetFormula ( const String value)
inline

Formula that is evaluated when the value is read.

Add the Variables before setting the formula as the formula's validity is checked on set.

The following operations are supported:

(, ) brackets for grouping/overriding operator precedence: 3 * (2 + 3) results to 15.
+, -, *, / addition, subtraction, multiplication and devision: 3 * 7 + 4 / 2 results to 23.
% remainder: 7 % 4 results to 3.
** power: 2 ** 3 results to 8.
&, |, ^, ~ bitwise AND; OR, XOR and NOT: 2 | 1 results to 3.
&&, || logical AND and OR: 1 && 0 results to 0.
<>, =, >, <, <=, >= logical UNEQUAL, EQUAL, GREATER, LESS, LESS OR EQUAL and GREATER OR EQUAL: 3 >= 2 results to 1.
<<, >> shift left and shift right: 1 << 2 results to 4.
? : conditional operator <condition> ? <true case> : <false case>.
SGN Signum function: -1 if value smaller than 0; 0 if value equal to 0; 1 if value greater than 0: SGN(42) results to 1.
NEG Negative function: NEG(-42) results to 42.

Keep in mind that a Math.Floor(double) operation is executed after each calculation. Logical operations result in 1 for true and 0 for false. Any number that is evaluated in a logical true/false condition is true as long as it is not 0.

String containing the formula.

◆ Variables()

std::vector< IntegerBaseNodePtr > Variables ( ) const
inline

Dictionary containing all variables of this node.

The variable names (the key of the dictionary) must consist only of capitalized alphabetical characters.

Dictionary where the key is the variable name and the value is the node holding the variables value.