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.

127 lines
3.2KB

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