store.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /** @file store.h
  2. *
  3. * @brief Generic store dependency.
  4. *
  5. * This code allows to use the store interface with any supported back end
  6. * without any knowledge of the back end implementations. Code using the store
  7. * interface need only include this file.
  8. *
  9. * New store implementations should be added to this file as `#include`s as
  10. * well as entries in the `BACKEND_TBL` macro.
  11. */
  12. #ifndef _LSUP_STORE_H
  13. #define _LSUP_STORE_H
  14. /*
  15. * Add new back end headers here.
  16. */
  17. #include "store_htable.h"
  18. #include "store_mdb.h"
  19. /*
  20. * Define backend types.
  21. *
  22. * Add new store implementations to this table.
  23. */
  24. #define BACKEND_TBL \
  25. /* #enum pfx #store if */\
  26. ENTRY( HTABLE, htstore_int ) \
  27. ENTRY( MDB, mdbstore_int ) \
  28. /** @brief Store types. All prefixed with `LSUP_STORE_`.
  29. */
  30. typedef enum {
  31. #define ENTRY(a, b) LSUP_STORE_##a,
  32. BACKEND_TBL
  33. #undef ENTRY
  34. } LSUP_StoreType;
  35. /** @brief Store structure.
  36. *
  37. * Code using the store interface should create an instance of this structure
  38. * with pointers to the store interface of their choice, and to an opaque
  39. * structure to hold the store state.
  40. *
  41. * Iterator state handles generated by lookup and add functions are kept
  42. * outside of this structure, but manipulated by the interface specified in
  43. * here.
  44. *
  45. * @sa #LSUP_graph_new()
  46. */
  47. typedef struct store_it {
  48. LSUP_StoreType type; ///< Store type.
  49. char * id; /**< Store ID. NOTE: This is
  50. * NULL for volatile stores.
  51. */
  52. const LSUP_StoreInt * sif; ///< Store interface.
  53. void * data; ///< Store back end data.
  54. } LSUP_Store;
  55. #endif /* LSUP_STORE_H */