1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
3
* PrimeBase Media Stream for MySQL
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.
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.
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
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* Original author: Paul McCullagh (H&G2JCtL)
20
* Continued development: Barry Leslie
27
#ifndef __CSOBJECT_H__
28
#define __CSOBJECT_H__
34
// The RETAIN() macro is useful when passing object references to functions
35
// that you want to retain. For example istead of:
41
// After 20 years of programming I have finally found a use for the 'C' comma
42
// operator out side of a 'for' loop. :)
43
#define RETAIN(x) ((x)->retain(),(x))
48
virtual ~CSObject() { finalize(); }
50
virtual void retain();
51
virtual void release();
54
* All objects are sortable, hashable and linkable,
55
* as long as these methods are implemented:
57
virtual void finalize() { }
58
virtual CSObject *getKey();
59
virtual int compareKey(CSObject *);
60
virtual uint32_t hashKey();
61
virtual CSObject *getHashLink();
62
virtual void setHashLink(CSObject *);
63
virtual CSObject *getNextLink();
64
virtual CSObject *getPrevLink();
65
virtual void setNextLink(CSObject *);
66
virtual void setPrevLink(CSObject *);
69
static void *operator new(size_t size, const char *func, const char *file, uint32_t line) {
70
return cs_mm_malloc(func, file, line, size);
73
static void operator delete(void *ptr, size_t size) {
78
//virtual void retain(const char *func, const char *file, uint32_t line);
79
//virtual void release(const char *func, const char *file, uint32_t line);
83
class CSRefObject : public CSObject {
86
virtual ~CSRefObject();
88
virtual void retain();
89
virtual void release();
91
//virtual void retain(const char *func, const char *file, uint32_t line);
92
//virtual void release(const char *func, const char *file, uint32_t line);
102
class CSSharedRefObject : public CSObject, public CSSync {
105
virtual ~CSSharedRefObject();
107
virtual void retain();
108
virtual void release();
110
virtual void startTracking();
111
//virtual void retain(const char *func, const char *file, uint32_t line);
112
//virtual void release(const char *func, const char *file, uint32_t line);
122
class CSStaticObject : public CSObject {
123
virtual void retain() {}
124
virtual void release(){ finalize();}
132
#define new new(__FUNC__, __FILE__, __LINE__)
137
virtual ~CSPooled() {}
138
virtual void returnToPool() = 0;