Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Dump.cpp
blobba98ae19075036754dad1b9a2e3314d59cdcdffb
1 #include "ace/Dump.h"
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)
21 : this_ (this_ptr)
23 ACE_TRACE ("ACE_Dumpable::ACE_Dumpable");
26 ACE_Dumpable_Ptr::ACE_Dumpable_Ptr (const ACE_Dumpable *dumper)
27 : dumper_ (dumper)
29 ACE_TRACE ("ACE_Dumpable_Ptr::ACE_Dumpable_Ptr");
32 const ACE_Dumpable *
33 ACE_Dumpable_Ptr::operator->() const
35 ACE_TRACE ("ACE_Dumpable_Ptr::operator->");
36 return this->dumper_;
39 void
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 ()
51 // Let the Tuple default constructor initialize object_table_
52 : current_size_ (0)
54 ACE_TRACE ("ACE_ODB::ACE_ODB");
57 ACE_ALLOC_HOOK_DEFINE(ACE_ODB)
59 ACE_ODB *
60 ACE_ODB::instance ()
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_,
73 ACE_ODB,
74 0);
77 return ACE_ODB::instance_;
80 void
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.
95 void
96 ACE_ODB::register_object (const ACE_Dumpable *dumper)
98 ACE_TRACE ("ACE_ODB::register_object");
99 int i;
100 int slot = 0;
102 for (i = 0; i < this->current_size_; i++)
104 if (this->object_table_[i].this_ == 0)
105 slot = i;
106 else if (this->object_table_[i].this_ == dumper->this_)
108 slot = i;
109 break;
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;
122 void
123 ACE_ODB::remove_object (const void *this_ptr)
125 ACE_TRACE ("ACE_ODB::remove_object");
126 int i;
128 for (i = 0; i < this->current_size_; i++)
130 if (this->object_table_[i].this_ == this_ptr)
131 break;
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