~drizzle-trunk/drizzle/development

1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
2
 *
3
 * PrimeBase Media Stream for MySQL
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
18
 *
19
 * Original author: Paul McCullagh (H&G2JCtL)
20
 * Continued development: Barry Leslie
21
 *
22
 * 2007-05-20
23
 *
24
 * A basic syncronized object.
25
 *
26
 */
27
28
#include "CSConfig.h"
29
30
#include <assert.h>
31
32
#include "CSGlobal.h"
33
#include "CSDefs.h"
34
#include "CSObject.h"
35
#include "CSMemory.h"
36
37
#ifdef DEBUG
38
#undef retain
39
#undef release
40
#endif
41
42
/*
43
 * ---------------------------------------------------------------
44
 * BASIC OBJECTS
45
 */
46
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
47
#ifdef DEBUG
48
void CSObject::retain(const char *func, const char *file, uint32_t line)
49
{
50
	CSException::throwAssertion(func, file, line, "Non-referenced object cannot be referenced");
51
}
52
#else
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
53
void CSObject::retain()
54
{
55
	CSException::throwAssertion(CS_CONTEXT, "Non-referenced object cannot be referenced");
56
}
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
57
#endif
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
58
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
59
#ifdef DEBUG
60
void CSObject::release(const char *, const char *, uint32_t )
61
#else
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
62
void CSObject::release()
63
#endif
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
64
{
65
	delete this;
66
}
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
67
68
CSObject *CSObject::getKey() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; }
69
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
70
int CSObject::compareKey(CSObject *)  { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return 0; }
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
71
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
72
uint32_t CSObject::hashKey()  { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return 0; }
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
73
74
CSObject *CSObject::getHashLink() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; }
75
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
76
void CSObject::setHashLink(CSObject *) { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); }
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
77
78
CSObject *CSObject::getNextLink() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; }
79
80
CSObject *CSObject::getPrevLink() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; }
81
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
82
void CSObject::setNextLink(CSObject *) { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); }
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
83
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
84
void CSObject::setPrevLink(CSObject *) { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); }
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
85
86
/*
87
 * ---------------------------------------------------------------
88
 * STATIC OBJECTS
89
 */
90
91
#ifdef DEBUG
92
void CSStaticObject::retain(const char *, const char *, uint32_t )
93
#else
94
void CSStaticObject::retain()
95
#endif
96
{
97
}
98
99
#ifdef DEBUG
100
void CSStaticObject::release(const char *, const char *, uint32_t )
101
#else
102
void CSStaticObject::release()
103
#endif
104
{
105
	finalize();
106
}
107
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
108
/*
109
 * ---------------------------------------------------------------
110
 * REFERENCE OBJECTS
111
 */
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
112
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
113
CSRefObject::CSRefObject():
114
CSObject(),
115
iRefCount(1)
116
{
117
#ifdef DEBUG
118
	iTrackMe = 0;
119
	cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe);
120
#endif
121
}
122
123
CSRefObject::~CSRefObject()
124
{
125
	ASSERT(iRefCount == 0);
126
}
127
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
128
#ifdef DEBUG
129
void CSRefObject::retain(const char *func, const char *file, uint32_t line)
130
#else
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
131
void CSRefObject::retain()
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
132
#endif
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
133
{
134
	if (!iRefCount)
135
		CSException::throwAssertion(CS_CONTEXT, "Freed object being retained.");
136
		
137
	iRefCount++;
138
#ifdef DEBUG
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
139
	cs_mm_track_memory(func, file, line, this, true, iRefCount, iTrackMe);
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
140
#endif
141
}
142
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
143
#ifdef DEBUG
144
void CSRefObject::release(const char *func, const char *file, uint32_t line)
145
#else
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
146
void CSRefObject::release()
147
#endif
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
148
{
149
	bool terminate;
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
150
151
#ifdef DEBUG
152
	cs_mm_track_memory(func, file, line, this, false, iRefCount, iTrackMe);
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
153
#endif
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
154
	iRefCount--;
155
	if (!iRefCount)
156
		terminate = true;
157
	else
158
		terminate = false;
159
160
	if (terminate)
161
		delete this;
162
}
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
163
164
#ifdef DEBUG
165
void CSRefObject::startTracking()
166
{
167
	iTrackMe = 1;
168
	cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe);
169
}
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
170
#endif
171
172
/*
173
 * ---------------------------------------------------------------
174
 * SHARED REFERENCE OBJECTS
175
 */
176
177
CSSharedRefObject::CSSharedRefObject():
178
CSObject(),
179
CSSync(),
180
iRefCount(1)
181
{
182
#ifdef DEBUG
183
	iTrackMe = 0;
184
	cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe);
185
#endif
186
}
187
188
CSSharedRefObject::~CSSharedRefObject()
189
{
190
	ASSERT(iRefCount == 0);
191
}
192
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
193
#ifdef DEBUG
194
void CSSharedRefObject::retain(const char *func, const char *file, uint32_t line)
195
#else
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
196
void CSSharedRefObject::retain()
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
197
#endif
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
198
{
199
	lock();
200
	iRefCount++;
201
#ifdef DEBUG
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
202
	cs_mm_track_memory(func, file, line, this, true, iRefCount, iTrackMe);
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
203
#endif
204
	unlock();
205
}
206
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
207
#ifdef DEBUG
208
void CSSharedRefObject::release(const char *func, const char *file, uint32_t line)
209
#else
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
210
void CSSharedRefObject::release()
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
211
#endif
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
212
{
213
	bool terminate;
214
215
	lock();
216
#ifdef DEBUG
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
217
	cs_mm_track_memory(func, file, line, this, false, iRefCount, iTrackMe);
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
218
#endif
219
	iRefCount--;
220
	if (!iRefCount)
221
		terminate = true;
222
	else
223
		terminate = false;
224
	unlock();
225
226
	if (terminate)
227
		delete this;
228
}
229
230
#ifdef DEBUG
231
void CSSharedRefObject::startTracking()
232
{
233
	iTrackMe = 1;
234
	cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe);
235
}
236
#endif
237
238
#ifdef DEBUG
239
/*
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
240
void CSSharedRefObject::retain(const char *func, const char *file, uint32_t line)
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
241
{
242
	lock();
243
	iRefCount++;
244
	cs_mm_print_track(func, file, line, this, true, iRefCount);
245
	unlock();
246
}
247
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
248
void CSSharedRefObject::release(const char *func, const char *file, uint32_t line)
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
249
{
250
	bool terminate;
251
252
	lock();
253
	cs_mm_track_memory(func, file, line, this, false, iRefCount, iTrackMe);
254
	iRefCount--;
255
	if (!iRefCount)
256
		terminate = true;
257
	else
258
		terminate = false;
259
	unlock();
260
261
	if (terminate)
262
		delete this;
263
}
264
*/
265
#endif
1548.2.11 by Barry.Leslie at PrimeBase
Removed libxml reqirement by using a home grown xml parser.
266
267