23 #ifndef SHEAF_DLL_SPEC_H 24 #include "SheafSystem/sheaf_dll_spec.h" 28 #include "SheafSystem/rc_ptr.h" 31 #ifndef ASSERT_CONTRACT_H 32 #include "SheafSystem/assert_contract.h" 46 define_old_variable(
size_type old_xtarget_ref_ct = (xtarget != 0) ? xtarget->ref_ct() : 0);
52 _target->add_reference();
57 ensure((xtarget != 0) ? xtarget->ref_ct() == old_xtarget_ref_ct+1 :
true);
73 define_old_variable(
int old_target_ref_ct = target_ref_ct(xother));
75 _target = xother._target;
79 _target->add_reference();
84 ensure((*
this) == xother);
85 ensure(( (*
this) != 0 ) ? target_ref_ct(*
this) == old_target_ref_ct+1 :
true);
94 _target->remove_reference();
106 template <
typename T>
107 template <
typename U>
112 return _target == xother._target;
115 template <
typename T>
116 template <
typename U>
121 return _target != xother._target;
124 template <
typename T>
133 define_old_variable(
bool old_same_target = same_target(*
this, xother));
134 define_old_variable(
int old_this_target_ref_ct = target_ref_ct(*
this));
135 define_old_variable(T* old_this_target = _target);
136 define_old_variable(
int old_xother_target_ref_ct = target_ref_ct(xother));
138 if(_target != xother._target)
142 _target->remove_reference();
145 _target = xother._target;
149 _target->add_reference();
155 ensure((*
this) == xother);
157 ensure(old_same_target ?
158 target_ref_ct(*
this) == old_this_target_ref_ct :
161 ensure((!old_same_target && (xother != 0)) ?
162 target_ref_ct(xother) == old_xother_target_ref_ct + 1:
165 ensure((!old_same_target && (old_this_target_ref_ct > 1)) ?
166 old_this_target->ref_ct() == old_this_target_ref_ct - 1 :
172 template <
typename T>
181 define_old_variable(
bool old_same_target = (_target == xtarget));
182 define_old_variable(
size_type old_this_target_ref_ct = target_ref_ct(*
this));
183 define_old_variable(T* old_this_target = _target);
184 define_old_variable(
size_type old_xtarget_ref_ct = (xtarget != 0) ? xtarget->ref_ct() : 0);
186 if(_target != xtarget)
190 _target->remove_reference();
197 _target->add_reference();
203 ensure(*
this == xtarget);
205 ensure(old_same_target ?
206 target_ref_ct(*
this) == old_this_target_ref_ct :
209 ensure((!old_same_target && (xtarget != 0)) ?
210 target_ref_ct(*
this) == old_xtarget_ref_ct + 1 :
213 ensure((!old_same_target) && (old_this_target_ref_ct > 1) ?
214 old_this_target->ref_ct() == old_this_target_ref_ct - 1 :
222 template <
typename T>
229 require((*
this) != 0);
234 template <
typename T>
241 require((*
this) != 0);
248 #endif // ifndef RC_PTR_IMPL_H
friend bool operator==(const rc_ptr &lhs, const T *rhs)
True if and only if the target of lhs is rhs.
T & operator*() const
A reference to the target.
T * operator->() const
A pointer to the target.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
rc_ptr & operator=(const rc_ptr &xother)
Assignment from rc_ptr.
bool operator!() const
Comparison of _target to null; enables if(!rc_ptr) syntax.
friend bool operator!=(const rc_ptr &lhs, const T *rhs)
True if and only if the target of lhs is not rhs.
Namespace for the sheaves component of the sheaf system.
rc_ptr(T *xtarget=0)
Creates a handle for xtarget.
Reference-counted pointer to object of type T. T must be an implementation of concept class rc_any...