Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Dump.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // $Id: Dump.cpp,v 1.1.1.3.40.1 2003/03/13 19:44:21 chad Exp $
00003 
00004 #include "ace/Synch_T.h"
00005 #include "ace/Dump.h"
00006 #include "ace/Object_Manager.h"
00007 #include "ace/Log_Msg.h"
00008 
00009 ACE_RCSID(ace, Dump, "$Id: Dump.cpp,v 1.1.1.3.40.1 2003/03/13 19:44:21 chad Exp $")
00010 
00011 // Implementations (very simple for now...)
00012 
00013 ACE_Dumpable::~ACE_Dumpable (void)
00014 {
00015   ACE_TRACE ("ACE_Dumpable::~ACE_Dumpable");
00016 }
00017 
00018 ACE_Dumpable::ACE_Dumpable (const void *this_ptr)
00019   : this_ (this_ptr)
00020 {
00021   ACE_TRACE ("ACE_Dumpable::ACE_Dumpable");
00022 }
00023 
00024 ACE_Dumpable_Ptr::ACE_Dumpable_Ptr (const ACE_Dumpable *dumper)
00025   : dumper_ (dumper)
00026 {
00027   ACE_TRACE ("ACE_Dumpable_Ptr::ACE_Dumpable_Ptr");
00028 }
00029 
00030 const ACE_Dumpable *
00031 ACE_Dumpable_Ptr::operator->() const
00032 {
00033   ACE_TRACE ("ACE_Dumpable_Ptr::operator->");
00034   return this->dumper_;
00035 }
00036 
00037 void
00038 ACE_Dumpable_Ptr::operator= (const ACE_Dumpable *dumper) const
00039 {
00040   ACE_TRACE ("ACE_Dumpable_Ptr::operator=");
00041   if (this->dumper_ != dumper)
00042     {
00043       delete (ACE_Dumpable *) this->dumper_;
00044       ((ACE_Dumpable_Ptr *) this)->dumper_ = dumper;
00045     }
00046 }
00047 
00048 ACE_ODB::ACE_ODB (void)
00049   // Let the Tuple default constructor initialize object_table_
00050   : current_size_ (0)
00051 {
00052   ACE_TRACE ("ACE_ODB::ACE_ODB");
00053 }
00054 
00055 ACE_ODB *
00056 ACE_ODB::instance (void)
00057 {
00058   ACE_TRACE ("ACE_ODB::instance");
00059 
00060   if (ACE_ODB::instance_ == 0)
00061     {
00062       ACE_MT (ACE_Thread_Mutex *lock =
00063         ACE_Managed_Object<ACE_Thread_Mutex>::get_preallocated_object
00064           (ACE_Object_Manager::ACE_DUMP_LOCK);
00065         ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, *lock, 0));
00066 
00067       if (ACE_ODB::instance_ == 0)
00068         ACE_NEW_RETURN (ACE_ODB::instance_,
00069                         ACE_ODB,
00070                         0);
00071     }
00072 
00073   return ACE_ODB::instance_;
00074 }
00075 
00076 void
00077 ACE_ODB::dump_objects (void)
00078 {
00079   ACE_TRACE ("ACE_ODB::dump_objects");
00080   for (int i = 0; i < this->current_size_; i++)
00081     {
00082       if (this->object_table_[i].this_ != 0)
00083         // Dump the state of the object.
00084         this->object_table_[i].dumper_->dump ();
00085     }
00086 }
00087 
00088 // This method registers a new <dumper>.  It detects
00089 // duplicates and simply overwrites them.
00090 
00091 void
00092 ACE_ODB::register_object (const ACE_Dumpable *dumper)
00093 {
00094   ACE_TRACE ("ACE_ODB::register_object");
00095   int i;
00096   int slot = 0;
00097 
00098   for (i = 0; i < this->current_size_; i++)
00099     {
00100       if (this->object_table_[i].this_ == 0)
00101         slot = i;
00102       else if (this->object_table_[i].this_ == dumper->this_)
00103         {
00104           slot = i;
00105           break;
00106         }
00107     }
00108 
00109   if (i == this->current_size_)
00110     {
00111       slot = this->current_size_++;
00112       ACE_ASSERT (this->current_size_ < ACE_ODB::MAX_TABLE_SIZE);
00113     }
00114   this->object_table_[slot].this_ = dumper->this_;
00115   this->object_table_[slot].dumper_ = dumper;
00116 }
00117 
00118 void
00119 ACE_ODB::remove_object (const void *this_ptr)
00120 {
00121   ACE_TRACE ("ACE_ODB::remove_object");
00122   int i;
00123 
00124   for (i = 0; i < this->current_size_; i++)
00125     {
00126       if (this->object_table_[i].this_ == this_ptr)
00127         break;
00128     }
00129 
00130   if (i < this->current_size_)
00131     {
00132       this->object_table_[i].this_ = 0;
00133       this->object_table_[i].dumper_ = 0;
00134     }
00135 }
00136 
00137 ACE_ODB *ACE_ODB::instance_ = 0;

Generated on Mon Jun 16 11:19:37 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002