jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.0KB

  1. /*
  2. Copyright (C) 2011 David Robillard
  3. Copyright (C) 2013 Paul Davis
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or (at
  7. your option) any later version.
  8. This program is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  11. License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. #ifndef __JackMetadata__
  17. #define __JackMetadata__
  18. #include <stdint.h>
  19. #if HAVE_DB
  20. #include <db.h>
  21. #endif
  22. #include <jack/uuid.h>
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. typedef struct {
  27. const char* key;
  28. const char* data;
  29. const char* type;
  30. } jack_property_t;
  31. typedef struct {
  32. jack_uuid_t subject;
  33. uint32_t property_cnt;
  34. jack_property_t* properties;
  35. uint32_t property_size;
  36. } jack_description_t;
  37. typedef enum {
  38. PropertyCreated,
  39. PropertyChanged,
  40. PropertyDeleted
  41. } jack_property_change_t;
  42. typedef void (*JackPropertyChangeCallback)(jack_uuid_t subject,
  43. const char* key,
  44. jack_property_change_t change,
  45. void* arg);
  46. #ifdef __cplusplus
  47. }
  48. #endif
  49. namespace Jack
  50. {
  51. class JackClient;
  52. /*!
  53. \brief Metadata base.
  54. */
  55. class JackMetadata
  56. {
  57. private:
  58. #if HAVE_DB
  59. DB* fDB;
  60. DB_ENV* fDBenv;
  61. #endif
  62. int PropertyInit(const char* server_name);
  63. int PropertyChangeNotify(JackClient* client, jack_uuid_t subject, const char* key, jack_property_change_t change);
  64. #if HAVE_DB
  65. void MakeKeyDbt(DBT* dbt, jack_uuid_t subject, const char* key);
  66. #endif
  67. public:
  68. JackMetadata(const char* server_name = NULL);
  69. ~JackMetadata();
  70. int GetProperty(jack_uuid_t subject, const char* key, char** value, char** type);
  71. int GetProperties(jack_uuid_t subject, jack_description_t* desc);
  72. int GetAllProperties(jack_description_t** descriptions);
  73. int GetDescription(jack_uuid_t subject, jack_description_t* desc);
  74. int GetAllDescriptions(jack_description_t** descs);
  75. void FreeDescription(jack_description_t* desc, int free_actual_description_too);
  76. int SetProperty(JackClient* client, jack_uuid_t subject, const char* key, const char* value, const char* type);
  77. int RemoveProperty(JackClient* client, jack_uuid_t subject, const char* key);
  78. int RemoveProperties(JackClient* client, jack_uuid_t subject);
  79. int RemoveAllProperties(JackClient* client);
  80. };
  81. } // end of namespace
  82. #endif