ua_nodestore.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef UA_NODESTORE_H_
  2. #define UA_NODESTORE_H_
  3. #include "ua_types_generated.h"
  4. #include "ua_nodes.h"
  5. /**
  6. * Stores the nodes in the address space. Internally, it is based on a hash-map
  7. * that maps nodes to their nodeid.
  8. */
  9. struct UA_NodeStore;
  10. typedef struct UA_NodeStore UA_NodeStore;
  11. /** Create a new nodestore */
  12. UA_NodeStore * UA_NodeStore_new(void);
  13. /** Delete the nodestore and all nodes in it. Do not call from a read-side
  14. critical section (multithreading). */
  15. void UA_NodeStore_delete(UA_NodeStore *ns);
  16. /** Create an editable node of the given NodeClass. */
  17. UA_Node * UA_NodeStore_newNode(UA_NodeClass class);
  18. #define UA_NodeStore_newObjectNode() (UA_ObjectNode*)UA_NodeStore_newNode(UA_NODECLASS_OBJECT)
  19. #define UA_NodeStore_newVariableNode() (UA_VariableNode*)UA_NodeStore_newNode(UA_NODECLASS_VARIABLE)
  20. #define UA_NodeStore_newMethodNode() (UA_MethodNode*)UA_NodeStore_newNode(UA_NODECLASS_METHOD)
  21. #define UA_NodeStore_newObjectTypeNode() (UA_ObjectTypeNode*)UA_NodeStore_newNode(UA_NODECLASS_OBJECTTYPE)
  22. #define UA_NodeStore_newVariableTypeNode() (UA_VariableTypeNode*)UA_NodeStore_newNode(UA_NODECLASS_VARIABLETYPE)
  23. #define UA_NodeStore_newReferenceTypeNode() (UA_ReferenceTypeNode*)UA_NodeStore_newNode(UA_NODECLASS_REFERENCETYPE)
  24. #define UA_NodeStore_newDataTypeNode() (UA_DataTypeNode*)UA_NodeStore_newNode(UA_NODECLASS_DATATYPE)
  25. #define UA_NodeStore_newViewNode() (UA_ViewNode*)UA_NodeStore_newNode(UA_NODECLASS_VIEW)
  26. /** Delete an editable node. */
  27. void UA_NodeStore_deleteNode(UA_Node *node);
  28. /**
  29. * Inserts a new node into the nodestore. If the nodeid is zero, then a fresh
  30. * numeric nodeid from namespace 1 is assigned. If insertion fails, the node is
  31. * deleted.
  32. */
  33. UA_StatusCode UA_NodeStore_insert(UA_NodeStore *ns, UA_Node *node);
  34. /**
  35. * To replace, get an editable copy, edit and use this function. If the node was
  36. * already replaced since the copy was made, UA_STATUSCODE_BADINTERNALERROR is
  37. * returned. If the nodeid is not found, UA_STATUSCODE_BADNODEIDUNKNOWN is
  38. * returned. In both error cases, the editable node is deleted.
  39. */
  40. UA_StatusCode UA_NodeStore_replace(UA_NodeStore *ns, UA_Node *node);
  41. /** Remove a node in the nodestore. */
  42. UA_StatusCode UA_NodeStore_remove(UA_NodeStore *ns, const UA_NodeId *nodeid);
  43. /**
  44. * The returned pointer is only valid as long as the node has not been replaced
  45. * or removed (in the same thread).
  46. */
  47. const UA_Node * UA_NodeStore_get(UA_NodeStore *ns, const UA_NodeId *nodeid);
  48. /** Returns the copy of a node. */
  49. UA_Node * UA_NodeStore_getCopy(UA_NodeStore *ns, const UA_NodeId *nodeid);
  50. /**
  51. * A function that can be evaluated on all entries in a nodestore via
  52. * UA_NodeStore_iterate. Note that the visitor is read-only on the nodes.
  53. */
  54. typedef void (*UA_NodeStore_nodeVisitor)(const UA_Node *node);
  55. /** Iterate over all nodes in a nodestore. */
  56. void UA_NodeStore_iterate(UA_NodeStore *ns, UA_NodeStore_nodeVisitor visitor);
  57. #endif /* UA_NODESTORE_H_ */