11#include "open62541pp/config.hpp"
29template <
typename Connection>
57#ifdef UA_ENABLE_ENCRYPTION
145 [[deprecated(
"use ServerConfig constructor and construct Server with ServerConfig")]]
149#ifdef UA_ENABLE_ENCRYPTION
158 [[deprecated(
"use ServerConfig constructor and construct Server with ServerConfig")]]
167 :
Server(
ServerConfig(port, certificate, privateKey, trustList, issuerList, revocationList)
189 [[deprecated(
"use ServerConfig::setApplicationUri via config() or pass config to Server")]]
194 [[deprecated(
"use ServerConfig::setProductUri via config() or pass config to Server")]]
199 [[deprecated(
"use ServerConfig::setApplicationName via config() or pass config to Server")]]
205 [[deprecated(
"not supported since open62541 v1.4")]]
208 [[deprecated(
"use ServerConfig::setAccessControl via config() or pass config to Server")]]
213 [[deprecated(
"use ServerConfig::setAccessControl via config() or pass config to Server")]]
218 [[deprecated(
"use ServerConfig::addCustomDataTypes via config() or pass config to Server")]]
227 [[deprecated(
"use sessions() instead")]]
236 [[deprecated(
"use namespaceArray() instead")]]
253#ifdef UA_ENABLE_SUBSCRIPTIONS
256 [[deprecated(
"use Subscription constructor")]]
260#ifdef UA_ENABLE_SUBSCRIPTIONS_EVENTS
262 [[deprecated(
"use Event constructor")]]
286 detail::ServerContext& context() noexcept;
287 const detail::ServerContext& context() const noexcept;
292 void operator()(
UA_Server* server)
noexcept;
295 std::unique_ptr<detail::ServerContext> context_;
296 std::unique_ptr<UA_Server, Deleter> server_;
306 return (lhs.handle() == rhs.handle());
311 return !(lhs == rhs);
Access control base class.
UA_ByteString wrapper class.
Data source base class for variable nodes.
Create and trigger events.
High-level node class to access node attribute, browse and populate address space.
void setAccessControl(std::unique_ptr< AccessControlBase > &&accessControl)
Set custom access control (transfer ownership to Server).
ServerConfig(uint16_t port, const ByteString &certificate={})
Create server config with minimal configuration.
void setApplicationName(std::string_view name)
Set application name, default: open62541-based OPC UA Application.
ServerConfig()
Create server config with default configuration.
void setLogger(LogFunction func)
void setAccessControl(AccessControlBase &accessControl)
Set custom access control.
ServerConfig & operator=(ServerConfig &&other) noexcept
ServerConfig(ServerConfig &&other) noexcept
ServerConfig(const ServerConfig &)=delete
ServerConfig & operator=(const ServerConfig &)=delete
void addCustomDataTypes(Span< const DataType > types)
Add custom data types.
ServerConfig(UA_ServerConfig &&native)
void setProductUri(std::string_view uri)
Set product URI, default: http://open62541.org.
void setBuildInfo(BuildInfo buildInfo)
void setApplicationUri(std::string_view uri)
Set application URI, default: urn:open62541.server.application.
ServerConfig(uint16_t port, const ByteString &certificate, const ByteString &privateKey, Span< const ByteString > trustList, Span< const ByteString > issuerList, Span< const ByteString > revocationList={})
Create server config with encryption enabled (PKI).
void setCustomDataTypes(Span< const DataType > dataTypes)
bool operator==(const Server &lhs, const Server &rhs) noexcept
Server(uint16_t port, const ByteString &certificate={})
Create server config with minimal configuration.
std::vector< Session > getSessions()
Node< Server > getNode(NodeId id)
Node< Server > getObjectsNode()
void setApplicationName(std::string_view name)
Server(UA_Server *native)
Create server from native instance (move ownership to server).
void setProductUri(std::string_view uri)
std::vector< std::string > namespaceArray()
Get all defined namespaces.
NamespaceIndex registerNamespace(std::string_view uri)
Register namespace. The new namespace index will be returned.
void setCustomHostname(std::string_view hostname)
Set custom hostname, default: system's host name.
void stop()
Stop the server's main loop.
void setVariableNodeDataSource(const NodeId &id, DataSourceBase &source)
Set data source for variable node.
Server(uint16_t port, const ByteString &certificate, const ByteString &privateKey, Span< const ByteString > trustList, Span< const ByteString > issuerList, Span< const ByteString > revocationList={})
Create server config with encryption enabled (PKI).
Server(Server &&other) noexcept
void run()
Run the server's main loop. This method will block until Server::stop is called.
uint16_t runIterate()
Run a single iteration of the server's main loop.
Node< Server > getRootNode()
Subscription< Server > createSubscription() noexcept
Create a (pseudo) subscription to monitor local data changes and events.
Node< Server > getViewsNode()
Server & operator=(const Server &)=delete
ServerConfig & config() noexcept
void setAccessControl(AccessControlBase &accessControl)
void setVariableNodeValueCallback(const NodeId &id, ValueCallbackBase &callback)
Set value callback for variable node.
std::vector< Session > sessions()
Get active sessions.
Event createEvent(const NodeId &eventType=ObjectTypeId::BaseEventType)
Create an event object to generate and trigger events.
Node< Server > getTypesNode()
void setApplicationUri(std::string_view uri)
Server & operator=(Server &&other) noexcept
Server(ServerConfig &&config)
Create server with given configuration (move ownership to server).
bool operator!=(const Server &lhs, const Server &rhs) noexcept
void setLogger(LogFunction logger)
void setAccessControl(std::unique_ptr< AccessControlBase > &&accessControl)
friend detail::ServerContext & detail::getContext(Server &server) noexcept
Server()
Create server with default configuration.
Server * asWrapper(UA_Server *server) noexcept
Convert native UA_Server pointer to its wrapper instance.
bool isRunning() const noexcept
Check if the server is running.
Server(const Server &)=delete
void setVariableNodeDataSource(const NodeId &id, std::unique_ptr< DataSourceBase > &&source)
Set data source for variable node (move ownership to server).
std::vector< std::string > getNamespaceArray()
void setVariableNodeValueCallback(const NodeId &id, std::unique_ptr< ValueCallbackBase > &&callback)
Set value callback for variable node (move ownership to server).
UA_Server * handle() noexcept
View to a contiguous sequence of objects, similar to std::span in C++20.
High-level subscription class.
Value callback base class for variable nodes.
Template base class to wrap native objects.
constexpr const UA_ServerConfig & native() const noexcept
UA_BuildInfo wrapper class.
uint16_t NamespaceIndex
Namespace index.
std::function< void(LogLevel, LogCategory, std::string_view msg)> LogFunction
Log function.