14RegPassivePtr::RegPassivePtr(
const RegPassivePtr& f)
17 control_word(f.control_word),
18#elif defined(USE_BIT_FIELDS)
26 s_ban_del(f.s_ban_del),
27 s_ban_sub(f.s_ban_sub),
28 s_ban_cop(f.s_ban_cop),
30 s_allow_del_at_zero_count(f.s_allow_del_at_zero_count),
36 if (f.get_s_ban_cop() == 2)
37#elif defined(USE_BIT_FIELDS)
38 if (f.conparam.s_ban_cop == 2)
44 <<
"RegPassivePtr::RegPassivePtr(const RegPassivePtr& f):\n"
45 <<
"attempt to copy object whose s_ban_cop == 2.\n";
49 else if (f.get_s_ban_cop() == 1 && f.cpp->get_number_of_booked() > 0)
50#elif defined(USE_BIT_FIELDS)
51 else if (f.conparam.s_ban_cop == 1 && f.cpp->get_number_of_booked() > 0)
53 else if (f.s_ban_cop == 1 && f.cpp->get_number_of_booked() > 0)
57 <<
"RegPassivePtr::RegPassivePtr(const RegPassivePtr& f):\n"
58 <<
"attempt to copy referred object whose s_ban_cop == 1.\n"
59 <<
"f.cpp->get_number_of_booked()="
60 << f.cpp->get_number_of_booked() <<
'\n';
65RegPassivePtr& RegPassivePtr::operator=(
const RegPassivePtr& f) {
68 if (f.get_s_ban_cop() == 2)
69#elif defined(USE_BIT_FIELDS)
70 if (f.conparam.s_ban_cop == 2)
76 <<
"RegPassivePtr& RegPassivePtr::operator=(const RegPassivePtr& "
78 <<
"attempt to copy object whose s_ban_cop == 2.\n";
82 else if (f.get_s_ban_cop() == 1 && f.cpp->get_number_of_booked() > 0)
83#elif defined(USE_BIT_FIELDS)
84 else if (f.conparam.s_ban_cop == 1 && f.cpp->get_number_of_booked() > 0)
86 else if (f.s_ban_cop == 1 && f.cpp->get_number_of_booked() > 0)
90 <<
"RegPassivePtr& RegPassivePtr::operator=(const "
91 "RegPassivePtr& f):\n"
92 <<
"attempt to copy referred object whose s_ban_cop == 1.\n"
93 <<
"f.cpp->get_number_of_booked()="
94 << f.cpp->get_number_of_booked() <<
'\n';
98 set_s_ban_cop(f.get_s_ban_cop());
99#ifdef USE_DELETE_AT_ZERO_COUNT
100 set_s_allow_del_at_zero_count(f.get_s_allow_del_at_zero_count());
102 set_s_ban_del(f.get_s_ban_del());
103 if (get_s_ban_sub() == 1)
104#elif defined(USE_BIT_FIELDS)
105 conparam.s_ban_cop = f.conparam.s_ban_cop;
106#ifdef USE_DELETE_AT_ZERO_COUNT
107 conparam.s_allow_del_at_zero_count = f.conparam.s_allow_del_at_zero_count;
109 conparam.s_ban_del = f.conparam.s_ban_del;
110 if (conparam.s_ban_sub == 1)
112 s_ban_cop = f.s_ban_cop;
113#ifdef USE_DELETE_AT_ZERO_COUNT
114 s_allow_del_at_zero_count = f.s_allow_del_at_zero_count;
116 s_ban_del = f.s_ban_del;
121 cpp != NULL && cpp->get_number_of_booked() > 0) {
123 <<
"RegPassivePtr& RegPassivePtr::operator=(const RegPassivePtr& "
125 <<
"self-assignment, s_ban_sub == 1, but the object is addressed.\n"
126 <<
"This can lead to loss of pointers to copied object, not only "
133 else if (get_s_ban_sub() == 2 && cpp != NULL &&
134 cpp->get_number_of_booked() > 0)
135#elif defined(USE_BIT_FIELDS)
136 else if (conparam.s_ban_sub == 2 && cpp != NULL &&
137 cpp->get_number_of_booked() > 0)
139 else if (s_ban_sub == 2 && cpp != NULL &&
140 cpp->get_number_of_booked() > 0)
144 <<
"RegPassivePtr& RegPassivePtr::operator=(const RegPassivePtr& "
146 <<
"s_ban_sub == 2, but the object is addressed.\n";
150 set_s_ban_sub(f.get_s_ban_sub());
151#elif defined(USE_BIT_FIELDS)
152 conparam.s_ban_sub = f.conparam.s_ban_sub;
154 s_ban_sub = f.s_ban_sub;
159int RegPassivePtr::s_print_adr_cpp = 0;
161void RegPassivePtr::print(std::ostream& file,
int l)
const {
162 if (l > 0) file << (*this);
165std::ostream&
operator<<(std::ostream& file,
const RegPassivePtr& f) {
167#ifdef USE_CHAR_GETSETTERS_PARAMETERS
168 Ifile <<
"RegPassivePtr<X>: s_ban_del/sub/cop=" << int(f.get_s_ban_del())
169 <<
"/" << int(f.get_s_ban_sub()) <<
"/" << int(f.get_s_ban_cop());
171 Ifile <<
"RegPassivePtr<X>: s_ban_del/sub/cop=" << f.get_s_ban_del() <<
"/"
172 << f.get_s_ban_sub() <<
"/" << f.get_s_ban_cop();
174#elif defined USE_BIT_FIELDS
175 Ifile <<
"RegPassivePtr<X>: s_ban_del/sub/cop=" << f.conparam.s_ban_del <<
"/"
176 << f.conparam.s_ban_sub <<
"/" << f.conparam.s_ban_cop;
178#ifdef USE_CHAR_CONTROL_VARIABLES
179 Ifile <<
"RegPassivePtr<X>: s_ban_del/sub/cop=" << int(f.s_ban_del) <<
"/"
180 << int(f.s_ban_sub) <<
"/" << int(f.s_ban_cop);
182 Ifile <<
"RegPassivePtr<X>: s_ban_del/sub/cop=" << f.s_ban_del <<
"/"
183 << f.s_ban_sub <<
"/" << f.s_ban_cop;
191 if (RegPassivePtr::s_print_adr_cpp == 0) {
193 file <<
" cpp=NULL\n";
195 file <<
" cpp!=NULL\n";
198 file <<
" cpp=" << f.cpp <<
'\n';
202 Ifile <<
"cpp->number_of_registered=" << f.cpp->get_number_of_booked()
206#ifdef USE_DELETE_AT_ZERO_COUNT
209 Ifile <<
"s_allow_del_at_zero_count="
210#ifdef USE_CHAR_GETSETTERS_PARAMETERS
211 << int(f.get_s_allow_del_at_zero_count()) <<
'\n';
213 << f.get_s_allow_del_at_zero_count() <<
'\n';
215#elif defined(USE_BIT_FIELDS)
216 Ifile <<
"s_allow_del_at_zero_count=" << f.conparam.s_allow_del_at_zero_count
219#ifdef USE_CHAR_CONTROL_VARIABLES
220 Ifile <<
"s_allow_del_at_zero_count=" << int(f.s_allow_del_at_zero_count)
223 Ifile <<
"s_allow_del_at_zero_count=" << f.s_allow_del_at_zero_count <<
'\n';
231long RegPassivePtr::get_total_number_of_references(
void)
const {
235 return cpp->get_number_of_booked();
238int RegPassivePtr::s_ban_del_ignore = 0;
240RegPassivePtr::~RegPassivePtr() {
243 cpp->change_rpp(NULL);
244 if (cpp->get_number_of_booked() == 0) {
249 if (s_ban_del_ignore == 0 && get_s_ban_del() == 1)
250#elif defined(USE_BIT_FIELDS)
251 if (s_ban_del_ignore == 0 && conparam.s_ban_del == 1)
253 if (s_ban_del_ignore == 0 && s_ban_del == 1)
256 mcerr <<
"Error in RegPassivePtr::~RegPassivePtr() "
257 <<
"s_ban_del == 1, but there are pointers to this class.\n";
258 mcerr <<
"cpp->number_of_registered=" << cpp->get_number_of_booked()
260 s_ban_del_ignore = 1;
std::ostream & operator<<(std::ostream &file, const RegPassivePtr &f)
#define USE_DELETE_AT_ZERO_COUNT