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 |
||
47 |
void CSObject::retain() |
|
48 |
{
|
|
49 |
CSException::throwAssertion(CS_CONTEXT, "Non-referenced object cannot be referenced"); |
|
50 |
}
|
|
51 |
||
52 |
void CSObject::release() |
|
53 |
{
|
|
54 |
delete this; |
|
55 |
}
|
|
56 |
||
57 |
#ifdef DEBUG
|
|
58 |
/*
|
|
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. |
59 |
void CSObject::retain(const char *func, const char *file, uint32_t line)
|
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
60 |
{
|
61 |
CSException::throwAssertion(CS_CONTEXT, "Non-referenced object cannot be referenced");
|
|
62 |
}
|
|
63 |
||
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. |
64 |
void CSObject::release(const char *func, const char *file, uint32_t line)
|
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
65 |
{
|
66 |
delete this;
|
|
67 |
}
|
|
68 |
*/
|
|
69 |
#endif
|
|
70 |
||
71 |
CSObject *CSObject::getKey() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; } |
|
72 |
||
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. |
73 |
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. |
74 |
|
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. |
75 |
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. |
76 |
|
77 |
CSObject *CSObject::getHashLink() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; } |
|
78 |
||
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. |
79 |
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. |
80 |
|
81 |
CSObject *CSObject::getNextLink() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; } |
|
82 |
||
83 |
CSObject *CSObject::getPrevLink() { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); return NULL; } |
|
84 |
||
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. |
85 |
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. |
86 |
|
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. |
87 |
void CSObject::setPrevLink(CSObject *) { CSException::throwCoreError(CS_CONTEXT, CS_ERR_IMPL_MISSING, __FUNC__); } |
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
88 |
/*
|
89 |
* ---------------------------------------------------------------
|
|
90 |
* REFERENCE OBJECTS
|
|
91 |
*/
|
|
92 |
CSRefObject::CSRefObject(): |
|
93 |
CSObject(), |
|
94 |
iRefCount(1) |
|
95 |
{
|
|
96 |
#ifdef DEBUG
|
|
97 |
iTrackMe = 0; |
|
98 |
cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe); |
|
99 |
#endif
|
|
100 |
}
|
|
101 |
||
102 |
CSRefObject::~CSRefObject() |
|
103 |
{
|
|
104 |
ASSERT(iRefCount == 0); |
|
105 |
}
|
|
106 |
||
107 |
void CSRefObject::retain() |
|
108 |
{
|
|
109 |
if (!iRefCount) |
|
110 |
CSException::throwAssertion(CS_CONTEXT, "Freed object being retained."); |
|
111 |
||
112 |
iRefCount++; |
|
113 |
#ifdef DEBUG
|
|
114 |
cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe); |
|
115 |
#endif
|
|
116 |
}
|
|
117 |
||
118 |
void CSRefObject::release() |
|
119 |
{
|
|
120 |
bool terminate; |
|
121 |
||
122 |
#ifdef DEBUG
|
|
123 |
cs_mm_track_memory(NULL, NULL, 0, this, false, iRefCount, iTrackMe); |
|
124 |
#endif
|
|
125 |
iRefCount--; |
|
126 |
if (!iRefCount) |
|
127 |
terminate = true; |
|
128 |
else
|
|
129 |
terminate = false; |
|
130 |
||
131 |
if (terminate) |
|
132 |
delete this; |
|
133 |
}
|
|
134 |
||
135 |
#ifdef DEBUG
|
|
136 |
/*
|
|
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. |
137 |
void CSRefObject::retain(const char *func, const char *file, uint32_t line)
|
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
138 |
{
|
139 |
iRefCount++;
|
|
140 |
cs_mm_print_track(func, file, line, this, true, iRefCount);
|
|
141 |
}
|
|
142 |
||
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. |
143 |
void CSRefObject::release(const char *func, const char *file, uint32_t line)
|
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
144 |
{
|
145 |
bool terminate;
|
|
146 |
||
147 |
cs_mm_track_memory(func, file, line, this, false, iRefCount, iTrackMe);
|
|
148 |
iRefCount--;
|
|
149 |
if (!iRefCount)
|
|
150 |
terminate = true;
|
|
151 |
else
|
|
152 |
terminate = false;
|
|
153 |
||
154 |
if (terminate)
|
|
155 |
delete this;
|
|
156 |
}
|
|
157 |
*/
|
|
158 |
#endif
|
|
159 |
||
160 |
/*
|
|
161 |
* ---------------------------------------------------------------
|
|
162 |
* SHARED REFERENCE OBJECTS
|
|
163 |
*/
|
|
164 |
||
165 |
CSSharedRefObject::CSSharedRefObject(): |
|
166 |
CSObject(), |
|
167 |
CSSync(), |
|
168 |
iRefCount(1) |
|
169 |
{
|
|
170 |
#ifdef DEBUG
|
|
171 |
iTrackMe = 0; |
|
172 |
cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe); |
|
173 |
#endif
|
|
174 |
}
|
|
175 |
||
176 |
CSSharedRefObject::~CSSharedRefObject() |
|
177 |
{
|
|
178 |
ASSERT(iRefCount == 0); |
|
179 |
}
|
|
180 |
||
181 |
void CSSharedRefObject::retain() |
|
182 |
{
|
|
183 |
lock(); |
|
184 |
iRefCount++; |
|
185 |
#ifdef DEBUG
|
|
186 |
cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe); |
|
187 |
#endif
|
|
188 |
unlock(); |
|
189 |
}
|
|
190 |
||
191 |
void CSSharedRefObject::release() |
|
192 |
{
|
|
193 |
bool terminate; |
|
194 |
||
195 |
lock(); |
|
196 |
#ifdef DEBUG
|
|
197 |
cs_mm_track_memory(NULL, NULL, 0, this, false, iRefCount, iTrackMe); |
|
198 |
#endif
|
|
199 |
iRefCount--; |
|
200 |
if (!iRefCount) |
|
201 |
terminate = true; |
|
202 |
else
|
|
203 |
terminate = false; |
|
204 |
unlock(); |
|
205 |
||
206 |
if (terminate) |
|
207 |
delete this; |
|
208 |
}
|
|
209 |
||
210 |
#ifdef DEBUG
|
|
211 |
void CSSharedRefObject::startTracking() |
|
212 |
{
|
|
213 |
iTrackMe = 1; |
|
214 |
cs_mm_track_memory(NULL, NULL, 0, this, true, iRefCount, iTrackMe); |
|
215 |
}
|
|
216 |
#endif
|
|
217 |
||
218 |
#ifdef DEBUG
|
|
219 |
/*
|
|
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. |
220 |
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. |
221 |
{
|
222 |
lock();
|
|
223 |
iRefCount++;
|
|
224 |
cs_mm_print_track(func, file, line, this, true, iRefCount);
|
|
225 |
unlock();
|
|
226 |
}
|
|
227 |
||
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. |
228 |
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. |
229 |
{
|
230 |
bool terminate;
|
|
231 |
||
232 |
lock();
|
|
233 |
cs_mm_track_memory(func, file, line, this, false, iRefCount, iTrackMe);
|
|
234 |
iRefCount--;
|
|
235 |
if (!iRefCount)
|
|
236 |
terminate = true;
|
|
237 |
else
|
|
238 |
terminate = false;
|
|
239 |
unlock();
|
|
240 |
||
241 |
if (terminate)
|
|
242 |
delete this;
|
|
243 |
}
|
|
244 |
*/
|
|
245 |
#endif
|
|
1548.2.11
by Barry.Leslie at PrimeBase
Removed libxml reqirement by using a home grown xml parser. |
246 |
|
247 |