1 // $Id: Dump.cpp 80826 2008-03-04 14:51:23Z wotte $
4 #include "ace/Guard_T.h"
5 #include "ace/Thread_Mutex.h"
6 #include "ace/Object_Manager.h"
7 #include "ace/Log_Msg.h"
9 ACE_RCSID(ace
, Dump
, "$Id: Dump.cpp 80826 2008-03-04 14:51:23Z wotte $")
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
13 // Implementations (very simple for now...)
15 ACE_Dumpable::~ACE_Dumpable (void)
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
;
50 ACE_ODB::ACE_ODB (void)
51 // Let the Tuple default constructor initialize object_table_
54 ACE_TRACE ("ACE_ODB::ACE_ODB");
58 ACE_ODB::instance (void)
60 ACE_TRACE ("ACE_ODB::instance");
62 if (ACE_ODB::instance_
== 0)
64 ACE_MT (ACE_Thread_Mutex
*lock
=
65 ACE_Managed_Object
<ACE_Thread_Mutex
>::get_preallocated_object
66 (ACE_Object_Manager::ACE_DUMP_LOCK
);
67 ACE_GUARD_RETURN (ACE_Thread_Mutex
, ace_mon
, *lock
, 0));
69 if (ACE_ODB::instance_
== 0)
70 ACE_NEW_RETURN (ACE_ODB::instance_
,
75 return ACE_ODB::instance_
;
79 ACE_ODB::dump_objects (void)
81 ACE_TRACE ("ACE_ODB::dump_objects");
82 for (int i
= 0; i
< this->current_size_
; i
++)
84 if (this->object_table_
[i
].this_
!= 0)
85 // Dump the state of the object.
86 this->object_table_
[i
].dumper_
->dump ();
90 // This method registers a new <dumper>. It detects
91 // duplicates and simply overwrites them.
94 ACE_ODB::register_object (const ACE_Dumpable
*dumper
)
96 ACE_TRACE ("ACE_ODB::register_object");
100 for (i
= 0; i
< this->current_size_
; i
++)
102 if (this->object_table_
[i
].this_
== 0)
104 else if (this->object_table_
[i
].this_
== dumper
->this_
)
111 if (i
== this->current_size_
)
113 slot
= this->current_size_
++;
114 ACE_ASSERT (this->current_size_
< ACE_ODB::MAX_TABLE_SIZE
);
116 this->object_table_
[slot
].this_
= dumper
->this_
;
117 this->object_table_
[slot
].dumper_
= dumper
;
121 ACE_ODB::remove_object (const void *this_ptr
)
123 ACE_TRACE ("ACE_ODB::remove_object");
126 for (i
= 0; i
< this->current_size_
; i
++)
128 if (this->object_table_
[i
].this_
== this_ptr
)
132 if (i
< this->current_size_
)
134 this->object_table_
[i
].this_
= 0;
135 this->object_table_
[i
].dumper_
= 0;
139 ACE_ODB
*ACE_ODB::instance_
= 0;
141 ACE_END_VERSIONED_NAMESPACE_DECL