/* ========================================================================
* Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Opc.Ua.Server
{
///
/// The master node manager for the server.
///
public interface IMasterNodeManager
{
///
/// The node managers being managed.
///
IReadOnlyList AsyncNodeManagers { get; }
///
/// Returns the configuration node manager.
///
IConfigurationNodeManager? ConfigurationNodeManager { get; }
///
/// Returns the core node manager.
///
ICoreNodeManager? CoreNodeManager { get; }
///
/// Returns the diagnostics node manager.
///
IDiagnosticsNodeManager? DiagnosticsNodeManager { get; }
///
/// The node managers being managed.
///
IReadOnlyList NodeManagers { get; }
///
/// Adds the references to the target.
///
ValueTask AddReferencesAsync(NodeId sourceId, IList references, CancellationToken cancellationToken = default);
///
/// Dispatches AddNodes service requests (Part 4 §5.8.2) per item to the
/// node manager that owns the parent node.
///
///
/// For every item, the dispatcher resolves the parent NodeId and routes
/// the request to the owning .
/// When the owner has not opted into NodeManagement, the corresponding
/// result is .
///
ValueTask<(ArrayOf results, ArrayOf diagnosticInfos)> AddNodesAsync(
OperationContext context,
ArrayOf nodesToAdd,
CancellationToken cancellationToken = default);
///
/// Dispatches DeleteNodes service requests (Part 4 §5.8.4) per item to
/// the node manager that owns the node being deleted. When the item
/// requests target-reference removal, the dispatcher removes inverse
/// references in all other node managers that point at the deleted node.
///
ValueTask<(ArrayOf results, ArrayOf diagnosticInfos)> DeleteNodesAsync(
OperationContext context,
ArrayOf nodesToDelete,
CancellationToken cancellationToken = default);
///
/// Dispatches AddReferences service requests (Part 4 §5.8.3) per item.
///
///
/// Forward references are routed to the source node's owning manager.
/// When the target node is local, the inverse edge is also written into
/// the target's owning manager so Browse returns symmetric edges.
///
ValueTask<(ArrayOf results, ArrayOf diagnosticInfos)> AddReferencesAsync(
OperationContext context,
ArrayOf referencesToAdd,
CancellationToken cancellationToken = default);
///
/// Dispatches DeleteReferences service requests (Part 4 §5.8.5) per item.
///
ValueTask<(ArrayOf results, ArrayOf diagnosticInfos)> DeleteReferencesAsync(
OperationContext context,
ArrayOf referencesToDelete,
CancellationToken cancellationToken = default);
///
/// Returns the set of references that meet the filter criteria.
///
/// is null.
///
ValueTask<(ArrayOf results, ArrayOf diagnosticInfos)> BrowseAsync(
OperationContext context,
ViewDescription view,
uint maxReferencesPerNode,
ArrayOf nodesToBrowse,
CancellationToken cancellationToken = default);
///
/// Continues a browse operation that was previously halted.
///
/// is null.
///
ValueTask<(ArrayOf results, ArrayOf diagnosticInfos)> BrowseNextAsync(
OperationContext context,
bool releaseContinuationPoints,
ArrayOf continuationPoints,
CancellationToken cancellationToken = default);
///
/// Calls a method defined on an object.
///
///
/// is null.
ValueTask<(ArrayOf results, ArrayOf diagnosticInfos)> CallAsync(
OperationContext context,
ArrayOf methodsToCall,
CancellationToken cancellationToken = default);
///
/// Handles condition refresh request.
///
ValueTask ConditionRefreshAsync(OperationContext context, IList monitoredItems, CancellationToken cancellationToken = default);
///
/// Creates a set of monitored items.
///
/// is null.
///
///
ValueTask CreateMonitoredItemsAsync(
OperationContext context,
uint subscriptionId,
double publishingInterval,
TimestampsToReturn timestampsToReturn,
ArrayOf itemsToCreate,
IList errors,
IList filterResults,
IList monitoredItems,
bool createDurable,
CancellationToken cancellationToken = default);
///
/// Deletes a set of monitored items.
///
/// is null.
ValueTask DeleteMonitoredItemsAsync(
OperationContext context,
uint subscriptionId,
IList itemsToDelete,
IList errors,
CancellationToken cancellationToken = default);
///
/// Deletes the references to the target.
///
ValueTask DeleteReferencesAsync(NodeId targetId, IList references, CancellationToken cancellationToken = default);
///
/// Searches the node id in all node managers,
/// returns the node state if found (and node Manager supports it), otherwise returns null.
///
ValueTask FindNodeInAddressSpaceAsync(NodeId nodeId, CancellationToken cancellationToken = default);
///
/// Returns node handle and its node manager.
///
[Obsolete("Use GetManagerHandleAsync instead.")]
object? GetManagerHandle(NodeId nodeId, out IAsyncNodeManager? nodeManager);
///
/// Returns node handle and its node manager.
///
object? GetManagerHandle(NodeId nodeId, out INodeManager? nodeManager);
///
/// Returns node handle and its node manager.
///
ValueTask<(object? handle, IAsyncNodeManager? nodeManager)> GetManagerHandleAsync(NodeId nodeId, CancellationToken cancellationToken = default);
///
/// Reads the history of a set of items.
///
///
ValueTask<(ArrayOf values, ArrayOf diagnosticInfos)> HistoryReadAsync(
OperationContext context,
ExtensionObject historyReadDetails,
TimestampsToReturn timestampsToReturn,
bool releaseContinuationPoints,
ArrayOf nodesToRead,
CancellationToken cancellationToken = default);
///
/// Updates the history for a set of nodes.
///
ValueTask<(ArrayOf results, ArrayOf diagnosticInfos)> HistoryUpdateAsync(
OperationContext context,
ArrayOf historyUpdateDetails,
CancellationToken cancellationToken = default);
///
/// Modifies a set of monitored items.
///
/// is null.
///
ValueTask ModifyMonitoredItemsAsync(
OperationContext context,
TimestampsToReturn timestampsToReturn,
IList monitoredItems,
ArrayOf itemsToModify,
IList errors,
IList filterResults,
CancellationToken cancellationToken = default);
///
/// Reads a set of nodes.
///
/// is null.
///
ValueTask<(ArrayOf values, ArrayOf diagnosticInfos)> ReadAsync(
OperationContext context,
double maxAge,
TimestampsToReturn timestampsToReturn,
ArrayOf nodesToRead,
CancellationToken cancellationToken = default);
///
/// Registers the node manager as the node manager for Nodes in the specified namespace.
///
/// The URI of the namespace.
/// The NodeManager which owns node in the namespace.
///
///
/// Multiple NodeManagers may register interest in a Namespace.
/// The order in which this method is called determines the precedence if multiple NodeManagers exist.
/// This method adds the namespaceUri to the Server's Namespace table if it does not already exist.
///
/// This method is thread safe and can be called at anytime.
///
/// This method does not have to be called for any namespaces that were in the NodeManager's
/// NamespaceUri property when the MasterNodeManager was created.
///
///
/// Throw if the namespaceUri or the nodeManager are null.
void RegisterNamespaceManager(string namespaceUri, IAsyncNodeManager nodeManager);
///
/// Registers the node manager as the node manager for Nodes in the specified namespace.
///
/// The URI of the namespace.
/// The NodeManager which owns node in the namespace.
///
///
/// Multiple NodeManagers may register interest in a Namespace.
/// The order in which this method is called determines the precedence if multiple NodeManagers exist.
/// This method adds the namespaceUri to the Server's Namespace table if it does not already exist.
///
/// This method is thread safe and can be called at anytime.
///
/// This method does not have to be called for any namespaces that were in the NodeManager's
/// NamespaceUri property when the MasterNodeManager was created.
///
///
/// Throw if the namespaceUri or the nodeManager are null.
void RegisterNamespaceManager(string namespaceUri, INodeManager nodeManager);
///
/// Registers a set of node ids.
///
/// is null.
void RegisterNodes(OperationContext context, ArrayOf nodesToRegister, out ArrayOf registeredNodeIds);
///
/// Deletes the specified references.
///
[Obsolete("Use RemoveReferencesAsync instead.")]
void RemoveReferences(List referencesToRemove);
///
/// Deletes the specified references.
///
ValueTask RemoveReferencesAsync(List referencesToRemove, CancellationToken cancellationToken = default);
///
/// Restore a set of monitored items after a Server Restart.
///
/// is null.
///
ValueTask RestoreMonitoredItemsAsync(
IList itemsToRestore,
IList monitoredItems,
IUserIdentity savedOwnerIdentity,
CancellationToken cancellationToken = default);
///
/// Signals that a session is closing.
///
ValueTask SessionClosingAsync(OperationContext context, NodeId sessionId, bool deleteSubscriptions, CancellationToken cancellationToken = default);
///
/// Signals that a session has been activated with a changed user identity.
///
ValueTask SessionActivatedAsync(OperationContext context, NodeId sessionId, CancellationToken cancellationToken = default);
///
/// Changes the monitoring mode for a set of items.
///
/// is null.
ValueTask SetMonitoringModeAsync(
OperationContext context,
MonitoringMode monitoringMode,
IList itemsToModify,
IList errors,
CancellationToken cancellationToken = default);
///
/// Shuts down the node managers.
///
ValueTask ShutdownAsync(CancellationToken cancellationToken = default);
///
/// Creates the node managers and start them
///
ValueTask StartupAsync(CancellationToken cancellationToken = default);
///
/// Transfers a set of monitored items.
///
/// is null.
ValueTask TransferMonitoredItemsAsync(
OperationContext context,
bool sendInitialValues,
IList monitoredItems,
IList errors,
CancellationToken cancellationToken = default);
///
/// Translates a start node id plus a relative paths into a node id.
///
/// is null.
///
ValueTask<(ArrayOf results, ArrayOf diagnosticInfos)> TranslateBrowsePathsToNodeIdsAsync(
OperationContext context,
ArrayOf browsePaths,
CancellationToken cancellationToken = default);
///
/// Unregisters the node manager as the node manager for Nodes in the specified namespace.
///
/// The URI of the namespace.
/// The NodeManager which no longer owns nodes in the namespace.
/// A value indicating whether the node manager was successfully unregistered.
/// Throw if the namespaceUri or the nodeManager are null.
bool UnregisterNamespaceManager(string namespaceUri, IAsyncNodeManager nodeManager);
///
/// Unregisters the node manager as the node manager for Nodes in the specified namespace.
///
/// The URI of the namespace.
/// The NodeManager which no longer owns nodes in the namespace.
/// A value indicating whether the node manager was successfully unregistered.
/// Throw if the namespaceUri or the nodeManager are null.
bool UnregisterNamespaceManager(string namespaceUri, INodeManager nodeManager);
///
/// Unregisters a set of node ids.
///
/// is null.
void UnregisterNodes(OperationContext context, ArrayOf nodesToUnregister);
///
/// Writes a set of values.
///
/// is null.
ValueTask<(ArrayOf results, ArrayOf diagnosticInfos)> WriteAsync(
OperationContext context,
ArrayOf nodesToWrite,
CancellationToken cancellationToken = default);
}
}