opcua_namespace.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef __NAMESPACE_H__
  2. #define __NAMESPACE_H__
  3. #include "opcua_basictypes.h"
  4. #include "opcua.h"
  5. typedef uint32_t hash_t;
  6. typedef struct namespace_t {
  7. UA_Int32 namespaceId;
  8. UA_String namespaceUri;
  9. UA_Node **entries;
  10. uint32_t size;
  11. uint32_t count;
  12. uint32_t sizePrimeIndex; /* Current size, as an index into the table of primes. */
  13. } namespace;
  14. UA_Int32 create_ns(namespace **result, uint32_t size);
  15. void empty_ns(namespace *ns);
  16. void delete_ns(namespace *ns);
  17. UA_Int32 insert(namespace *ns, UA_Node *node);
  18. UA_Int32 find(namespace *ns, UA_Node **result, UA_NodeId *nodeid);
  19. void delete(namespace *ns, UA_NodeId *nodeid);
  20. /* Internal */
  21. static hash_t hash_string(const UA_Byte * data, UA_Int32 len);
  22. static hash_t hash(const UA_NodeId *n);
  23. static unsigned int higher_prime_index (unsigned long n);
  24. static inline hash_t mod_1(hash_t x, hash_t y, hash_t inv, int shift);
  25. static inline hash_t mod(hash_t hash, const namespace *ns);
  26. static inline hash_t htab_mod_m2(hash_t hash, const namespace *ns);
  27. static UA_Int32 find_slot(const namespace *ns, UA_Node **slot, UA_NodeId *nodeid);
  28. static UA_Node ** find_empty_slot(const namespace *ns, hash_t hash);
  29. static UA_Int32 expand(namespace *ns);
  30. #endif /* __NAMESPACE_H */