open62541pp 0.17.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
opcua::DataSourceBase Class Referenceabstract

#include <nodestore.hpp>

Inheritance diagram for opcua::DataSourceBase:
[legend]

Detailed Description

Data source base class for variable nodes.

The server redirects every read and write request to callback functions. Internally, the data source needs to implement its own memory management.

See also
https://www.open62541.org/doc/1.3/tutorial_server_datasource.html
Examples
server_datasource.cpp.

Definition at line 60 of file nodestore.hpp.

Public Member Functions

virtual StatusCode read (Session &session, const NodeId &id, const NumericRange *range, DataValue &value, bool timestamp)=0
 
virtual StatusCode write (Session &session, const NodeId &id, const NumericRange *range, const DataValue &value)=0
 
UA_DataSource create (bool ownsAdapter) override
 
- Public Member Functions inherited from opcua::PluginAdapter< UA_DataSource >
 PluginAdapter ()=default
 
 PluginAdapter (const PluginAdapter &)=default
 
 PluginAdapter (PluginAdapter &&) noexcept=default
 
virtual ~PluginAdapter ()=default
 
PluginAdapteroperator= (const PluginAdapter &)=default
 
PluginAdapteroperator= (PluginAdapter &&) noexcept=default
 

Additional Inherited Members

- Public Types inherited from opcua::PluginAdapter< UA_DataSource >
using PluginType
 

Member Function Documentation

◆ read()

virtual StatusCode opcua::DataSourceBase::read ( Session & session,
const NodeId & id,
const NumericRange * range,
DataValue & value,
bool timestamp )
pure virtual

Callback to set the read value, the result status and optionally a source timestamp.

Note
Zero-copy operations are possible. It is not required to return a copy of the actual content data. You can return a pointer to memory owned by the user. Memory can be reused between read callbacks of a data source, as the result is already encoded on the network buffer between each read operation. To use zero-copy reads, set the value of the Variant (DataValue::setValue) without copying, e.g. with Variant::assign.
Parameters
sessionCurrent session
idThe identifier of the node being read from
rangeIf not nullptr, then the data source shall return only a selection of the (non-scalar) data. Set UA_STATUSCODE_BADINDEXRANGEINVALID in value if this does not apply.
valueThe DataValue that is returned to the reader
timestampSet the source timestamp of value if true
Returns
StatusCode
Examples
server_datasource.cpp.

◆ write()

virtual StatusCode opcua::DataSourceBase::write ( Session & session,
const NodeId & id,
const NumericRange * range,
const DataValue & value )
pure virtual

Callback to write the value into a data source.

Parameters
sessionCurrent session
idThe identifier of the node being written to
rangeIf not nullptr, then only this selection of (non-scalar) data should be written into the data source.
valueThe DataValue that has been written by the writer
Returns
StatusCode
Examples
server_datasource.cpp.

◆ create()

UA_DataSource opcua::DataSourceBase::create ( bool ownsAdapter)
overridevirtual