23#define USE_DOUBLE_PTR_IN_PASSIVEPTR
33#define USE_DELETE_AT_ZERO_COUNT
60#define COPY_TYPE_CHECK
64#define USE_GETSETTERS_IN_PASSIVEPTR
73#define USE_PRIVATE_PARAM_IN_PASSIVEPTR
77#if defined(USE_PRIVATE_PARAM_IN_PASSIVEPTR) && \
78 !defined(USE_GETSETTERS_IN_PASSIVEPTR)
79"options incompatible\n";
82#define USE_CHAR_CONTROL_VARIABLES
105#if defined(USE_CHAR_CONTROL_VARIABLES) && defined(USE_BIT_FIELDS)
106"options incompatible\n";
108#if defined(USE_CHAR_CONTROL_VARIABLES) && defined(USE_BIT_OPERA)
109"options incompatible\n";
111#if defined(USE_BIT_FIELDS) && defined(USE_BIT_OPERA)
112"options incompatible\n";
115#define USE_CHAR_GETSETTERS_PARAMETERS
122#if defined(USE_CHAR_CONTROL_VARIABLES) && \
123 !defined(USE_CHAR_GETSETTERS_PARAMETERS)
124"options incompatible\n";
133#ifdef DEBUG_ACTIVEPTR
134 mcout <<
"static X* StandardCopyDefinition::copy(const X* f)\n";
138#ifndef COPY_TYPE_CHECK
142#ifdef DEBUG_ACTIVEPTR
143 mcout <<
"X* StandardCopyDefinition::copy(const X* f): f->copy() returned "
145 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
147 mcerr <<
"Type of *p is (in internal notations) " <<
typeid(*p).name()
150 if (
typeid(*p) !=
typeid(*f)) {
151 mcerr <<
"Error in X* StandardCopyDefinition::copy(const X* f): "
152 <<
"typeid(*p) != typeid(*f) \n";
153 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
155 mcerr <<
"Type of *p is (in internal notations) " <<
typeid(*p).name()
157 mcerr <<
"Type of *f is (in internal notations) " <<
typeid(*f).name()
159 mcerr <<
"Possible reason is omiting of copy function in one of the "
160 "derivative classes\n";
204 inline void book(
void);
215 long number_of_booked;
219 if (number_of_booked > LONG_MAX - 1) {
220 mcerr <<
"Error in CountPassivePtr::book(void):\n"
221 <<
" too much booked counters, number_of_booked > LONG_MAX-1, "
222 "number_of_booked=" << number_of_booked <<
'\n';
229 if (number_of_booked < 1) {
230 mcerr <<
"Error in CountPassivePtr::unbook(void):\n"
231 <<
" number_of_booked < 1, number_of_booked=" << number_of_booked
241const unsigned char eb_s_ban_del = 1;
242const unsigned char eb_s_ban_sub1 = 2;
243const unsigned char eb_s_ban_sub2 = 4;
244const unsigned char eb_s_ban_cop1 = 8;
245const unsigned char eb_s_ban_cop2 = 16;
246#ifdef USE_DELETE_AT_ZERO_COUNT
247const unsigned char eb_s_allow_del_at_zero_count = 32;
259 inline static void clear_bit(
unsigned char& cw,
unsigned char b) {
264 inline static void rise_bit(
unsigned char& cw,
unsigned char b) { cw |= b; }
268#elif defined(USE_BIT_FIELDS)
271 unsigned int s_ban_del : 1;
272 unsigned int s_ban_sub : 2;
273 unsigned int s_ban_cop : 2;
274#ifdef USE_DELETE_AT_ZERO_COUNT
275 unsigned int s_allow_del_at_zero_count : 1;
283 s_allow_del_at_zero_count(0)
287#ifdef USE_CHAR_GETSETTERS_PARAMETERS
288 ControlParam(
char fs_ban_del,
char fs_ban_sub,
char fs_ban_cop = 0
291 char fs_allow_del_at_zero_count = 0
296 ControlParam(int fs_ban_del, int fs_ban_sub, int fs_ban_cop = 0
299 int fs_allow_del_at_zero_count = 0
304 s_ban_del(fs_ban_del),
305 s_ban_sub(fs_ban_sub),
306 s_ban_cop(fs_ban_cop)
309 s_allow_del_at_zero_count(fs_allow_del_at_zero_count)
312 if (!(fs_ban_del == 0 || fs_ban_del == 1)) {
313 mcerr <<
"ERROR in ControlParam::ControlParam(...)\n";
314 mcerr <<
"s_ban_del is outside limits, s_ban_del=" << fs_ban_del
318 if (fs_ban_sub < 0 || fs_ban_sub > 2) {
319 mcerr <<
"ERROR in ControlParam::ControlParam(...):\n";
320 mcerr <<
"s_ban_sub is outside limits, s_ban_sub=" << fs_ban_sub
324 if (fs_ban_cop < 0 || fs_ban_cop > 2) {
325 mcerr <<
"ERROR in ControlParam::ControlParam(...):\n";
326 mcerr <<
"s_ban_cop is outside limits, s_ban_cop=" << fs_ban_cop
330#ifdef USE_DELETE_AT_ZERO_COUNT
331 if (!(s_allow_del_at_zero_count == 0 || s_allow_del_at_zero_count == 1)) {
332 mcerr <<
"ERROR in ControlParam::ControlParam(...)\n";
333 mcerr <<
"s_allow_del_at_zero_count is outside limits, "
334 "s_allow_del_at_zero_count=" << fs_allow_del_at_zero_count
347#elif defined USE_BIT_FIELDS
354 s_allow_del_at_zero_count(0),
359#ifdef USE_CHAR_GETSETTERS_PARAMETERS
363 inline
RegPassivePtr(int fs_ban_del, int fs_ban_sub, int fs_ban_cop = 0)
368#elif defined(USE_BIT_FIELDS)
369 conparam(fs_ban_del, fs_ban_sub, fs_ban_cop),
371 s_ban_del(fs_ban_del), s_ban_sub(fs_ban_sub), s_ban_cop(fs_ban_cop),
373 s_allow_del_at_zero_count(0),
399 if (cpp) cpp->change_rpp(NULL);
409 virtual void print(std::ostream& file,
int l = 1)
const;
423 unsigned char control_word;
426#ifdef USE_PRIVATE_PARAM_IN_PASSIVEPTR
429 static int s_ban_del_ignore;
430 static int s_print_adr_cpp;
431#ifdef USE_PRIVATE_PARAM_IN_PASSIVEPTR
435#elif defined(USE_BIT_FIELDS)
437 ControlParam conparam;
440#ifdef USE_PRIVATE_PARAM_IN_PASSIVEPTR
443 static int s_ban_del_ignore;
444 static int s_print_adr_cpp;
445#ifdef USE_PRIVATE_PARAM_IN_PASSIVEPTR
451#ifdef USE_PRIVATE_PARAM_IN_PASSIVEPTR
454#ifdef USE_CHAR_CONTROL_VARIABLES
466 static int s_ban_del_ignore;
473#ifdef USE_CHAR_CONTROL_VARIABLES
493#ifdef USE_CHAR_CONTROL_VARIABLES
505#ifdef USE_DELETE_AT_ZERO_COUNT
506#ifdef USE_CHAR_CONTROL_VARIABLES
507 char s_allow_del_at_zero_count;
509 int s_allow_del_at_zero_count;
519 static int s_print_adr_cpp;
527#ifdef USE_PRIVATE_PARAM_IN_PASSIVEPTR
533#ifdef USE_GETSETTERS_IN_PASSIVEPTR
535#ifdef USE_CHAR_GETSETTERS_PARAMETERS
543 clear_bit(control_word, eb_s_ban_del);
544 else if (fs_ban_del == 1)
545 rise_bit(control_word, eb_s_ban_del);
547 if (fs_ban_del == 0 || fs_ban_del == 1) {
549 conparam.s_ban_del = fs_ban_del;
551 s_ban_del = fs_ban_del;
556 mcerr <<
"ERROR in inline void set_s_ban_del(int fs_ban_del):\n";
557 mcerr <<
"s_ban_del is outside limits, s_ban_del=" << int(fs_ban_del)
563#ifdef USE_CHAR_GETSETTERS_PARAMETERS
570 if ((control_word & eb_s_ban_del) != 0)
575#elif defined(USE_BIT_FIELDS)
577 return conparam.s_ban_del;
580 {
return s_ban_del; }
583#ifdef USE_CHAR_GETSETTERS_PARAMETERS
589 if (fs_ban_del_ignore == 0 || fs_ban_del_ignore == 1) {
590 s_ban_del_ignore = fs_ban_del_ignore;
592 mcerr <<
"ERROR in inline void set_s_ban_del_ignore(int "
593 "fs_ban_del_ignore ):\n";
594 mcerr <<
"s_ban_del_ignore is outside limits, s_ban_del_ignore="
595 << int(fs_ban_del_ignore) <<
'\n';
600#ifdef USE_CHAR_GETSETTERS_PARAMETERS
606 return s_ban_del_ignore;
609#ifdef USE_CHAR_GETSETTERS_PARAMETERS
616 if (fs_ban_sub == 0) {
617 clear_bit(control_word, eb_s_ban_sub1);
618 clear_bit(control_word, eb_s_ban_sub2);
619 }
else if (fs_ban_sub == 1) {
620 rise_bit(control_word, eb_s_ban_sub1);
621 clear_bit(control_word, eb_s_ban_sub2);
622 }
else if (fs_ban_sub == 2) {
623 clear_bit(control_word, eb_s_ban_sub1);
624 rise_bit(control_word, eb_s_ban_sub2);
627 if (fs_ban_sub >= 0 && fs_ban_sub <= 2) {
629 conparam.s_ban_sub = fs_ban_sub;
631 s_ban_sub = fs_ban_sub;
636 mcerr <<
"ERROR in inline void set_s_ban_sub(int fs_ban_sub):\n";
637 mcerr <<
"s_ban_sub is outside limits, s_ban_sub=" << int(fs_ban_sub)
643#ifdef USE_CHAR_GETSETTERS_PARAMETERS
650 if ((control_word & eb_s_ban_sub2) == 0) {
651 if ((control_word & eb_s_ban_sub1) == 0)
661#elif defined(USE_BIT_FIELDS)
663 return conparam.s_ban_sub;
666 {
return s_ban_sub; }
669#ifdef USE_CHAR_GETSETTERS_PARAMETERS
676 if (fs_ban_cop == 0) {
677 clear_bit(control_word, eb_s_ban_cop1);
678 clear_bit(control_word, eb_s_ban_cop2);
679 }
else if (fs_ban_cop == 1) {
680 rise_bit(control_word, eb_s_ban_cop1);
681 clear_bit(control_word, eb_s_ban_cop2);
682 }
else if (fs_ban_cop == 2) {
683 clear_bit(control_word, eb_s_ban_cop1);
684 rise_bit(control_word, eb_s_ban_cop2);
687 if (fs_ban_cop >= 0 && fs_ban_cop <= 2) {
689 conparam.s_ban_cop = fs_ban_cop;
691 s_ban_cop = fs_ban_cop;
696 mcerr <<
"ERROR in inline void set_s_ban_cop(int fs_ban_cop):\n";
697 mcerr <<
"s_ban_cop is outside limits, s_ban_cop=" << int(fs_ban_cop)
703#ifdef USE_CHAR_GETSETTERS_PARAMETERS
710 if ((control_word & eb_s_ban_cop2) == 0) {
711 if ((control_word & eb_s_ban_cop1) == 0)
719#elif defined USE_BIT_FIELDS
721 return conparam.s_ban_cop;
724 {
return s_ban_cop; }
727#ifdef USE_DELETE_AT_ZERO_COUNT
729#ifdef USE_CHAR_GETSETTERS_PARAMETERS
736 if (fs_allow_del_at_zero_count == 0)
737 clear_bit(control_word, eb_s_allow_del_at_zero_count);
738 else if (fs_allow_del_at_zero_count == 1)
739 rise_bit(control_word, eb_s_allow_del_at_zero_count);
741 if (fs_allow_del_at_zero_count == 0 || fs_allow_del_at_zero_count == 1) {
743 conparam.s_allow_del_at_zero_count = fs_allow_del_at_zero_count;
745 s_allow_del_at_zero_count = fs_allow_del_at_zero_count;
750 mcerr <<
"ERROR in inline void set_s_allow_del_at_zero_count(int "
751 "fs_allow_del_at_zero_count):\n";
752 mcerr <<
"s_allow_del_at_zero_count is outside limits, "
753 "s_allow_del_at_zero_count=" << int(fs_allow_del_at_zero_count)
759#ifdef USE_CHAR_GETSETTERS_PARAMETERS
766 if ((control_word & eb_s_allow_del_at_zero_count) != 0)
771#elif defined(USE_BIT_FIELDS)
773 return conparam.s_allow_del_at_zero_count;
776 {
return s_allow_del_at_zero_count; }
781#ifdef USE_CHAR_GETSETTERS_PARAMETERS
787 if (fs_print_adr_cpp == 0 || fs_print_adr_cpp == 1) {
788 s_print_adr_cpp = fs_print_adr_cpp;
790 mcerr <<
"ERROR in inline void set_s_print_adr_cpp(int fs_print_adr_cpp "
792 mcerr <<
"s_print_adr_cpp is outside limits, s_print_adr_cpp="
793 << int(fs_print_adr_cpp) <<
'\n';
798#ifdef USE_CHAR_GETSETTERS_PARAMETERS
804 return s_print_adr_cpp;
816 if (number_of_booked != 0) {
817 mcerr <<
"Error in CountPassivePtr::~CountPassivePtr():\n"
818 <<
" number_of_booked != 0, number_of_booked=" << number_of_booked
823 mcerr <<
"rpp = NULL\n";
826 if (rpp != NULL) rpp->cpp = NULL;
#define USE_DELETE_AT_ZERO_COUNT
Counter of protected pointers.
long get_number_of_booked(void)
void change_rpp(const RegPassivePtr *frpp)
const RegPassivePtr * get_rpp(void)
CountPassivePtr(const RegPassivePtr *frpp)
static char get_s_ban_del_ignore(void)
void clear_pointers(void) const
static void set_s_ban_del_ignore(char fs_ban_del_ignore)
static void set_s_print_adr_cpp(char fs_print_adr_cpp)
virtual void print(std::ostream &file, int l=1) const
static char get_s_print_adr_cpp(void)
RegPassivePtr & operator=(const RegPassivePtr &f)
char get_s_allow_del_at_zero_count(void) const
void set_s_ban_cop(char fs_ban_cop)
RegPassivePtr(char fs_ban_del, char fs_ban_sub, char fs_ban_cop=0)
void set_s_allow_del_at_zero_count(char fs_allow_del_at_zero_count)
char get_s_ban_sub(void) const
virtual RegPassivePtr * copy() const
friend std::ostream & operator<<(std::ostream &file, const RegPassivePtr &f)
void set_s_ban_sub(char fs_ban_sub)
char get_s_ban_cop(void) const
void set_s_ban_del(char fs_ban_del)
char get_s_ban_del(void) const
CountPP_ns::CountPassivePtr * book(void) const
long get_total_number_of_references(void) const
static X * copy(const X *f)