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.

119 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. #ifdef HAVE_CONFIG_H
  19. #include "config.h"
  20. #endif
  21. #include <stdint.h>
  22. #if HAVE_DB
  23. #include <db.h>
  24. #endif
  25. #include <jack/uuid.h>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. typedef struct {
  30. const char* key;
  31. const char* data;
  32. const char* type;
  33. } jack_property_t;
  34. typedef struct {
  35. jack_uuid_t subject;
  36. uint32_t property_cnt;
  37. jack_property_t* properties;
  38. uint32_t property_size;
  39. } jack_description_t;
  40. typedef enum {
  41. PropertyCreated,
  42. PropertyChanged,
  43. PropertyDeleted
  44. } jack_property_change_t;
  45. typedef void (*JackPropertyChangeCallback)(jack_uuid_t subject,
  46. const char* key,
  47. jack_property_change_t change,
  48. void* arg);
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. namespace Jack
  53. {
  54. class JackClient;
  55. /*!
  56. \brief Metadata base.
  57. */
  58. class JackMetadata
  59. {
  60. private:
  61. #if HAVE_DB
  62. DB* fDB;
  63. DB_ENV* fDBenv;
  64. const bool fIsEngine;
  65. #endif
  66. int PropertyInit();
  67. int PropertyChangeNotify(JackClient* client, jack_uuid_t subject, const char* key, jack_property_change_t change);
  68. #if HAVE_DB
  69. void MakeKeyDbt(DBT* dbt, jack_uuid_t subject, const char* key);
  70. #endif
  71. public:
  72. JackMetadata(bool isEngine);
  73. ~JackMetadata();
  74. int GetProperty(jack_uuid_t subject, const char* key, char** value, char** type);
  75. int GetProperties(jack_uuid_t subject, jack_description_t* desc);
  76. int GetAllProperties(jack_description_t** descriptions);
  77. int GetDescription(jack_uuid_t subject, jack_description_t* desc);
  78. int GetAllDescriptions(jack_description_t** descs);
  79. void FreeDescription(jack_description_t* desc, int free_actual_description_too);
  80. int SetProperty(JackClient* client, jack_uuid_t subject, const char* key, const char* value, const char* type);
  81. int RemoveProperty(JackClient* client, jack_uuid_t subject, const char* key);
  82. int RemoveProperties(JackClient* client, jack_uuid_t subject);
  83. int RemoveAllProperties(JackClient* client);
  84. };
  85. } // end of namespace
  86. #endif