open62541_nodestore.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef UA_OPEN62541_NODESTORE_H_
  2. #define UA_OPEN62541_NODESTORE_H_
  3. #include "ua_server.h"
  4. #include "ua_config.h"
  5. /**
  6. @ingroup server
  7. @defgroup nodestore NodeStore
  8. @brief The nodestore is the central storage for nodes in the UA address
  9. space. Internally, the nodestore is realised as hash-map where nodes are
  10. stored and retrieved with their nodeid.
  11. The nodes in the nodestore are immutable. To change the content of a node, it
  12. needs to be replaced as a whole. When a node is inserted into the namespace,
  13. it gets replaced with a pointer to a managed node. Managed nodes shall never
  14. be freed by the user. This is done by the namespace when the node is removed
  15. and no readers (in other threads) access the node.
  16. @{
  17. */
  18. void UA_EXPORT open62541NodeStore_setNodeStore(open62541NodeStore *nodestore);
  19. open62541NodeStore UA_EXPORT *open62541NodeStore_getNodeStore();
  20. /** @brief Create a new namespace */
  21. UA_StatusCode UA_EXPORT open62541NodeStore_new(open62541NodeStore **result);
  22. /** @brief Delete the namespace and all nodes in it */
  23. void open62541NodeStore_delete(open62541NodeStore *ns);
  24. #define UA_NODESTORE_INSERT_UNIQUE 1
  25. #define UA_NODESTORE_INSERT_GETMANAGED 2
  26. /** @brief Insert a new node into the namespace
  27. With the UNIQUE flag, the node is only inserted if the nodeid does not
  28. already exist. With the GETMANAGED flag, the node pointer is replaced with
  29. the managed pointer. Otherwise, it is set to UA_NULL. */
  30. UA_StatusCode open62541NodeStore_insert(open62541NodeStore *ns, UA_Node **node,
  31. UA_Byte flags);
  32. /** @brief Remove a node from the namespace. Always succeeds, even if the node
  33. was not found. */
  34. UA_StatusCode open62541NodeStore_remove(open62541NodeStore *ns,
  35. const UA_NodeId *nodeid);
  36. /** @brief Retrieve a node (read-only) from the namespace. Nodes are immutable.
  37. They can only be replaced. After the Node is no longer used, the locked
  38. entry needs to be released. */
  39. UA_StatusCode open62541NodeStore_get(const open62541NodeStore *ns,
  40. const UA_NodeId *nodeid, const UA_Node **managedNode);
  41. /** @brief Release a managed node. Do never insert a node that isn't stored in a
  42. namespace. */
  43. void open62541NodeStore_releaseManagedNode(const UA_Node *managed);
  44. /** @brief A function that can be evaluated on all entries in a namespace via
  45. UA_NodeStore_iterate. Note that the visitor is read-only on the nodes. */
  46. typedef void (*UA_NodeStore_nodeVisitor)(const UA_Node *node);
  47. /** @brief Iterate over all nodes in a namespace. */
  48. void open62541NodeStore_iterate(const open62541NodeStore *ns,
  49. UA_NodeStore_nodeVisitor visitor);
  50. /// @} /* end of group */
  51. //service implementations
  52. UA_Int32 UA_EXPORT open62541NodeStore_ReadNodes(const UA_RequestHeader *requestHeader,
  53. UA_ReadValueId *readValueIds,
  54. UA_UInt32 *indices, UA_UInt32 indicesSize,
  55. UA_DataValue *readNodesResults, UA_Boolean timeStampToReturn,
  56. UA_DiagnosticInfo *diagnosticInfos);
  57. UA_Int32 UA_EXPORT open62541NodeStore_WriteNodes(const UA_RequestHeader *requestHeader,
  58. UA_WriteValue *writeValues,
  59. UA_UInt32 *indices, UA_UInt32 indicesSize,
  60. UA_StatusCode *writeNodesResults, UA_DiagnosticInfo *diagnosticInfo);
  61. UA_Int32 UA_EXPORT open62541NodeStore_BrowseNodes(const UA_RequestHeader *requestHeader,
  62. UA_BrowseDescription *browseDescriptions, UA_UInt32 *indices,
  63. UA_UInt32 indicesSize, UA_UInt32 requestedMaxReferencesPerNode,
  64. UA_BrowseResult *browseResults, UA_DiagnosticInfo *diagnosticInfos);
  65. UA_Int32 UA_EXPORT open62541NodeStore_AddNodes(const UA_RequestHeader *requestHeader,
  66. UA_AddNodesItem *nodesToAdd,
  67. UA_UInt32 *indices, UA_UInt32 indicesSize,
  68. UA_AddNodesResult* addNodesResults, UA_DiagnosticInfo *diagnosticInfos);
  69. UA_Int32 UA_EXPORT open62541NodeStore_AddReferences(const UA_RequestHeader *requestHeader, UA_AddReferencesItem* referencesToAdd,
  70. UA_UInt32 *indices,UA_UInt32 indicesSize, UA_StatusCode *addReferencesResults,
  71. UA_DiagnosticInfo *diagnosticInfos);
  72. #endif /* UA_OPEN62541_NODESTORE_H_ */