ua_nodestore.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef UA_NODESTORE_H_
  2. #define UA_NODESTORE_H_
  3. #include "ua_server.h"
  4. /**
  5. @ingroup server
  6. @defgroup nodestore NodeStore
  7. @brief The nodestore is the central storage for nodes in the UA address
  8. space. Internally, the nodestore is realised as hash-map where nodes are
  9. stored and retrieved with their nodeid.
  10. The nodes in the nodestore are immutable. To change the content of a node, it
  11. needs to be replaced as a whole. When a node is inserted into the namespace,
  12. it gets replaced with a pointer to a managed node. Managed nodes shall never
  13. be freed by the user. This is done by the namespace when the node is removed
  14. and no readers (in other threads) access the node.
  15. @{
  16. */
  17. /** @brief Create a new namespace */
  18. UA_StatusCode UA_NodeStore_new(UA_NodeStore **result);
  19. /** @brief Delete the namespace and all nodes in it */
  20. void UA_NodeStore_delete(UA_NodeStore *ns);
  21. #define UA_NODESTORE_INSERT_UNIQUE 1
  22. #define UA_NODESTORE_INSERT_GETMANAGED 2
  23. /** @brief Insert a new node into the namespace
  24. With the UNIQUE flag, the node is only inserted if the nodeid does not
  25. already exist. With the GETMANAGED flag, the node pointer is replaced with
  26. the managed pointer. Otherwise, it is set to UA_NULL. */
  27. UA_StatusCode UA_NodeStore_insert(UA_NodeStore *ns, UA_Node **node, UA_Byte flags);
  28. /** @brief Remove a node from the namespace. Always succeeds, even if the node
  29. was not found. */
  30. UA_StatusCode UA_NodeStore_remove(UA_NodeStore *ns, const UA_NodeId *nodeid);
  31. /** @brief Retrieve a node (read-only) from the namespace. Nodes are immutable.
  32. They can only be replaced. After the Node is no longer used, the locked
  33. entry needs to be released. */
  34. UA_StatusCode UA_NodeStore_get(const UA_NodeStore *ns, const UA_NodeId *nodeid,
  35. const UA_Node **managedNode);
  36. /** @brief Release a managed node. Do never insert a node that isn't stored in a
  37. namespace. */
  38. void UA_NodeStore_release(const UA_Node *managed);
  39. /** @brief A function that can be evaluated on all entries in a namespace via
  40. UA_NodeStore_iterate. Note that the visitor is read-only on the nodes. */
  41. typedef void (*UA_NodeStore_nodeVisitor)(const UA_Node *node);
  42. /** @brief Iterate over all nodes in a namespace. */
  43. void UA_NodeStore_iterate(const UA_NodeStore *ns, UA_NodeStore_nodeVisitor visitor);
  44. /// @} /* end of group */
  45. #endif /* UA_NODESTORE_H_ */