14 #ifndef __INCLUDED__SCOPIRA_TOOL_OBJECT_H__ 15 #define __INCLUDED__SCOPIRA_TOOL_OBJECT_H__ 19 #include <scopira/tool/mutex.h> 20 #include <scopira/tool/export.h> 75 mutable volatile int dm_refcount;
76 mutable mutex dm_refcount_mutex;
78 volatile int dm_object_magic;
79 volatile bool dm_use_debug_ref_counter;
89 SCOPIRA_EXPORT
virtual ~object();
102 SCOPIRA_EXPORT
int add_ref(
void)
const;
114 SCOPIRA_EXPORT
bool sub_ref(
void)
const;
123 SCOPIRA_EXPORT
void auto_ref(
void)
const;
194 SCOPIRA_EXPORT
object(
void);
209 SCOPIRA_EXPORT
explicit object(
bool neverusecounter);
231 void operator = (
const object &rhs);
287 : dm_ptr(o) {
if (o) o->add_ref(); }
294 : dm_ptr(o.dm_ptr) {
if (dm_ptr) dm_ptr->add_ref(); }
301 : dm_ptr(o.get()) {
if (dm_ptr) dm_ptr->add_ref(); }
307 {
if (dm_ptr) dm_ptr->sub_ref(); }
316 {
if (o) o->add_ref();
if (dm_ptr) dm_ptr->sub_ref(); dm_ptr = o; }
323 {
set(o);
return *
this; }
331 {
set(o.dm_ptr);
return *
this; }
337 bool operator == (
const count_ptr<T> &rhs)
const {
return dm_ptr == rhs.dm_ptr; }
343 bool operator == (
const T* rhs)
const {
return dm_ptr == rhs; }
349 bool operator != (
const count_ptr<T> &rhs)
const {
return dm_ptr != rhs.dm_ptr; }
355 bool operator != (
const T* rhs)
const {
return dm_ptr != rhs; }
361 bool operator < (const count_ptr<T> &rhs)
const {
return dm_ptr < rhs.dm_ptr; }
369 {
if (dm_ptr) dm_ptr->
print(o);
return o; }
378 T*
get(void)
const {
return dm_ptr; }
386 { assert(
"[NULL pointer dereferenced in count_ptr]" && dm_ptr);
return *dm_ptr; }
395 T* operator ->(
void)
const 396 { assert(
"[NULL pointer dereferenced in count_ptr]" && dm_ptr);
return dm_ptr; }
405 T & operator *(
void)
const 406 { assert(
"[NULL pointer dereferenced in count_ptr]" && dm_ptr);
return *dm_ptr; }
414 bool is_null(
void)
const {
return dm_ptr == 0; }
458 : dm_ptr(o), dm_doref(doref) {
if (doref && o) o->add_ref(); }
465 : dm_ptr(o.dm_ptr), dm_doref(o.dm_doref) {
if (dm_doref && dm_ptr) dm_ptr->add_ref(); }
471 {
if (dm_doref && dm_ptr) dm_ptr->sub_ref(); }
479 {
if (dm_doref && o) o->add_ref();
if (dm_doref && dm_ptr) dm_ptr->sub_ref(); dm_ptr = o; }
486 {
set(o);
return *
this; }
494 {
set(o.dm_ptr);
return *
this; }
500 bool operator == (
const count2_ptr<T>& rhs)
const {
return dm_ptr == rhs.dm_ptr; }
506 bool operator == (
const T* rhs)
const {
return dm_ptr == rhs; }
512 bool operator != (
const count2_ptr<T>& rhs)
const {
return dm_ptr != rhs.dm_ptr; }
518 bool operator != (
const T* rhs)
const {
return dm_ptr != rhs; }
524 bool operator < (const count2_ptr<T>& rhs)
const {
return dm_ptr < rhs.dm_ptr; }
532 {
if (dm_ptr) dm_ptr->
print(o);
return o; }
541 T*
get(void)
const {
return dm_ptr; }
549 operator T*(void)
const {
return dm_ptr; }
559 { assert(
"[NULL pointer dereferenced in count_ptr]" && dm_ptr);
return *dm_ptr; }
568 T* operator ->(
void)
const 569 { assert(
"[NULL pointer dereferenced in count_ptr]" && dm_ptr);
return dm_ptr; }
578 T & operator *(
void)
const 579 { assert(
"[NULL pointer dereferenced in count_ptr]" && dm_ptr);
return *dm_ptr; }
587 bool is_null(
void)
const {
return dm_ptr == 0; }
620 inline scopira::tool::oflow_i & operator << (scopira::tool::oflow_i &o, const scopira::tool::count_ptr<C> &ptr)
622 return o << ptr.get();
656 static int dm_baddel;
673 SCOPIRA_EXPORT ~objrefcounter();
686 static bool has_counter(
void);
689 static void bad_del(
void);
690 static void add_real(
void);
691 static void sub_real(
void);
693 static void output(
void);
Definition: archiveflow.h:20