~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/cslib/CSObject.h

Remove dead memset call.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
18
 *
 
19
 * Original author: Paul McCullagh (H&G2JCtL)
 
20
 * Continued development: Barry Leslie
 
21
 *
 
22
 * 2007-05-20
 
23
 *
 
24
 *
 
25
 */
 
26
 
 
27
#ifndef __CSOBJECT_H__
 
28
#define __CSOBJECT_H__
 
29
 
 
30
#include "CSDefs.h"
 
31
#include "CSMemory.h"
 
32
#include "CSMutex.h"
 
33
 
 
34
// The RETAIN() macro is useful when passing object references to functions
 
35
// that you want to retain. For example istead of:
 
36
// x->retain();
 
37
// foo(x);
 
38
// You can do:
 
39
// foo(RETAIN(x));
 
40
//
 
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))
 
44
 
 
45
class CSObject {
 
46
public:
 
47
        CSObject() { }
 
48
        virtual ~CSObject() { finalize(); }
 
49
 
 
50
        virtual void retain();
 
51
        virtual void release();
 
52
 
 
53
        /*
 
54
         * All objects are sortable, hashable and linkable,
 
55
         * as long as these methods are implemented:
 
56
         */
 
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 *);
 
67
 
 
68
#ifdef DEBUG
 
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);
 
71
        }
 
72
 
 
73
        static void operator delete(void *ptr, size_t size) {
 
74
                UNUSED(size);
 
75
                cs_mm_free(ptr);
 
76
        }
 
77
 
 
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);
 
80
#endif
 
81
};
 
82
 
 
83
class CSRefObject : public CSObject {
 
84
public:
 
85
        CSRefObject();
 
86
        virtual ~CSRefObject();
 
87
 
 
88
        virtual void retain();
 
89
        virtual void release();
 
90
#ifdef DEBUG
 
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);
 
93
        int             iTrackMe;
 
94
#endif
 
95
 
 
96
#ifndef DEBUG
 
97
private:
 
98
#endif
 
99
        uint32_t        iRefCount;
 
100
};
 
101
 
 
102
class CSSharedRefObject : public CSObject, public CSSync {
 
103
public:
 
104
        CSSharedRefObject();
 
105
        virtual ~CSSharedRefObject();
 
106
 
 
107
        virtual void retain();
 
108
        virtual void release();
 
109
#ifdef DEBUG
 
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);
 
113
        int             iTrackMe;
 
114
#endif
 
115
 
 
116
#ifndef DEBUG
 
117
private:
 
118
#endif
 
119
        uint32_t        iRefCount;
 
120
};
 
121
 
 
122
class CSStaticObject : public CSObject {
 
123
        virtual void retain() {}
 
124
        virtual void release(){ finalize();}
 
125
#ifdef DEBUG
 
126
        int             iTrackMe;
 
127
#endif
 
128
        uint32_t        iRefCount;
 
129
};
 
130
 
 
131
#ifdef DEBUG
 
132
#define new new(__FUNC__, __FILE__, __LINE__)
 
133
#endif
 
134
 
 
135
class CSPooled {
 
136
public:
 
137
        virtual ~CSPooled() {}
 
138
        virtual void returnToPool() = 0;
 
139
};
 
140
 
 
141
#endif