2 #include "ace/Guard_T.h"
3 #include "ace/Thread_Mutex.h"
4 #include "ace/Object_Manager.h"
5 #include "ace/Log_Category.h"
7 #if defined (ACE_HAS_ALLOC_HOOKS)
8 # include "ace/Malloc_Base.h"
9 #endif /* ACE_HAS_ALLOC_HOOKS */
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
13 // Implementations (very simple for now...)
15 ACE_Dumpable::~ACE_Dumpable ()
17 ACE_TRACE ("ACE_Dumpable::~ACE_Dumpable");
20 ACE_Dumpable::ACE_Dumpable (const void *this_ptr
)
23 ACE_TRACE ("ACE_Dumpable::ACE_Dumpable");
26 ACE_Dumpable_Ptr::ACE_Dumpable_Ptr (const ACE_Dumpable
*dumper
)
29 ACE_TRACE ("ACE_Dumpable_Ptr::ACE_Dumpable_Ptr");
33 ACE_Dumpable_Ptr::operator->() const
35 ACE_TRACE ("ACE_Dumpable_Ptr::operator->");
40 ACE_Dumpable_Ptr::operator= (const ACE_Dumpable
*dumper
) const
42 ACE_TRACE ("ACE_Dumpable_Ptr::operator=");
43 if (this->dumper_
!= dumper
)
45 delete const_cast <ACE_Dumpable
*> (this->dumper_
);
46 (const_cast<ACE_Dumpable_Ptr
*> (this))->dumper_
= dumper
;
51 // Let the Tuple default constructor initialize object_table_
54 ACE_TRACE ("ACE_ODB::ACE_ODB");
57 ACE_ALLOC_HOOK_DEFINE(ACE_ODB
)
62 ACE_TRACE ("ACE_ODB::instance");
64 if (ACE_ODB::instance_
== 0)
66 ACE_MT (ACE_Thread_Mutex
*lock
=
67 ACE_Managed_Object
<ACE_Thread_Mutex
>::get_preallocated_object
68 (ACE_Object_Manager::ACE_DUMP_LOCK
);
69 ACE_GUARD_RETURN (ACE_Thread_Mutex
, ace_mon
, *lock
, 0));
71 if (ACE_ODB::instance_
== 0)
72 ACE_NEW_RETURN (ACE_ODB::instance_
,
77 return ACE_ODB::instance_
;
81 ACE_ODB::dump_objects ()
83 ACE_TRACE ("ACE_ODB::dump_objects");
84 for (int i
= 0; i
< this->current_size_
; i
++)
86 if (this->object_table_
[i
].this_
!= 0)
87 // Dump the state of the object.
88 this->object_table_
[i
].dumper_
->dump ();
92 // This method registers a new <dumper>. It detects
93 // duplicates and simply overwrites them.
96 ACE_ODB::register_object (const ACE_Dumpable
*dumper
)
98 ACE_TRACE ("ACE_ODB::register_object");
102 for (i
= 0; i
< this->current_size_
; i
++)
104 if (this->object_table_
[i
].this_
== 0)
106 else if (this->object_table_
[i
].this_
== dumper
->this_
)
113 if (i
== this->current_size_
)
115 slot
= this->current_size_
++;
116 ACE_ASSERT (this->current_size_
< ACE_ODB::MAX_TABLE_SIZE
);
118 this->object_table_
[slot
].this_
= dumper
->this_
;
119 this->object_table_
[slot
].dumper_
= dumper
;
123 ACE_ODB::remove_object (const void *this_ptr
)
125 ACE_TRACE ("ACE_ODB::remove_object");
128 for (i
= 0; i
< this->current_size_
; i
++)
130 if (this->object_table_
[i
].this_
== this_ptr
)
134 if (i
< this->current_size_
)
136 this->object_table_
[i
].this_
= 0;
137 this->object_table_
[i
].dumper_
= 0;
141 ACE_ODB
*ACE_ODB::instance_
= 0;
143 ACE_END_VERSIONED_NAMESPACE_DECL