UA Server SDK C++ Bundle  1.4.1.271
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BrowseContext Class Reference

This class provides all browse settings and the continuation point handling. More...

#include <continuationpoint.h>

Public Member Functions

 BrowseContext (OpcUa_ViewDescription *pView, OpcUa_NodeId *pNodeToBrowse, OpcUa_UInt32 uMaxResultsToReturn, OpcUa_BrowseDirection BrowseDirection, OpcUa_NodeId *pReferenceTypeId, OpcUa_Boolean bIncludeSubtype, OpcUa_UInt32 uNodeClassMask, OpcUa_UInt32 uResultMask)
 Creates a BrowseContext object initialized with the browse parameters passed in. More...
 
virtual ~BrowseContext ()
 Destroys the BrowseContext object.
 
void setUserData (ContinuationPointUserDataBase *pContinuationPointUserDataBase)
 Set user data to prepare a Continuation Point for the next browse if not all nodes can be returned. More...
 
ContinuationPointUserDataBasedetachUserData ()
 Detach user data to continue browse. More...
 
OpcUa_ViewDescription * pView () const
 Returns the OPC UA View context for the browse. More...
 
OpcUa_NodeId * pNodeToBrowse () const
 Returns the node id of the node to browse.
 
OpcUa_UInt32 uMaxResultsToReturn () const
 Returns the maximum number of browse results to return. More...
 
void setMaxResultsToReturn (OpcUa_UInt32 uMaxResultsToReturn)
 Allows setting of the maximum number of results to return.
 
OpcUa_BrowseDirection BrowseDirection () const
 Returns the browse direction for the browse call. More...
 
OpcUa_NodeId * pReferenceTypeId () const
 Returns the node id of the requested reference type or its subtypes if bIncludeSubtype is set. More...
 
OpcUa_Boolean bIncludeSubtype () const
 Returns the flag indicating whether subtypes of the requested reference type should be included in the browse result. More...
 
OpcUa_UInt32 uNodeClassMask () const
 Returns the node class filter mask identifying the node classes to include in the browse result. More...
 
OpcUa_UInt32 uResultMask () const
 Returns the result filter mask identifing the information returned for each node in the browse result. More...
 
void setResultMask (OpcUa_UInt32 uResultMask)
 Allows setting of the result mask.
 
OpcUa_Boolean isFirstBrowse () const
 Can be used to check whether it is the first browse with this context. More...
 
OpcUa_Boolean isLastBrowse () const
 Flag that tells the SDK whether it was the last browse call and all references are returned. More...
 
OpcUa_UInt32 nodeToBrowseCount () const
 Returns the total number of nodes to browse in the Browse service. More...
 
OpcUa_UInt32 nodeToBrowseIndex () const
 Returns the index of this node in the nodes to browse array in the Browse service call. More...
 

Detailed Description

This class provides all browse settings and the continuation point handling.

The class provides all settings for a browse call, like node to browse and the browse filter settings. It also keeps the settings and the continuation point user data if not all results can be returned in a single browse result. The same object is provided in a second browse call triggered through a BrowseNext service call. In this case, the continuation point is provided in addition to the browse settings.

If the number of browse results exeeds the uMaxResultsToReturn or a server internal limit, a continuation point is necessary and setUserData is used to store the implementation specific continuation point user data.

The following code provides an example for the functions setUserData and uMaxResultsToReturn

// Check whether we need to create a continuation point and stop browsing
if ( browseCount >= browseContext.uMaxResultsToReturn() )
{
// Create continuation point object for browse context
CPNodeManagerTree* pCP = new CPNodeManagerTree;
// Set continuation point data for next browse
pCP->m_nextChild = i+1;
// Assign continuation point to browse context
browseContext.setUserData(pCP);
break;
}

The following code provides an example for a continuation point user data class

class CPNodeManagerTree : public ContinuationPointUserDataBase
{
UA_DISABLE_COPY(CPNodeManagerTree);
public:
CPNodeManagerTree() : m_nextChild(0){}
virtual ~CPNodeManagerTree(){}
OpcUa_UInt32 m_nextChild;
};

isFirstBrowse is used to check whether it is a first browse or a browse next.

detachUserData is used to get the stored continuation point data.

The following code provides an example for the functions isFirstBrowse and detachUserData

// Check whether we have a continuation point from OPC UA browse
if ( browseContext.isFirstBrowse() == OpcUa_False )
{
CPNodeManagerTree* pCP = (CPNodeManagerTree*)browseContext.detachUserData();
if ( pCP )
{
startingChild = pCP->m_nextChild;
delete pCP;
}
}

The SDK handles the release of continuation point data if BrowseNext is not called or just called to release the continuation point.

Constructor & Destructor Documentation

BrowseContext::BrowseContext ( OpcUa_ViewDescription *  pView,
OpcUa_NodeId *  pNodeToBrowse,
OpcUa_UInt32  uMaxResultsToReturn,
OpcUa_BrowseDirection  BrowseDirection,
OpcUa_NodeId *  pReferenceTypeId,
OpcUa_Boolean  bIncludeSubtype,
OpcUa_UInt32  uNodeClassMask,
OpcUa_UInt32  uResultMask 
)

Creates a BrowseContext object initialized with the browse parameters passed in.

Parameters
pViewThe View context used for the browse.
pNodeToBrowseThe actual Node to browse.
uMaxResultsToReturnThe maximum number of results to return.
BrowseDirectionDirection of the browse from the node to browse (Inverse/Forward/Both).
pReferenceTypeIdNodeId of the reference type to follow.
bIncludeSubtypeFlag indicating whether subtypes of the reference type should be returned.
uNodeClassMaskThe node class mask used as filter.
uResultMaskThe result mask used to filter the requested data returned for a result.

Member Function Documentation

OpcUa_Boolean BrowseContext::bIncludeSubtype ( ) const
inline

Returns the flag indicating whether subtypes of the requested reference type should be included in the browse result.

See Also
pReferenceTypeId
OpcUa_BrowseDirection BrowseContext::BrowseDirection ( ) const
inline

Returns the browse direction for the browse call.

Options are:

  • OpcUa_BrowseDirection_Forward
  • OpcUa_BrowseDirection_Inverse
  • OpcUa_BrowseDirection_Both
ContinuationPointUserDataBase * BrowseContext::detachUserData ( )

Detach user data to continue browse.

The user of the SDK is responsible to delete the user data after detach is called.

Returns
a pointer to the continuation point user data base.
OpcUa_Boolean BrowseContext::isFirstBrowse ( ) const
inline

Can be used to check whether it is the first browse with this context.

In the case of OpcUa_True, it is the first browse call with this browse context. In the case of OpcUa_False, it is a browse next call with a continuation point.

Returns
a Boolean value to check whether this was the first browse with the current context.
OpcUa_Boolean BrowseContext::isLastBrowse ( ) const
inline

Flag that tells the SDK whether it was the last browse call and all references are returned.

The flag is set by setUserData (OpcUa_False) since this indicates that a continuation point is necessary, or by detachUserData (OpcUa_True) since the continuation point is handled in a next browse. The default value is OpcUa_True.

Returns
a value used to recognize whether this was the last browse call or not.
OpcUa_UInt32 BrowseContext::nodeToBrowseCount ( ) const
inline

Returns the total number of nodes to browse in the Browse service.

This BrowseContext represents only one of the nodes to browse in the Browse request. This information can be used together with the nodeToBrowseIndex() and the receiveTime and timeoutHint in the ServiceContext to decide whether the current node can still be processed or the browse for the node should be skipped and BadNoContinuationPoints returned for the remaining nodes. It would also be possible to return continuation points and an empty result list for the remaining nodes if the number is below the number of continuation points supported per session.

OpcUa_UInt32 BrowseContext::nodeToBrowseIndex ( ) const
inline

Returns the index of this node in the nodes to browse array in the Browse service call.

This BrowseContext represents only one of the nodes to browse in the Browse request. This information can be used together with the nodeToBrowseCount() and the receiveTime and timeoutHint in the ServiceContext to decide whether the current node can still be processed or the browse for the node should be skipped and BadNoContinuationPoints returned for the remaining nodes. It would also be possible to return continuation points and an empty result list for the remaining nodes if the number is below the number of continuation points supported per session.

OpcUa_NodeId* BrowseContext::pReferenceTypeId ( ) const
inline

Returns the node id of the requested reference type or its subtypes if bIncludeSubtype is set.

See Also
bIncludeSubtype
OpcUa_ViewDescription* BrowseContext::pView ( ) const
inline

Returns the OPC UA View context for the browse.

If the view is not set, the whole address space is browsed.

void BrowseContext::setUserData ( ContinuationPointUserDataBase pContinuationPointUserDataBase)

Set user data to prepare a Continuation Point for the next browse if not all nodes can be returned.

The data handling class must be derived from ContinuationPointUserDataBase. The SDK handles the release of continuation point data if BrowseNext is not called or just called to release the continuation point.

See Also
detachUserData to get the continuation point user data in a later browse call with continuation point.
Parameters
pContinuationPointUserDataBaseUser data for the continuation point. BrowseContext takes ownership of the passed object.
OpcUa_UInt32 BrowseContext::uMaxResultsToReturn ( ) const
inline

Returns the maximum number of browse results to return.

If the maximum is exceeded, a continuation point needs to be created.

See Also
setUserData
OpcUa_UInt32 BrowseContext::uNodeClassMask ( ) const
inline

Returns the node class filter mask identifying the node classes to include in the browse result.

Bit mask containing the following options:

Define Value
OpcUa_NodeClass_Object 1
OpcUa_NodeClass_Variable 2
OpcUa_NodeClass_Method 4
OpcUa_NodeClass_ObjectType 8
OpcUa_NodeClass_VariableType 16
OpcUa_NodeClass_ReferenceType 32
OpcUa_NodeClass_DataType 64
OpcUa_NodeClass_View 128

If set to zero, all node classes are returned.

OpcUa_UInt32 BrowseContext::uResultMask ( ) const
inline

Returns the result filter mask identifing the information returned for each node in the browse result.

Bit mask containing the following options:

Define Value
OpcUa_BrowseResultMask_None 0
OpcUa_BrowseResultMask_ReferenceTypeId 1
OpcUa_BrowseResultMask_IsForward 2
OpcUa_BrowseResultMask_NodeClass 4
OpcUa_BrowseResultMask_BrowseName 8
OpcUa_BrowseResultMask_DisplayName 16
OpcUa_BrowseResultMask_TypeDefinition 32

The documentation for this class was generated from the following files: