Changeset 6170 in vbox
- Timestamp:
- Dec 21, 2007 3:02:10 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 26926
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpputils.h
r6076 r6170 108 108 * Pointer management includes the following key points: 109 109 * 110 * 1) Automatic increment of the reference counter when a pointer to the111 * object of the managed class or another auto_ptr_instance of the same112 * type is assigned to the given auto_ref_ptr instance.110 * 1) Automatic increment of the object's reference counter when the given 111 * auto_ref_ptr instance starts managing a pointer to this object. 112 * 113 113 * 2) Automatic decrement of the reference counter when the given 114 * auto_ref_ptr instance is destroyed (for example, as a result of 115 * leaving the scope) or berfore it is assigned a new object pointer. 116 * 3) Automatic deletion of the managed object pointer whenever its 117 * reference counter reaches zero after a decrement. 118 * 4) Providing the dereference operator that gives direct access to the 114 * auto_ref_ptr instance is destroyed, or before it is assigned a pointer 115 * to a new object. 116 * 117 * 3) Automatic deletion of the managed object whenever its reference 118 * counter reaches zero after a decrement. 119 * 120 * 4) Providing the dereference operator-> that gives direct access to the 119 121 * managed pointer. 120 122 * … … 135 137 136 138 /** 137 * Creates an instance that starts managing the given pointer. 139 * Creates an instance that starts managing the given pointer. The 140 * reference counter of the object pointed to by @a a is incremented by 141 * one. 138 142 * 139 143 * @param a Pointer to manage. … … 142 146 143 147 /** 144 * Creates an instance that starts managing the pointer managed 145 * by the given object. 148 * Creates an instance that starts managing a pointer managed by the given 149 * instance. The reference counter of the object managed by @a that is 150 * incremented by one. 146 151 * 147 * @param that Object to manage.152 * @param that Instance to take a pointer to manage from. 148 153 */ 149 154 auto_ref_ptr (const auto_ref_ptr &that) : m (that.m) { if (m) m->ref(); } … … 152 157 153 158 /** 154 * Assigns the given pointer to this instance and starts managing it. 159 * Assigns the given pointer to this instance and starts managing it. The 160 * reference counter of the object pointed to by @a a is incremented by 161 * one. The reference counter of the object previously managed by this 162 * instance is decremented by one. 155 163 * 156 164 * @param a Pointer to assign. … … 159 167 160 168 /** 161 * Assigns the given pointer to this instance and starts managing it. 169 * Assigns a pointer managed by the given instance to this instance and 170 * starts managing it. The reference counter of the object managed by @a 171 * that is incremented by one. The reference counter of the object 172 * previously managed by this instance is decremented by one. 162 173 * 163 174 * @param a Pointer to assign. … … 166 177 167 178 /** 168 * Returns @c true if this instance is null and false otherwise.179 * Returns @c true if this instance is @c null and false otherwise. 169 180 */ 170 181 bool is_null() const { return m == NULL; } … … 172 183 /** 173 184 * Dereferences the instance by returning the managed pointer. 174 * Asserts that the managed pointer is not NULL.185 * Asserts that the managed pointer is not @c NULL. 175 186 */ 176 187 C *operator-> () const { AssertMsg (m, ("Managed pointer is NULL!\n")); return m; } 177 188 178 189 /** 179 * Returns the managed pointer or NULL if this instance isnull.190 * Returns the managed pointer or @c NULL if this instance is @c null. 180 191 */ 181 192 C *raw() const { return m; } 182 193 183 194 /** 184 * Compares this auto_ref_ptr instance another instance and returns @c185 * true if both instances manage the same or @c NULL pointer.195 * Compares this auto_ref_ptr instance with another instance and returns 196 * @c true if both instances manage the same or @c NULL pointer. 186 197 * 187 * Note that this method doesn't try to compare objects managed pointers188 * point to because that would a) break the common 'pointer to something'189 * semantics auto_ref_ptr tries to follow and b) require to define the190 * comparison operator in the managed class which is not always possible.191 * You may analyze pointed objects yourself if you need more precise192 * comparison.198 * Note that this method compares pointer values only, it doesn't try to 199 * compare objects themselves. Doing otherwise would a) break the common 200 * 'pointer to something' comparison semantics auto_ref_ptr tries to 201 * follow and b) require to define the comparison operator in the managed 202 * class which is not always possible. You may analyze pointed objects 203 * yourself if you need more precise comparison. 193 204 * 194 * @param that Object to compare this objectwith.205 * @param that Instance to compare this instance with. 195 206 */ 196 207 bool operator== (const auto_ref_ptr &that) const
Note:
See TracChangeset
for help on using the changeset viewer.