refcnt.hh (7810:3a790012d6ed) refcnt.hh (7866:31a04e5ac4be)
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 20 unchanged lines hidden (view full) ---

29 */
30
31#ifndef __BASE_REFCNT_HH__
32#define __BASE_REFCNT_HH__
33
34class RefCounted
35{
36 private:
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 20 unchanged lines hidden (view full) ---

29 */
30
31#ifndef __BASE_REFCNT_HH__
32#define __BASE_REFCNT_HH__
33
34class RefCounted
35{
36 private:
37 int count;
37 mutable int count;
38
39 private:
40 // Don't allow a default copy constructor or copy operator on
41 // these objects because the default operation will copy the
42 // reference count as well and we certainly don't want that.
43 RefCounted(const RefCounted &);
44 RefCounted &operator=(const RefCounted &);
45

--- 33 unchanged lines hidden (view full) ---

79
80
81 public:
82 RefCountingPtr() : data(0) {}
83 RefCountingPtr(T *data) { copy(data); }
84 RefCountingPtr(const RefCountingPtr &r) { copy(r.data); }
85 ~RefCountingPtr() { del(); }
86
38
39 private:
40 // Don't allow a default copy constructor or copy operator on
41 // these objects because the default operation will copy the
42 // reference count as well and we certainly don't want that.
43 RefCounted(const RefCounted &);
44 RefCounted &operator=(const RefCounted &);
45

--- 33 unchanged lines hidden (view full) ---

79
80
81 public:
82 RefCountingPtr() : data(0) {}
83 RefCountingPtr(T *data) { copy(data); }
84 RefCountingPtr(const RefCountingPtr &r) { copy(r.data); }
85 ~RefCountingPtr() { del(); }
86
87 T *operator->() { return data; }
88 T &operator*() { return *data; }
89 T *get() { return data; }
87 T *operator->() const { return data; }
88 T &operator*() const { return *data; }
89 T *get() const { return data; }
90
90
91 const T *operator->() const { return data; }
92 const T &operator*() const { return *data; }
93 const T *get() const { return data; }
94
95 const RefCountingPtr &operator=(T *p) { set(p); return *this; }
96 const RefCountingPtr &operator=(const RefCountingPtr &r)
97 { return operator=(r.data); }
98
99 bool operator!() const { return data == 0; }
100 operator bool() const { return data != 0; }
101};
102

--- 25 unchanged lines hidden ---
91 const RefCountingPtr &operator=(T *p) { set(p); return *this; }
92 const RefCountingPtr &operator=(const RefCountingPtr &r)
93 { return operator=(r.data); }
94
95 bool operator!() const { return data == 0; }
96 operator bool() const { return data != 0; }
97};
98

--- 25 unchanged lines hidden ---