ua_namespace.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef UA_NAMESPACE_H_
  2. #define UA_NAMESPACE_H_
  3. #include "ua_types.h"
  4. #include "ua_types_generated.h"
  5. /**
  6. @ingroup server
  7. @defgroup namespace Namespace
  8. @brief The namespace is the central storage for nodes in the UA address
  9. space. Internally, the namespace is realised as hash-map where nodes are
  10. stored and retrieved with their nodeid.
  11. The nodes in the namespace 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. /** @brief UA_Namespace datastructure. Mainly a hashmap to UA_Nodes */
  19. struct UA_Namespace;
  20. typedef struct UA_Namespace UA_Namespace;
  21. /** @brief Create a new namespace */
  22. UA_Int32 UA_Namespace_new(UA_Namespace **result);
  23. /** @brief Delete the namespace and all nodes in it */
  24. UA_Int32 UA_Namespace_delete(UA_Namespace *ns);
  25. #define UA_NAMESPACE_INSERT_UNIQUE 1
  26. #define UA_NAMESPACE_INSERT_GETMANAGED 2
  27. /** @brief Insert a new node into the namespace
  28. With the UNIQUE flag, the node is only inserted if the nodeid does not
  29. already exist. With the GETMANAGED flag, the node pointer is replaced with
  30. the managed pointer. Otherwise, it is set to UA_NULL. */
  31. UA_Int32 UA_Namespace_insert(UA_Namespace *ns, UA_Node **node, UA_Byte flags);
  32. /** @brief Remove a node from the namespace. Always succeeds, even if the node
  33. was not found. */
  34. UA_Int32 UA_Namespace_remove(UA_Namespace *ns, const UA_NodeId *nodeid);
  35. /** @brief Retrieve a node (read-only) from the namespace. Nodes are immutable.
  36. They can only be replaced. After the Node is no longer used, the locked
  37. entry needs to be released. */
  38. UA_Int32 UA_Namespace_get(const UA_Namespace *ns, const UA_NodeId *nodeid,
  39. const UA_Node **managedNode);
  40. /** @brief Release a managed node. Do never insert a node that isn't stored in a
  41. namespace. */
  42. void UA_Namespace_releaseManagedNode(const UA_Node *managed);
  43. /** @brief A function that can be evaluated on all entries in a namespace via
  44. UA_Namespace_iterate. Note that the visitor is read-only on the nodes. */
  45. typedef void (*UA_Namespace_nodeVisitor)(const UA_Node *node);
  46. /** @brief Iterate over all nodes in a namespace. */
  47. UA_Int32 UA_Namespace_iterate(const UA_Namespace *ns, UA_Namespace_nodeVisitor visitor);
  48. /// @} /* end of group */
  49. #endif /* UA_NAMESPACE_H_ */