~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to include/RefCount.h

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2009-09-24 14:51:06 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (20.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090924145106-38jgrzmj0d73pha5
Tags: 3.1.0.13-1
* Upload to experimental

* New upstream release
  - Fixes Follow-X-Forwarded-For support (Closes: #523943)
  - Adds IPv6 support (Closes: #432351)

* debian/rules
  - Removed obsolete configuration options
  - Enable db and radius basic authentication modules

* debian/patches/01-cf.data.debian
  - Adapted to new upstream version

* debian/patches/02-makefile-defaults
  - Adapted to new upstream version

* debian/{squid.postinst,squid.rc,README.Debian,watch}
  - Updated references to squid 3.1

* debian/squid3.install
  - Install CSS file for error pages
  - Install manual pages for new authentication modules

* debian/squid3-common.install
  - Install documented version of configuration file in /usr/share/doc/squid3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
1
/*
3
 
 * $Id: RefCount.h,v 1.11 2007/04/25 11:30:15 adrian Exp $
 
2
 * $Id$
4
3
 *
5
4
 * DEBUG: none          Refcount allocator
6
5
 * AUTHOR:  Robert Collins
21
20
 *  it under the terms of the GNU General Public License as published by
22
21
 *  the Free Software Foundation; either version 2 of the License, or
23
22
 *  (at your option) any later version.
24
 
 *  
 
23
 *
25
24
 *  This program is distributed in the hope that it will be useful,
26
25
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
27
26
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
27
 *  GNU General Public License for more details.
29
 
 *  
 
28
 *
30
29
 *  You should have received a copy of the GNU General Public License
31
30
 *  along with this program; if not, write to the Free Software
32
31
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
36
35
#ifndef _SQUID_REFCOUNT_H_
37
36
#define _SQUID_REFCOUNT_H_
38
37
 
 
38
#include "config.h"
 
39
 
 
40
#if HAVE_IOSTREAM
39
41
#include <iostream>
 
42
#endif
40
43
 
41
44
template <class C>
42
 
 
43
45
class RefCount
44
46
{
45
47
 
48
50
 
49
51
    RefCount (C const *p) : p_(p) { reference (*this); }
50
52
 
51
 
    ~RefCount()
52
 
    {
 
53
    ~RefCount() {
53
54
        dereference();
54
55
    }
55
56
 
56
 
    RefCount (const RefCount &p) : p_(p.p_)
57
 
    {
 
57
    RefCount (const RefCount &p) : p_(p.p_) {
58
58
        reference (p);
59
59
    }
60
60
 
61
 
    RefCount& operator = (const RefCount& p)
62
 
    {
 
61
    RefCount& operator = (const RefCount& p) {
63
62
        // DO NOT CHANGE THE ORDER HERE!!!
64
63
        // This preserves semantics on self assignment
65
64
        C const *newP_ = p.p_;
68
67
        return *this;
69
68
    }
70
69
 
71
 
        bool operator !() const { return !p_; }
 
70
    bool operator !() const { return !p_; }
72
71
 
73
72
    C const * operator-> () const {return p_; }
74
73
 
78
77
 
79
78
    C & operator * () {return *const_cast<C *>(p_); }
80
79
 
81
 
    C const * getRaw() const{return p_; }
 
80
    C const * getRaw() const {return p_; }
82
81
 
83
82
    C * getRaw() {return const_cast<C *>(p_); }
84
83
 
85
 
    bool operator == (const RefCount& p) const
86
 
    {
 
84
    bool operator == (const RefCount& p) const {
87
85
        return p.p_ == p_;
88
86
    }
89
87
 
90
 
    bool operator != (const RefCount &p) const
91
 
    {
 
88
    bool operator != (const RefCount &p) const {
92
89
        return p.p_ != p_;
93
90
    }
94
91
 
95
92
private:
96
 
    void dereference(C const *newP = NULL)
97
 
    {
 
93
    void dereference(C const *newP = NULL) {
98
94
        /* Setting p_ first is important:
99
95
        * we may be freed ourselves as a result of
100
96
        * delete p_;
106
102
            delete tempP_;
107
103
    }
108
104
 
109
 
    void reference (const RefCount& p)
110
 
    {
 
105
    void reference (const RefCount& p) {
111
106
        if (p.p_)
112
107
            p.p_->RefCountReference();
113
108
    }
116
111
 
117
112
};
118
113
 
119
 
struct RefCountable_
120
 
{
121
 
    RefCountable_():count_(0){}
 
114
struct RefCountable_ {
 
115
    RefCountable_():count_(0) {}
122
116
 
123
 
    virtual ~RefCountable_(){}
 
117
    virtual ~RefCountable_() {}
124
118
 
125
119
    /* Not private, to allow class hierarchies */
126
 
    void RefCountReference() const
127
 
    {
 
120
    void RefCountReference() const {
128
121
#if REFCOUNT_DEBUG
129
122
        debug (0,1)("Incrementing this %p from count %u\n",this,count_);
130
123
#endif
132
125
        ++count_;
133
126
    }
134
127
 
135
 
    unsigned RefCountDereference() const
136
 
    {
 
128
    unsigned RefCountDereference() const {
137
129
#if REFCOUNT_DEBUG
138
130
        debug (0,1)("Decrementing this %p from count %u\n",this,count_);
139
131
#endif