27#ifdef USE_REPLACE_ALLOC
41#define USE_DOUBLE_PTR_IN_PASSIVEPTR
50#define USE_DELETE_AT_ZERO_COUNT
82#define COPY_TYPE_CHECK
142#define PILF_CONST const
143#define PILF_MUTABLE mutable
156#define USE_GETSETTERS_IN_PASSIVEPTR
165#define USE_PRIVATE_PARAM_IN_PASSIVEPTR
169#if defined(USE_PRIVATE_PARAM_IN_PASSIVEPTR) && \
170 !defined(USE_GETSETTERS_IN_PASSIVEPTR)
171"options incompatible\n";
174#define USE_CHAR_CONTROL_VARIABLES
197#if defined(USE_CHAR_CONTROL_VARIABLES) && defined(USE_BIT_FIELDS)
198"options incompatible\n";
200#if defined(USE_CHAR_CONTROL_VARIABLES) && defined(USE_BIT_OPERA)
201"options incompatible\n";
203#if defined(USE_BIT_FIELDS) && defined(USE_BIT_OPERA)
204"options incompatible\n";
207#define USE_CHAR_GETSETTERS_PARAMETERS
214#if defined(USE_CHAR_CONTROL_VARIABLES) && \
215 !defined(USE_CHAR_GETSETTERS_PARAMETERS)
216"options incompatible\n";
219#ifdef COPY_RETURNS_COMMON_BASE
225 virtual ~CommonBase() {}
230#define virt_common_base \
233#define virt_common_base_col :public virtual CommonBase
234#define virt_common_base_comma \
237#define virt_common_base_col_comma :public virtual CommonBase,
238#define virt_common_base_pcomma , public virtual CommonBase
241#define virt_common_base
242#define virt_common_base_col
243#define virt_common_base_comma
244#define virt_common_base_col_comma
245#define virt_common_base_pcomma
258#ifndef COPY_RETURNS_COMMON_BASE
260#define AbsCont_copy(type) \
261 virtual type* copy(void) const { return new type(*this); }
262#define AnyType_copy(derived_type, base_type) \
263 virtual derived_type* copy(void) const { return new derived_type(*this); }
266#define AbsCont_copy(type) \
267 virtual CommonBase* copy(void) const { return new type(*this); }
268#define AnyType_copy(derived_type, base_type) \
269 virtual CommonBase* copy(void) const { return new derived_type(*this); }
273#ifndef COPY_RETURNS_COMMON_BASE
282 virtual void print(std::ostream& file,
int l)
const {
283 Ifile <<
"AbsCont::print is called, l=" << l <<
"\n";
293#define macro_copy_total(type) \
294 virtual type* copy(void) const { return new type(*this); }
295#define macro_copy_total_zero(type) virtual type* copy(void) const = 0
296#define macro_copy_header(type) virtual type* copy(void) const
297#define macro_copy_body(type) \
298 type* type::copy(void) const { return new type(*this); }
299#define macro_copy_body_not_defined(type) \
300 type* type::copy(void) const { \
301 mcerr << "macro_copy_body_not_defined(" << #type << "): forbidden call\n"; \
314 virtual CommonBase*
copy(
void)
const = 0;
315 virtual void print(std::ostream& file,
int l)
const {
316 Ifile <<
"AbsCont::print is called, l=" << l <<
"\n";
322#define macro_copy_total(type) \
323 virtual CommonBase* copy(void) const { return new type(*this); }
324#define macro_copy_total_zero(type) virtual CommonBase* copy(void) const = 0
325#define macro_copy_header(type) virtual CommonBase* copy(void) const;
326#define macro_copy_body(type) \
327 CommonBase* type::copy(void) const { return new type(*this); }
328#define macro_copy_body_not_defined(type) \
329 CommonBase* type::copy(void) const { \
330 mcerr << "macro_copy_body_not_defined(" << #type << "): forbidden call\n"; \
338 Ifile <<
"operator<<AbsCont& is called.\n";
354#ifdef DEBUG_ACTIVEPTR
355 mcout <<
"static X* StandardCopyDefinition::copy(const X* f)\n";
359#ifndef COPY_TYPE_CHECK
360#ifndef COPY_RETURNS_COMMON_BASE
363 X* ptr =
dynamic_cast<X*
>(f->copy());
365 mcerr <<
"Error in X* StandardCopyDefinition::copy(const X* f): "
366 <<
"cannot convert pointer returned from f->copy()"
367 <<
"to type " <<
typeid(X).name() <<
'\n';
386#ifdef DEBUG_ACTIVEPTR
387 mcout <<
"X* StandardCopyDefinition::copy(const X* f): f->copy() returned "
389 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
391 mcerr <<
"Type of *p is (in internal notations) " <<
typeid(*p).name()
394 if (
typeid(*p) !=
typeid(*f)) {
395 mcerr <<
"Error in X* StandardCopyDefinition::copy(const X* f): "
396 <<
"typeid(*p) != typeid(*f) \n";
397 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
399 mcerr <<
"Type of *p is (in internal notations) " <<
typeid(*p).name()
401 mcerr <<
"Type of *f is (in internal notations) " <<
typeid(*f).name()
403 mcerr <<
"Possible reason is omiting of copy function in one of the "
404 "derivative classes\n";
483#ifdef DEBUG_ACTIVEPTR
484 mcout <<
"static X* CopyDefinitionWithoutInheritance::copy(const X* f)\n";
506#define USE_OLD_POINTER_NAMES
507#ifdef USE_OLD_POINTER_NAMES
509#define AutoCont ActivePtr
522template <
class X,
class C = StandardCopyDefinition<X> >
536#ifdef IMPLICIT_X_STAR
537 inline operator X*(void)
const;
541 inline X*
get(
void)
const {
return ptr; }
551 inline void put(
const X* fptr)
555#ifdef DEBUG_ACTIVEPTR
556 mcout <<
"inline void put(const X* fptr)\n";
558 mcout <<
"Type of X is (in internal notations) " <<
typeid(X).name()
560 mcout <<
"Type of *fptr is (in internal notations) " <<
typeid(*fptr).name()
566 X* ptr_temp = (fptr != NULL ? C::copy(fptr) : (X*)(NULL));
567 if (ptr != NULL)
delete ptr;
569#ifdef DEBUG_ACTIVEPTR
570 mcout <<
"finishing inline void put(const X* fptr):\n";
588 mcerr <<
"ERROR in ActivePtr::pass(X* fptr):\n";
589 mcerr <<
"Both the destination and source pointers are not empty\n";
610#ifdef DEBUG_ACTIVEPTR
611 mcout <<
"ActivePtr::clear is called, ptr =" << ptr <<
'\n';
622#ifdef DEBUG_ACTIVEPTR
623 mcout <<
"ActivePtr::pilfer is called\n";
628 mcerr <<
"ERROR in ActivePtr::pilfer(...):\n";
629 mcerr <<
"Both the destination and source pointers are not empty\n";
645 void print(std::ostream& file,
int l = 1)
const;
660 : ptr(fptr != NULL ? C::copy(fptr) : ((X*)NULL))
661#ifndef DEBUG_ACTIVEPTR
666 mcout <<
"ActivePtr(const X* fptr, Clone) is finished, ptr =" << ptr
669 cout <<
"deleted, exit\n";
678 : ptr(f.ptr != NULL ? C::copy(f.ptr) : f.ptr)
679#ifndef DEBUG_ACTIVEPTR
684 mcout <<
"ActivePtr(const ActivePtr<X,C>& f) is finished\n";
691#ifdef DEBUG_ACTIVEPTR
692 mcout <<
"ActivePtr(const ActivePtr<X,C>& f, Pilfer) is run\n";
701#ifdef DEBUG_ACTIVEPTR
702 mcout <<
"inline ActivePtr& operator=(const ActivePtr<X,C>& f)\n";
704 if (
this != &f) put(f.ptr);
731#ifdef USE_REPLACE_ALLOC
740template <
class X,
class C>
741void ActivePtr<X, C>::print(std::ostream& file,
int l)
const {
743 Ifile <<
"ActivePtr<X,C>: ";
745 file <<
" ptr==NULL. \n";
747 file <<
" ptr!=NULL: ";
765template <
class X,
class C>
766 std::ostream&
operator<<(std::ostream& file,
const ActivePtr<X, C>& f) {
767 Ifile <<
"ActivePtr<X,C>: ";
769 file <<
" ptr==NULL. \n";
771 file <<
" ptr!=NULL: ";
792template <
class X,
class C>
793 std::istream&
operator>>(std::istream& file, ActivePtr<X, C>& f) {
797 for (n = 0; n < q - 1; n++) {
798 keyline[n] = file.get();
801 if (!strcmp(&(keyline[0]),
" ptr==NULL. ")) {
827template <
class X,
class C>
inline X* ActivePtr<X, C>::operator->(
void)
const {
828#ifdef SKIP_CHECKS_NULL
831 if (ptr != NULL)
return ptr;
832 mcerr <<
"Error in X* ActivePtr<X,C>::operator->(void) const: "
834 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name() <<
'\n';
840template <
class X,
class C>
inline X& ActivePtr<X, C>::operator*(
void)
const {
841#ifdef SKIP_CHECKS_NULL
844 if (ptr != NULL)
return *ptr;
845 mcerr <<
"Error in X& ActivePtr<X,C>::operator*(void) const: "
847 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name() <<
'\n';
852template <
class X,
class C>
inline X* ActivePtr<X, C>::getver(
void)
const {
853#ifdef SKIP_CHECKS_NULL
856 if (ptr != NULL)
return ptr;
857 mcerr <<
"Error in X* ActivePtr<X,C>::getver(void) const: "
859 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name() <<
'\n';
864#ifdef IMPLICIT_X_STAR
865template <
class X,
class C>
inline ActivePtr<X, C>::operator X*(void)
const {
866#ifdef SKIP_CHECKS_NULL
869 if (ptr != NULL)
return ptr;
870 mcerr <<
"Error in ActivePtr<X,C>::operator X*(void) const: "
872 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name() <<
'\n';
878template <
class X,
class C>
879inline void exchange(ActivePtr<X, C>& f1, ActivePtr<X, C>& f2) {
880 X* ptr = f1.extract();
881 f1.pass(f2.extract());
885#ifdef INCLUDE_ActivePtrWI
892#define USE_OLD_POINTER_NAMES
893#ifdef USE_OLD_POINTER_NAMES
895#define AutoPtr ActivePtrWI
900template <
class X>
class ActivePtrWI {
902 inline X* get(
void)
const {
return ptr; }
903 inline void put(
const X* fptr)
911 if (fptr != NULL) ptr =
new X(*fptr);
913 inline void pass(X* fptr)
918 if (ptr != NULL)
delete ptr;
921 void print(std::ostream& file,
int l = 1)
const;
922 inline ActivePtrWI(
void) : ptr(NULL) {}
923 inline ActivePtrWI(
const X* fptr)
924 : ptr(fptr != NULL ? new X(*fptr) : ((X*)NULL)) {}
927 inline ActivePtrWI(
const ActivePtrWI<X>& f) : ptr(NULL) {
928 if (f.ptr != NULL) ptr =
new X(*(f.ptr));
930 inline ActivePtrWI& operator=(
const ActivePtrWI<X>& f) {
931 if (
this != &f) put(f.ptr);
934 inline X* operator->(
void)
const;
936#ifdef IMPLICIT_X_STAR
937 operator X*(void)
const;
939 virtual ~ActivePtrWI() {
940 if (ptr != NULL)
delete ptr;
945#ifdef USE_REPLACE_ALLOC
950template <
class X>
inline X* ActivePtrWI<X>::operator->(
void)
const {
951#ifdef SKIP_CHECKS_NULL
954 if (ptr != NULL)
return ptr;
955 mcerr <<
"Error in X* ActivePtrWI<X>::operator->(void) const: "
957 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name() <<
'\n';
962template <
class X>
inline X& ActivePtrWI<X>::operator*(
void)
const {
963#ifdef SKIP_CHECKS_NULL
966 if (ptr != NULL)
return *ptr;
967 mcerr <<
"Error in X& ActivePtrWI<X>::operator*(void) const: "
969 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name() <<
'\n';
975#ifdef IMPLICIT_X_STAR
976template <
class X> ActivePtrWI<X>::operator X*(void)
const {
977#ifdef SKIP_CHECKS_NULL
980 if (ptr != NULL)
return ptr;
981 mcerr <<
"Error in ActivePtrWI<X>::operator X*(void) const: "
983 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name() <<
'\n';
990template <
class X>
void ActivePtrWI<X>::print(std::ostream& file,
int l)
const {
992 Ifile <<
"ActivePtrWI<X>:";
994 file <<
" pointer in NULL, no object.\n";
1002 std::ostream&
operator<<(std::ostream& file,
const ActivePtrWI<X>& f) {
1003 Ifile <<
"ActivePtrWI<X>:";
1004 if (f.get() == NULL)
1005 file <<
" pointer in NULL, no object\n";
1016#define USE_OLD_POINTER_NAMES
1017#ifdef USE_OLD_POINTER_NAMES
1019#define ProtPtr PassivePtr
1020#define RegProtPtr RegPassivePtr
1021#define CountProtPtr CountPassivePtr
1037 inline void book(
void);
1038 inline void unbook(
void);
1040 inline const RegPassivePtr*
get_rpp(
void) {
return rpp; }
1041 inline void change_rpp(
const RegPassivePtr* frpp) { rpp = frpp; }
1044 const RegPassivePtr* rpp;
1048 long number_of_booked;
1049#ifdef USE_REPLACE_ALLOC
1055 if (number_of_booked > LONG_MAX - 1) {
1056 mcerr <<
"Error in CountPassivePtr::book(void):\n"
1057 <<
" too much booked counters, number_of_booked > LONG_MAX-1, "
1058 "number_of_booked=" << number_of_booked <<
'\n';
1065 if (number_of_booked < 1) {
1066 mcerr <<
"Error in CountPassivePtr::unbook(void):\n"
1067 <<
" number_of_booked < 1, number_of_booked=" << number_of_booked
1079const unsigned char eb_s_ban_del = 1;
1080const unsigned char eb_s_ban_sub1 = 2;
1081const unsigned char eb_s_ban_sub2 = 4;
1082const unsigned char eb_s_ban_cop1 = 8;
1083const unsigned char eb_s_ban_cop2 = 16;
1084#ifdef USE_DELETE_AT_ZERO_COUNT
1085const unsigned char eb_s_allow_del_at_zero_count = 32;
1107 inline static void clear_bit(
unsigned char& cw,
unsigned char b) {
1108 if ((cw & b) != 0) {
1112 inline static void rise_bit(
unsigned char& cw,
unsigned char b) { cw |= b; }
1116#elif defined(USE_BIT_FIELDS)
1117 class ControlParam {
1119 unsigned int s_ban_del : 1;
1120 unsigned int s_ban_sub : 2;
1121 unsigned int s_ban_cop : 2;
1122#ifdef USE_DELETE_AT_ZERO_COUNT
1123 unsigned int s_allow_del_at_zero_count : 1;
1131 s_allow_del_at_zero_count(0)
1135#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1136 ControlParam(
char fs_ban_del,
char fs_ban_sub,
char fs_ban_cop = 0
1139 char fs_allow_del_at_zero_count = 0
1144 ControlParam(int fs_ban_del, int fs_ban_sub, int fs_ban_cop = 0
1147 int fs_allow_del_at_zero_count = 0
1152 s_ban_del(fs_ban_del),
1153 s_ban_sub(fs_ban_sub),
1154 s_ban_cop(fs_ban_cop)
1157 s_allow_del_at_zero_count(fs_allow_del_at_zero_count)
1160 if (!(fs_ban_del == 0 || fs_ban_del == 1)) {
1161 mcerr <<
"ERROR in ControlParam::ControlParam(...)\n";
1162 mcerr <<
"s_ban_del is outside limits, s_ban_del=" << fs_ban_del
1166 if (fs_ban_sub < 0 || fs_ban_sub > 2) {
1167 mcerr <<
"ERROR in ControlParam::ControlParam(...):\n";
1168 mcerr <<
"s_ban_sub is outside limits, s_ban_sub=" << fs_ban_sub
1172 if (fs_ban_cop < 0 || fs_ban_cop > 2) {
1173 mcerr <<
"ERROR in ControlParam::ControlParam(...):\n";
1174 mcerr <<
"s_ban_cop is outside limits, s_ban_cop=" << fs_ban_cop
1178#ifdef USE_DELETE_AT_ZERO_COUNT
1179 if (!(s_allow_del_at_zero_count == 0 || s_allow_del_at_zero_count == 1)) {
1180 mcerr <<
"ERROR in ControlParam::ControlParam(...)\n";
1181 mcerr <<
"s_allow_del_at_zero_count is outside limits, "
1182 "s_allow_del_at_zero_count=" << fs_allow_del_at_zero_count
1196#elif defined USE_BIT_FIELDS
1203 s_allow_del_at_zero_count(0),
1208#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1212 inline RegPassivePtr(int fs_ban_del, int fs_ban_sub, int fs_ban_cop = 0)
1217#elif defined(USE_BIT_FIELDS)
1218 conparam(fs_ban_del, fs_ban_sub, fs_ban_cop),
1220 s_ban_del(fs_ban_del),
1221 s_ban_sub(fs_ban_sub),
1222 s_ban_cop(fs_ban_cop),
1224 s_allow_del_at_zero_count(0),
1229 set_s_ban_del(fs_ban_del);
1230 set_s_ban_sub(fs_ban_sub);
1231 set_s_ban_cop(fs_ban_cop);
1254 if (cpp != NULL) cpp->change_rpp(NULL);
1264 virtual void print(std::ostream& file,
int l = 1)
const;
1265 friend std::ostream&
operator<<(std::ostream& file,
const RegPassivePtr& f);
1278 unsigned char control_word;
1281#ifdef USE_PRIVATE_PARAM_IN_PASSIVEPTR
1284 static int s_ban_del_ignore;
1285 static int s_print_adr_cpp;
1286#ifdef USE_PRIVATE_PARAM_IN_PASSIVEPTR
1290#elif defined(USE_BIT_FIELDS)
1292 ControlParam conparam;
1295#ifdef USE_PRIVATE_PARAM_IN_PASSIVEPTR
1298 static int s_ban_del_ignore;
1299 static int s_print_adr_cpp;
1300#ifdef USE_PRIVATE_PARAM_IN_PASSIVEPTR
1306#ifdef USE_PRIVATE_PARAM_IN_PASSIVEPTR
1309#ifdef USE_CHAR_CONTROL_VARIABLES
1321 static int s_ban_del_ignore;
1328#ifdef USE_CHAR_CONTROL_VARIABLES
1348#ifdef USE_CHAR_CONTROL_VARIABLES
1360#ifdef USE_DELETE_AT_ZERO_COUNT
1361#ifdef USE_CHAR_CONTROL_VARIABLES
1362 char s_allow_del_at_zero_count;
1364 int s_allow_del_at_zero_count;
1374 static int s_print_adr_cpp;
1382#ifdef USE_PRIVATE_PARAM_IN_PASSIVEPTR
1388#ifdef USE_GETSETTERS_IN_PASSIVEPTR
1391#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1394 inline void set_s_ban_del(
int fs_ban_del)
1398 if (fs_ban_del == 0)
1399 clear_bit(control_word, eb_s_ban_del);
1400 else if (fs_ban_del == 1)
1401 rise_bit(control_word, eb_s_ban_del);
1403 if (fs_ban_del == 0 || fs_ban_del == 1) {
1404#ifdef USE_BIT_FIELDS
1405 conparam.s_ban_del = fs_ban_del;
1407 s_ban_del = fs_ban_del;
1412 mcerr <<
"ERROR in inline void set_s_ban_del(int fs_ban_del):\n";
1413 mcerr <<
"s_ban_del is outside limits, s_ban_del=" << int(fs_ban_del)
1419#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1422 inline int get_s_ban_del(
void)
const
1426 if ((control_word & eb_s_ban_del) != 0)
1431#elif defined(USE_BIT_FIELDS)
1432 {
return conparam.s_ban_del; }
1434 {
return s_ban_del; }
1437#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1440 inline static void set_s_ban_del_ignore(
int fs_ban_del_ignore)
1443 if (fs_ban_del_ignore == 0 || fs_ban_del_ignore == 1) {
1444 s_ban_del_ignore = fs_ban_del_ignore;
1446 mcerr <<
"ERROR in inline void set_s_ban_del_ignore(int "
1447 "fs_ban_del_ignore ):\n";
1448 mcerr <<
"s_ban_del_ignore is outside limits, s_ban_del_ignore="
1449 << int(fs_ban_del_ignore) <<
'\n';
1454#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1457 inline static int get_s_ban_del_ignore(
void)
1460 return s_ban_del_ignore;
1463#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1466 inline void set_s_ban_sub(
int fs_ban_sub)
1470 if (fs_ban_sub == 0) {
1471 clear_bit(control_word, eb_s_ban_sub1);
1472 clear_bit(control_word, eb_s_ban_sub2);
1473 }
else if (fs_ban_sub == 1) {
1474 rise_bit(control_word, eb_s_ban_sub1);
1475 clear_bit(control_word, eb_s_ban_sub2);
1476 }
else if (fs_ban_sub == 2) {
1477 clear_bit(control_word, eb_s_ban_sub1);
1478 rise_bit(control_word, eb_s_ban_sub2);
1481 if (fs_ban_sub >= 0 && fs_ban_sub <= 2) {
1482#ifdef USE_BIT_FIELDS
1483 conparam.s_ban_sub = fs_ban_sub;
1485 s_ban_sub = fs_ban_sub;
1490 mcerr <<
"ERROR in inline void set_s_ban_sub(int fs_ban_sub):\n";
1491 mcerr <<
"s_ban_sub is outside limits, s_ban_sub=" << int(fs_ban_sub)
1497#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1500 inline int get_s_ban_sub(
void)
const
1504 if ((control_word & eb_s_ban_sub2) == 0) {
1505 if ((control_word & eb_s_ban_sub1) == 0)
1515#elif defined(USE_BIT_FIELDS)
1516 {
return conparam.s_ban_sub; }
1518 {
return s_ban_sub; }
1521#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1524 inline void set_s_ban_cop(
int fs_ban_cop)
1528 if (fs_ban_cop == 0) {
1529 clear_bit(control_word, eb_s_ban_cop1);
1530 clear_bit(control_word, eb_s_ban_cop2);
1531 }
else if (fs_ban_cop == 1) {
1532 rise_bit(control_word, eb_s_ban_cop1);
1533 clear_bit(control_word, eb_s_ban_cop2);
1534 }
else if (fs_ban_cop == 2) {
1535 clear_bit(control_word, eb_s_ban_cop1);
1536 rise_bit(control_word, eb_s_ban_cop2);
1539 if (fs_ban_cop >= 0 && fs_ban_cop <= 2) {
1540#ifdef USE_BIT_FIELDS
1541 conparam.s_ban_cop = fs_ban_cop;
1543 s_ban_cop = fs_ban_cop;
1548 mcerr <<
"ERROR in inline void set_s_ban_cop(int fs_ban_cop):\n";
1549 mcerr <<
"s_ban_cop is outside limits, s_ban_cop=" << int(fs_ban_cop)
1555#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1558 inline int get_s_ban_cop(
void)
const
1562 if ((control_word & eb_s_ban_cop2) == 0) {
1563 if ((control_word & eb_s_ban_cop1) == 0)
1571#elif defined USE_BIT_FIELDS
1572 {
return conparam.s_ban_cop; }
1574 {
return s_ban_cop; }
1577#ifdef USE_DELETE_AT_ZERO_COUNT
1579#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1582 inline void set_s_allow_del_at_zero_count(
int fs_allow_del_at_zero_count)
1586 if (fs_allow_del_at_zero_count == 0)
1587 clear_bit(control_word, eb_s_allow_del_at_zero_count);
1588 else if (fs_allow_del_at_zero_count == 1)
1589 rise_bit(control_word, eb_s_allow_del_at_zero_count);
1591 if (fs_allow_del_at_zero_count == 0 || fs_allow_del_at_zero_count == 1) {
1592#ifdef USE_BIT_FIELDS
1593 conparam.s_allow_del_at_zero_count = fs_allow_del_at_zero_count;
1595 s_allow_del_at_zero_count = fs_allow_del_at_zero_count;
1600 mcerr <<
"ERROR in inline void set_s_allow_del_at_zero_count(int "
1601 "fs_allow_del_at_zero_count):\n";
1602 mcerr <<
"s_allow_del_at_zero_count is outside limits, "
1603 "s_allow_del_at_zero_count=" << int(fs_allow_del_at_zero_count)
1609#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1612 inline int get_s_allow_del_at_zero_count(
void)
const
1616 if ((control_word & eb_s_allow_del_at_zero_count) != 0)
1621#elif defined(USE_BIT_FIELDS)
1622 {
return conparam.s_allow_del_at_zero_count; }
1624 {
return s_allow_del_at_zero_count; }
1629#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1632 inline static void set_s_print_adr_cpp(
int fs_print_adr_cpp)
1635 if (fs_print_adr_cpp == 0 || fs_print_adr_cpp == 1) {
1636 s_print_adr_cpp = fs_print_adr_cpp;
1638 mcerr <<
"ERROR in inline void set_s_print_adr_cpp(int fs_print_adr_cpp "
1640 mcerr <<
"s_print_adr_cpp is outside limits, s_print_adr_cpp="
1641 << int(fs_print_adr_cpp) <<
'\n';
1646#ifdef USE_CHAR_GETSETTERS_PARAMETERS
1649 inline static int get_s_print_adr_cpp(
void)
1652 return s_print_adr_cpp;
1661#ifdef USE_REPLACE_ALLOC
1667 if (number_of_booked != 0) {
1668 mcerr <<
"Error in CountPassivePtr::~CountPassivePtr():\n"
1669 <<
" number_of_booked != 0, number_of_booked=" << number_of_booked
1674 mcerr <<
"rpp = NULL\n";
1677 if (rpp != NULL) rpp->cpp = NULL;
1682 friend class RegPassivePtr;
1685 if (cpp == NULL)
return NULL;
1686#ifdef USE_DOUBLE_PTR_IN_PASSIVEPTR
1688 if (cpp->get_rpp() == NULL)
return NULL;
1689#ifdef USE_CHECK_DOUBLE_PTR_IN_PASSIVEPTR
1690 X* temp_ptr =
dynamic_cast<X*
>(
const_cast<RegPassivePtr*
>(cpp->get_rpp()));
1691 if (ptr != temp_ptr) {
1692 mcerr <<
"Error in inline X* PassivePtr::get(void):\n";
1693 mcerr <<
"ptr != temp_ptr\n";
1700#ifdef USE_DYNCAST_IN_PASSIVEPTR
1703 const RegPassivePtr* rpp = cpp->get_rpp();
1704 if (rpp == NULL)
return NULL;
1705 X* temp_ptr =
dynamic_cast<X*
>(
const_cast<RegPassivePtr*
>(rpp));
1706 if (temp_ptr == NULL) {
1707 mcerr <<
"Error in inline X* PassivePtr::get(void):\n"
1708 <<
" dynamic cast from RegPassivePtr to X* is not successful."
1709 <<
" You have probably tried to address with passive pointer "
1710 <<
" an object which is not derived from RegPassivePtr\n";
1715 else return (X*)(cpp->get_rpp());
1748#ifdef USE_DOUBLE_PTR_IN_PASSIVEPTR
1756#ifdef USE_DOUBLE_PTR_IN_PASSIVEPTR
1787#ifdef IMPLICIT_X_STAR
1788 inline operator X*(void)
const;
1794 return cpp->get_number_of_booked();
1796 void print(std::ostream& file,
int l = 1)
const;
1802#ifdef USE_DOUBLE_PTR_IN_PASSIVEPTR
1805#ifdef USE_REPLACE_ALLOC
1824 Ifile <<
"PassivePtr<X>:";
1826 file <<
" pointer is NULL, no object, number of ref's is "
1827 << get_total_number_of_references() <<
"\n";
1830 get()->print(file, l);
1833 Ifile <<
"number of ref's is " << get_total_number_of_references() <<
'\n';
1840 Ifile <<
"PassivePtr<X>:";
1841 if (f.get() == NULL)
1842 file <<
" pointer is NULL, no object, number of ref's is "
1843 << f.get_total_number_of_references() <<
"\n";
1849 Ifile <<
"number of ref's is " << f.get_total_number_of_references()
1863#ifdef USE_DELETE_AT_ZERO_COUNT
1864 const RegPassivePtr* arptr;
1865 if ((arptr = cpp->get_rpp()) != NULL &&
1867 arptr->get_s_allow_del_at_zero_count() == 1 &&
1869 arptr->s_allow_del_at_zero_count == 1 &&
1871 cpp->get_number_of_booked() == 1)
1876 if (cpp->get_rpp() == NULL && cpp->get_number_of_booked() == 0)
1884#ifdef USE_DOUBLE_PTR_IN_PASSIVEPTR
1903 if (f.cpp != NULL) {
1908#ifdef USE_DOUBLE_PTR_IN_PASSIVEPTR
1941 if (
this != &f) put(f.get());
1952#ifdef USE_DELETE_AT_ZERO_COUNT
1953 const RegPassivePtr* arptr;
1954 if ((arptr = cpp->get_rpp()) != NULL &&
1956 arptr->get_s_allow_del_at_zero_count() == 1 &&
1958 arptr->s_allow_del_at_zero_count == 1 &&
1960 cpp->get_number_of_booked() == 1)
1965 if (cpp->get_rpp() == NULL && cpp->get_number_of_booked() == 0) {
1971 if (cpp != NULL) cpp->book();
1972#ifdef USE_DOUBLE_PTR_IN_PASSIVEPTR
1979#ifdef USE_DOUBLE_PTR_IN_PASSIVEPTR
1980#ifdef SKIP_CHECKS_NULL
1984 mcerr <<
"Error in X* PassivePtr<X>::operator->(void) const: cpp == NULL\n";
1985 mcerr <<
"This means that the pointer is emtpy, "
1986 <<
"there is no addressed object.\n";
1987 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
1991 if (cpp->get_rpp() == NULL) {
1992 mcerr <<
"Error in X* PassivePtr<X>::operator->(void) const: "
1993 "cpp->get_rpp() == NULL\n";
1994 mcerr <<
"This means that the pointer is emtpy, "
1995 <<
"there is no addressed object.\n";
1996 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2000#ifdef USE_CHECK_DOUBLE_PTR_IN_PASSIVEPTR
2001 X* temp_ptr =
dynamic_cast<X*
>(
const_cast<RegPassivePtr*
>(cpp->get_rpp()));
2002 if (ptr != temp_ptr) {
2003 mcerr <<
"Error in inline X* PassivePtr::operator->(void):\n";
2004 mcerr <<
"ptr != temp_ptr\n";
2011#ifdef SKIP_CHECKS_NULL
2012 const RegPassivePtr* rpp = cpp->get_rpp();
2015 mcerr <<
"Error in X* PassivePtr<X>::operator->(void) const: cpp == NULL\n";
2016 mcerr <<
"This means that the pointer is emtpy, "
2017 <<
"there is no addressed object.\n";
2018 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2022 const RegPassivePtr* rpp;
2023 if ((rpp = cpp->get_rpp()) == NULL) {
2024 mcerr <<
"Error in X* PassivePtr<X>::operator->(void) const: "
2025 "cpp->get_rpp() == NULL\n";
2026 mcerr <<
"This means that the pointer is emtpy, "
2027 <<
"there is no addressed object.\n";
2028 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2033#ifdef USE_DYNCAST_IN_PASSIVEPTR
2034 X* temp_ptr =
dynamic_cast<X*
>(
const_cast<RegPassivePtr*
>(rpp));
2035 if (temp_ptr == NULL) {
2036 mcerr <<
"Error in X* PassivePtr<X>::operator->(void) const:\n"
2037 <<
" dynamic cast from RegPassivePtr to X* is not successful"
2038 <<
" (although the addresses of counter and abject are not zero)."
2039 <<
" You have probably initialized passive pointer "
2040 <<
" with address of deleted object\n";
2043 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2056#ifdef USE_DOUBLE_PTR_IN_PASSIVEPTR
2057#ifdef SKIP_CHECKS_NULL
2061 mcerr <<
"Error in X& PassivePtr<X>::operator*(void) const: cpp == NULL\n";
2062 mcerr <<
"This means that the pointer is emtpy, "
2063 <<
"there is no addressed object.\n";
2064 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2068 if (cpp->get_rpp() == NULL) {
2069 mcerr <<
"Error in X& PassivePtr<X>::operator*(void) const: cpp->get_rpp() "
2071 mcerr <<
"This means that the pointer is emtpy, "
2072 <<
"there is no addressed object.\n";
2073 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2077#ifdef USE_CHECK_DOUBLE_PTR_IN_PASSIVEPTR
2078 X* temp_ptr =
dynamic_cast<X*
>(
const_cast<RegPassivePtr*
>(cpp->get_rpp()));
2079 if (ptr != temp_ptr) {
2080 mcerr <<
"Error in inline X& PassivePtr::operator*(void):\n";
2081 mcerr <<
"ptr != temp_ptr\n";
2088#ifdef SKIP_CHECKS_NULL
2089 static const RegPassivePtr* rpp = cpp->get_rpp();
2092 mcerr <<
"Error in X& PassivePtr<X>::operator*(void) const: cpp == NULL\n";
2093 mcerr <<
"This means that the pointer is emtpy, "
2094 <<
"there is no addressed object.\n";
2095 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2099 static const RegPassivePtr* rpp;
2109 if ((rpp = cpp->get_rpp()) == NULL) {
2110 mcerr <<
"Error in X& PassivePtr<X>::operator*(void) const: cpp->get_rpp() "
2112 mcerr <<
"This means that the pointer is emtpy, "
2113 <<
"there is no addressed object.\n";
2114 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2119#ifdef USE_DYNCAST_IN_PASSIVEPTR
2120 X* temp_ptr =
dynamic_cast<X*
>(
const_cast<RegPassivePtr*
>(rpp));
2121 if (temp_ptr == NULL) {
2122 mcerr <<
"Error in X& PassivePtr<X>::operator*(void) const:\n"
2123 <<
" dynamic cast from RegPassivePtr to X* is not successful."
2124 <<
" You have probably tried to address with passive pointer "
2125 <<
" an object which is not derived from RegPassivePtr\n";
2130 return *((X*)(rpp));
2136#ifdef USE_DOUBLE_PTR_IN_PASSIVEPTR
2137#ifdef SKIP_CHECKS_NULL
2141 mcerr <<
"Error in X* PassivePtr<X>::getver(void) const: cpp == NULL\n";
2142 mcerr <<
"This means that the pointer is emtpy, "
2143 <<
"there is no addressed object.\n";
2144 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2148 if (cpp->get_rpp() == NULL) {
2149 mcerr <<
"Error in X* PassivePtr<X>::getver(void) const: cpp->get_rpp() == "
2151 mcerr <<
"This means that the pointer is emtpy, "
2152 <<
"there is no addressed object.\n";
2153 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2157#ifdef USE_CHECK_DOUBLE_PTR_IN_PASSIVEPTR
2158 X* temp_ptr =
dynamic_cast<X*
>(
const_cast<RegPassivePtr*
>(cpp->get_rpp()));
2159 if (ptr != temp_ptr) {
2160 mcerr <<
"Error in inline X* PassivePtr::getver(void):\n";
2161 mcerr <<
"ptr != temp_ptr\n";
2168#ifdef SKIP_CHECKS_NULL
2169 const RegPassivePtr* rpp = cpp->get_rpp();
2172 mcerr <<
"Error in X* PassivePtr<X>::getver(void) const: cpp == NULL\n";
2173 mcerr <<
"This means that the pointer is emtpy, "
2174 <<
"there is no addressed object.\n";
2175 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2179 const RegPassivePtr* rpp;
2180 if ((rpp = cpp->get_rpp()) == NULL) {
2181 mcerr <<
"Error in X* PassivePtr<X>::getver(void) const: cpp->get_rpp() == "
2183 mcerr <<
"This means that the pointer is emtpy, "
2184 <<
"there is no addressed object.\n";
2185 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2190#ifdef USE_DYNCAST_IN_PASSIVEPTR
2191 X* temp_ptr =
dynamic_cast<X*
>(
const_cast<RegPassivePtr*
>(rpp));
2192 if (temp_ptr == NULL) {
2193 mcerr <<
"Error in X* PassivePtr<X>::getver(void) const:\n"
2194 <<
" dynamic cast from RegPassivePtr to X* is not successful."
2195 <<
" You have probably tried to address with passive pointer "
2196 <<
" an object which is not derived from RegPassivePtr\n";
2206#ifdef IMPLICIT_X_STAR
2208#ifdef USE_DOUBLE_PTR_IN_PASSIVEPTR
2209#ifdef SKIP_CHECKS_NULL
2213 mcerr <<
"Error in PassivePtr<X>::operator X*(void) const: cpp == NULL\n";
2214 mcerr <<
"This means that the pointer is emtpy, "
2215 <<
"there is no addressed object.\n";
2216 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2220 if (cpp->get_rpp() == NULL) {
2221 mcerr <<
"Error in X* PassivePtr<X>::operator X*(void) const: "
2222 "cpp->get_rpp() == NULL\n";
2223 mcerr <<
"This means that the pointer is emtpy, "
2224 <<
"there is no addressed object.\n";
2225 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2229#ifdef USE_CHECK_DOUBLE_PTR_IN_PASSIVEPTR
2230 X* temp_ptr =
dynamic_cast<X*
>(
const_cast<RegPassivePtr*
>(cpp->get_rpp()));
2231 if (ptr != temp_ptr) {
2232 mcerr <<
"Error in inline X* PassivePtr::operator X*(void):\n";
2233 mcerr <<
"ptr != temp_ptr\n";
2240#ifdef SKIP_CHECKS_NULL
2241 const RegPassivePtr* rpp = cpp->get_rpp();
2245 <<
"Error in X* PassivePtr<X>::operator X*(void) const: cpp == NULL\n";
2246 mcerr <<
"This means that the pointer is emtpy, "
2247 <<
"there is no addressed object.\n";
2248 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2252 const RegPassivePtr* rpp;
2253 if ((rpp = cpp->get_rpp()) == NULL) {
2254 mcerr <<
"Error in X* PassivePtr<X>::operator X*(void) const: "
2255 "cpp->get_rpp() == NULL\n";
2256 mcerr <<
"This means that the pointer is emtpy, "
2257 <<
"there is no addressed object.\n";
2258 mcerr <<
"Type of X is (in internal notations) " <<
typeid(X).name()
2263#ifdef USE_DYNCAST_IN_PASSIVEPTR
2264 X* temp_ptr =
dynamic_cast<X*
>(
const_cast<RegPassivePtr*
>(rpp));
2265 if (temp_ptr == NULL) {
2266 mcerr <<
"Error in X* PassivePtr<X>::operator X*(void) const:\n"
2267 <<
" dynamic cast from RegPassivePtr to X* is not successful."
2268 <<
" You have probably tried to address with passive pointer "
2269 <<
" an object which is not derived from RegPassivePtr\n";
2284 return f1.get() == f2.get();
2290#ifdef USE_DELETE_AT_ZERO_COUNT
2291 const RegPassivePtr* arptr;
2292 if ((arptr = cpp->get_rpp()) != NULL &&
2294 arptr->get_s_allow_del_at_zero_count() == 1 &&
2296 arptr->s_allow_del_at_zero_count == 1 &&
2298 cpp->get_number_of_booked() == 1)
2303 if (cpp->get_rpp() == NULL && cpp->get_number_of_booked() == 0) {
2314 return f1.get() < f2.get();
2317#define USE_OLD_POINTER_NAMES
2318#ifdef USE_OLD_POINTER_NAMES
2319#define AutoContReg ActivePtrReg
2322template <
class X,
class C = StandardCopyDefinition<X> >
2324 public ActivePtr<X, C> {
2328 : RegPassivePtr(), ActivePtr<X, C>(fptr,
do_clone) {}
2330 : RegPassivePtr(), ActivePtr<X, C>(fptr,
dont_clone) {}
2333 : RegPassivePtr(), ActivePtr<X, C>(f) {}
2335 : RegPassivePtr(), ActivePtr<X, C>(f) {}
2337 if (
this != &f) put(f.get());
2340 virtual void print(std::ostream& file,
int l = 1)
const;
2343#ifdef USE_REPLACE_ALLOC
2348template <
class X,
class C>
2351 Ifile <<
"ActivePtrReg<X,C>:\n";
2353 RegPassivePtr::print(file, l);
2354 ActivePtr<X, C>::print(file, l);
2360 Ifile <<
"ActivePtrReg<X>:";
2362 file << (ActivePtr<X>&)f;
2367#ifdef INCLUDE_ActivePtrWI
2369#define USE_OLD_POINTER_NAMES
2370#ifdef USE_OLD_POINTER_NAMES
2371#define AutoPtrReg ActivePtrWIReg
2375class ActivePtrWIReg :
public RegPassivePtr,
2376 public ActivePtrWI<X> {
2378 inline ActivePtrWIReg(
void) : ActivePtrWI<X>(), RegPassivePtr() {}
2379 inline ActivePtrWIReg(
const X* fptr)
2380 : ActivePtrWI<X>(fptr), RegPassivePtr() {}
2381 inline ActivePtrWIReg(ActivePtrWIReg<X>& f)
2382 : ActivePtrWI<X>(fptr), RegPassivePtr() {}
2383 inline ActivePtrWIReg(
const ActivePtrWIReg<X>& f)
2384 : ActivePtrWI<X>(fptr), RegPassivePtr() {}
2385 inline ActivePtrWIReg& operator=(
const ActivePtrWIReg<X>& f) {
2386 if (
this != &f) put(f.get());
2389 virtual ~ActivePtrWIReg() {}
2390#ifdef USE_REPLACE_ALLOC
2402 inline operator double(
void) {
return val; }
2403#ifdef USE_REPLACE_ALLOC
int operator==(const PassivePtr< X > &f1, const PassivePtr< X > &f2)
bool operator<(PassivePtr< X > f1, PassivePtr< X > f2)
#define USE_PRIVATE_PARAM_IN_PASSIVEPTR
void exchange(ActivePtr< X, C > &f1, ActivePtr< X, C > &f2)
#define USE_DOUBLE_PTR_IN_PASSIVEPTR
std::ostream & operator<<(std::ostream &file, const AbsCont &f)
std::istream & operator>>(std::istream &file, ActivePtr< X, C > &f)
#define USE_DELETE_AT_ZERO_COUNT
DoubleAc operator*(const DoubleAc &f1, const DoubleAc &f2)
virtual void print(std::ostream &file, int l) const
virtual AbsCont * copy(void) const =0
ActivePtrReg(const X *fptr, Clone)
ActivePtrReg(const ActivePtrReg< X, C > &f)
macro_copy_total(ActivePtrReg)
ActivePtrReg & operator=(const ActivePtrReg< X, C > &f)
ActivePtrReg(ActivePtrReg< X, C > &f)
ActivePtrReg(const X *fptr, Pass)
virtual void print(std::ostream &file, int l=1) const
static X * copy(const X *f)
void change_rpp(const RegPassivePtr *frpp)
CountPassivePtr(const RegPassivePtr *frpp)
long get_number_of_booked(void)
const RegPassivePtr * get_rpp(void)
DoubleReg(const DoubleReg &f)
static X * copy(const X *f)
void pilfer(PILF_CONST ActivePtr< X, C > &f)
Attention: actually not const.
ActivePtr & operator=(const ActivePtr< X, C > &f)
char get_s_ban_cop(void) const
char get_s_allow_del_at_zero_count(void) const
static char get_s_print_adr_cpp(void)
virtual void print(std::ostream &file, int l=1) const
RegPassivePtr(const RegPassivePtr &f)
X * operator->(void) const
CountPP_ns::CountPassivePtr * book(void) const
char get_s_ban_sub(void) const
long get_total_number_of_references(void) const
X & operator*(void) const
static char get_s_ban_del_ignore(void)
void set_s_allow_del_at_zero_count(char fs_allow_del_at_zero_count)
PassivePtr< X > & operator=(X *f)
void set_s_ban_sub(char fs_ban_sub)
void set_s_ban_del(char fs_ban_del)
void set_s_ban_cop(char fs_ban_cop)
ActivePtr(const ActivePtr< X, C > &f)
RegPassivePtr(char fs_ban_del, char fs_ban_sub, char fs_ban_cop=0)
void clear_pointers(void) const
void move_pointer(PassivePtr< X > &f)
char get_s_ban_del(void) const
macro_copy_total(PassivePtr)
static void set_s_print_adr_cpp(char fs_print_adr_cpp)
macro_copy_total(RegPassivePtr)
PassivePtr< X > & operator=(const PassivePtr< X > &f)
ActivePtr(const X *fptr, Clone)
void print(std::ostream &file, int l=1) const
macro_copy_total(ActivePtr)
ActivePtr(PILF_CONST ActivePtr< X, C > &f, Pilfer)
RegPassivePtr & operator=(const RegPassivePtr &f)
static void set_s_ban_del_ignore(char fs_ban_del_ignore)
PassivePtr(const PassivePtr< X > &f)
std::ostream & yesindent(std::ostream &f)
std::ostream & noindent(std::ostream &f)
#define Iprintn(file, name)
std::ostream & operator<<(std::ostream &file, const trajestep &f)