~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Merge Joe, plus I updated the tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
 
1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
2
2
 *
3
3
 * PrimeBase Media Stream for MySQL
4
4
 *
14
14
 *
15
15
 * You should have received a copy of the GNU General Public License
16
16
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
18
 *
19
19
 * Original author: Paul McCullagh (H&G2JCtL)
20
20
 * Continued development: Barry Leslie
42
42
// operator out side of a 'for' loop. :)
43
43
#define RETAIN(x) ((x)->retain(),(x))
44
44
 
45
 
// A back reference is a reference stored by an object pointing to it's owner.
46
 
// Since the owner will free all of it's object when it is released the  object
47
 
// itself cannot hold a reference to its owner.
48
 
// Use this macro to make it clear that this is what you intended. 
49
 
#define BACK_REFERENCE(x) (x)
50
 
 
51
45
class CSObject {
52
46
public:
53
47
        CSObject() { }
54
48
        virtual ~CSObject() { finalize(); }
55
49
 
56
 
#ifdef DEBUG
57
 
        virtual void retain(const char *func, const char *file, uint32_t line);
58
 
        virtual void release(const char *func, const char *file, uint32_t line);
59
 
#else
60
50
        virtual void retain();
61
51
        virtual void release();
62
 
#endif
63
52
 
64
53
        /*
65
54
         * All objects are sortable, hashable and linkable,
86
75
                cs_mm_free(ptr);
87
76
        }
88
77
 
89
 
#endif
90
 
};
91
 
 
92
 
class CSStaticObject : public CSObject {
93
 
#ifdef DEBUG
94
 
        virtual void retain(const char *func, const char *file, uint32_t line);
95
 
        virtual void release(const char *func, const char *file, uint32_t line);
96
 
 
97
 
        int             iTrackMe;
98
 
#else
99
 
        virtual void retain();
100
 
        virtual void release();
 
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);
101
80
#endif
102
81
};
103
82
 
106
85
        CSRefObject();
107
86
        virtual ~CSRefObject();
108
87
 
 
88
        virtual void retain();
 
89
        virtual void release();
109
90
#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
 
 
 
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);
114
93
        int             iTrackMe;
115
 
#else
116
 
        virtual void retain();
117
 
        virtual void release();
118
94
#endif
119
95
 
120
 
        uint32_t getRefCount() { return iRefCount;}
121
 
 
 
96
#ifndef DEBUG
122
97
private:
 
98
#endif
123
99
        uint32_t        iRefCount;
124
100
};
125
101
 
128
104
        CSSharedRefObject();
129
105
        virtual ~CSSharedRefObject();
130
106
 
131
 
#ifdef DEBUG
132
 
        virtual void startTracking();
133
 
        virtual void retain(const char *func, const char *file, uint32_t line);
134
 
        virtual void release(const char *func, const char *file, uint32_t line);
135
 
 
136
 
        int             iTrackMe;
137
 
#else
138
107
        virtual void retain();
139
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;
140
114
#endif
141
115
 
142
 
        uint32_t getRefCount() { return iRefCount;}
143
 
 
 
116
#ifndef DEBUG
144
117
private:
145
 
        uint32_t        iRefCount;
146
 
};
147
 
 
148
 
#ifdef DEBUG
149
 
#define new                    new(__FUNC__, __FILE__, __LINE__)
150
 
 
151
 
#define retain()        retain(__FUNC__, __FILE__, __LINE__)
152
 
#define release()       release(__FUNC__, __FILE__, __LINE__)
 
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__)
153
133
#endif
154
134
 
155
135
class CSPooled {