/* ========================================================================
* 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/
* ======================================================================*/
namespace Opc.Ua.Server.Fluent
{
///
/// Per-node fluent surface returned by
/// . All On*
/// methods return the same builder so calls can be chained.
///
///
///
/// Variable-only callbacks (e.g. OnRead) and method-only
/// callbacks (e.g. OnCall) throw
/// with
/// when invoked on a node
/// of an incompatible class. Use to obtain a
/// strongly-typed view that surfaces the right callbacks at compile
/// time.
///
///
/// All callbacks replace any previously assigned handler on the
/// underlying ; they do not add to a list.
/// Wiring the same node twice with the same callback category is an
/// error and throws.
///
///
public interface INodeBuilder : INodeStateBuilder
{
///
/// The resolved . Exposed so callers can
/// reach attributes that are not surfaced by the builder (for
/// example, setting UserAccessLevel programmatically).
///
new NodeState Node { get; }
///
/// The owning builder. Useful when you want to terminate a chain
/// and resolve another node without storing the parent reference.
///
INodeManagerBuilder Builder { get; }
///
/// Returns a strongly-typed view of the same node. Throws if the
/// resolved node is not assignable to .
///
/// The expected node state type.
///
/// The resolved node is not assignable to .
///
INodeBuilder As() where TState : NodeState;
///
/// Wires .
///
INodeBuilder OnRead(NodeValueEventHandler handler);
///
/// Wires .
///
INodeBuilder OnRead(NodeValueSimpleEventHandler handler);
///
/// Wires .
///
INodeBuilder OnWrite(NodeValueEventHandler handler);
///
/// Wires .
///
INodeBuilder OnWrite(NodeValueSimpleEventHandler handler);
///
/// Wires . Use this
/// overload when the read source performs I/O — the handler runs
/// without holding lock(this), so the call can await
/// freely.
///
INodeBuilder OnRead(NodeValueEventHandlerAsync handler);
///
/// Wires .
/// The framework still applies index-range / data-encoding /
/// copy-policy post-processing to the returned value.
///
INodeBuilder OnRead(NodeValueSimpleEventHandlerAsync handler);
///
/// Wires .
///
INodeBuilder OnWrite(NodeValueWriteEventHandlerAsync handler);
///
/// Wires .
///
INodeBuilder OnWrite(NodeValueSimpleWriteEventHandlerAsync handler);
///
/// Wires .
///
INodeBuilder OnCall(GenericMethodCalledEventHandler2 handler);
///
/// Wires .
///
INodeBuilder OnCall(GenericMethodCalledEventHandler2Async handler);
///
/// Invoked exactly once after the node has been added to the
/// address space and all sibling builder wiring has been applied.
///
INodeBuilder OnNodeAdded(NodeLifecycleHandler handler);
///
/// Invoked when the node manager removes the node from the address
/// space (including manager dispose).
///
INodeBuilder OnNodeRemoved(NodeLifecycleHandler handler);
///
/// Routes CustomNodeManager2.HistoryRead requests targeting
/// the resolved node to .
///
INodeBuilder OnHistoryRead(HistoryReadHandler handler);
///
/// Routes CustomNodeManager2.HistoryUpdate requests targeting
/// the resolved node to .
///
INodeBuilder OnHistoryUpdate(HistoryUpdateHandler handler);
///
/// Routes CustomNodeManager2.ConditionRefresh invocations
/// whose monitored item targets the resolved node to
/// .
///
INodeBuilder OnConditionRefresh(ConditionRefreshHandler handler);
///
/// Invoked once a monitored item has been successfully created for
/// the resolved source node. Useful for attaching push-style
/// sampling sources.
///
INodeBuilder OnMonitoredItemCreated(MonitoredItemCreatedHandler handler);
///
/// Wires the resolved node's
/// hook to forward events to .
///
INodeBuilder OnEvent(EventNotificationHandler handler);
///
/// Opts the resolved node into (or out of) dynamic scaling of event
/// consumer tasks. When enabled, the
/// for this node scales consumer tasks with the number of event
/// monitored items, improving throughput under high event loads.
/// The Server node () is always
/// auto-opted-in regardless of this call.
///
///
/// true to opt in (default); false to opt out.
///
INodeBuilder AllowMultipleEventConsumers(bool enable = true);
///
/// Resolves a child of the current node by browse name. Used by
/// source-generated typed traversal wrappers to walk one segment
/// at a time without re-resolving from the root.
///
/// Browse name of the immediate child.
///
/// Thrown when the child cannot be found.
///
new INodeBuilder Child(QualifiedName browseName);
///
/// Strongly-typed sibling of .
///
///
/// CLR type the resolved child must be
/// assignable to.
///
new INodeBuilder Child(QualifiedName browseName)
where TState : NodeState;
///
/// Resolves a variable child of the current node and returns a
/// typed view.
///
///
/// CLR type carried by the child variable's Value attribute.
///
/// Browse name of the immediate child.
///
/// Thrown when the child cannot be found, or when it is not a
/// .
///
IVariableBuilder Variable(QualifiedName browseName);
}
///
/// Strongly-typed view of that narrows the
/// property to . All
/// inherited On* methods continue to return the non-generic
/// builder; use chaining when
/// you need to restore the typed view.
///
///
/// The concrete derivative the resolved node
/// is narrowed to.
///
public interface INodeBuilder : INodeBuilder, INodeStateBuilder
where TState : NodeState
{
///
/// The resolved node, narrowed to .
///
new TState Node { get; }
}
}