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