~pbms-core/pbms/async_read

« back to all changes in this revision

Viewing changes to mybs/src/cslib/CSObject.h

  • Committer: paul-mccullagh
  • Date: 2008-03-26 11:35:17 UTC
  • Revision ID: paul-mccullagh-afb1610c21464a577ae428d72fc725eb986c05a5
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2007 SNAP Innovation GmbH
 
2
 *
 
3
 * BLOB Streaming 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
 * Paul McCullagh (H&G2JCtL)
 
20
 *
 
21
 * 2007-05-20
 
22
 *
 
23
 * CORE SYSTEM:
 
24
 * A base class for all TeamDrive classes.
 
25
 *
 
26
 */
 
27
 
 
28
#ifndef __CSOBJECT_H__
 
29
#define __CSOBJECT_H__
 
30
 
 
31
#include "CSDefs.h"
 
32
#include "CSMemory.h"
 
33
#include "CSMutex.h"
 
34
 
 
35
class CSObject {
 
36
public:
 
37
        CSObject() { }
 
38
        virtual ~CSObject() { }
 
39
 
 
40
        virtual void retain();
 
41
        virtual void release();
 
42
 
 
43
        /*
 
44
         * All objects are sortable, hashable and linkable,
 
45
         * as long as these methods are implemented:
 
46
         */
 
47
        virtual CSObject *getKey();
 
48
        virtual int compareKey(CSObject *);
 
49
        virtual u_int hashKey();
 
50
        virtual CSObject *getHashLink();
 
51
        virtual void setHashLink(CSObject *);
 
52
        virtual CSObject *getNextLink();
 
53
        virtual CSObject *getPrevLink();
 
54
        virtual void setNextLink(CSObject *);
 
55
        virtual void setPrevLink(CSObject *);
 
56
 
 
57
#ifdef DBUG_ON
 
58
        static void *operator new(size_t size, const char *func, const char *file, u_int line) {
 
59
                return cs_mm_malloc(func, file, line, size);
 
60
        }
 
61
 
 
62
        static void operator delete(void *ptr, size_t size) {
 
63
                cs_mm_free(ptr);
 
64
        }
 
65
 
 
66
        //virtual void retain(const char *func, const char *file, u_int line);
 
67
        //virtual void release(const char *func, const char *file, u_int line);
 
68
#endif
 
69
};
 
70
 
 
71
class CSRefObject : public CSObject {
 
72
public:
 
73
        CSRefObject();
 
74
        virtual ~CSRefObject();
 
75
 
 
76
        virtual void retain();
 
77
        virtual void release();
 
78
#ifdef DBUG_ON
 
79
        //virtual void retain(const char *func, const char *file, u_int line);
 
80
        //virtual void release(const char *func, const char *file, u_int line);
 
81
#endif
 
82
 
 
83
#ifndef DBUG_ON
 
84
private:
 
85
#endif
 
86
        u_int   iRefCount;
 
87
};
 
88
 
 
89
class CSSharedRefObject : public CSObject, public CSSync {
 
90
public:
 
91
        CSSharedRefObject();
 
92
        virtual ~CSSharedRefObject();
 
93
 
 
94
        virtual void retain();
 
95
        virtual void release();
 
96
#ifdef DBUG_ON
 
97
        //virtual void retain(const char *func, const char *file, u_int line);
 
98
        //virtual void release(const char *func, const char *file, u_int line);
 
99
#endif
 
100
 
 
101
#ifndef DBUG_ON
 
102
private:
 
103
#endif
 
104
        u_int   iRefCount;
 
105
};
 
106
 
 
107
#ifdef DBUG_ON
 
108
#define new new(__FUNC__, __FILE__, __LINE__)
 
109
#endif
 
110
 
 
111
class CSPooled {
 
112
public:
 
113
        virtual void returnToPool() = 0;
 
114
};
 
115
 
 
116
#endif