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

Cleanup_Func_Registry.cpp

Go to the documentation of this file.
00001 #include "tao_pch.h"
00002 #include "Cleanup_Func_Registry.h"
00003 
00004 #if !defined (__ACE_INLINE__)
00005 # include "Cleanup_Func_Registry.inl"
00006 #endif /* __ACE_INLINE__ */
00007 
00008 #include "ace/Log_Msg.h"
00009 
00010 ACE_RCSID (tao,
00011            Cleanup_Func_Registry,
00012            "$Id: Cleanup_Func_Registry.cpp,v 1.1.1.2.2.1 2003/03/14 16:05:12 chad Exp $")
00013 
00014 TAO_Cleanup_Func_Registry::TAO_Cleanup_Func_Registry (void)
00015   : cleanup_funcs_ ()
00016 {
00017 }
00018 
00019 TAO_Cleanup_Func_Registry::~TAO_Cleanup_Func_Registry (void)
00020 {
00021 }
00022 
00023 int
00024 TAO_Cleanup_Func_Registry::register_cleanup_function (
00025   ACE_CLEANUP_FUNC func,
00026   size_t &slot_id)
00027 {
00028   size_t slot = this->cleanup_funcs_.size ();
00029 
00030   if (this->cleanup_funcs_.size (slot + 1) != 0)
00031     return -1;
00032 
00033   this->cleanup_funcs_[slot] = func;
00034   slot_id = slot;
00035 
00036   return 0;
00037 }
00038 
00039 void
00040 TAO_Cleanup_Func_Registry::cleanup (ACE_Array_Base<void *> &ts_objects)
00041 {
00042   size_t len = ts_objects.size ();
00043 
00044   // The allocated slot may never have been used.  It is therefore
00045   // possible that the TSS array size may be less than the cleanup
00046   // function size.  However, there is still a one-to-one
00047   // correspondence between cleanup_func[foo] and ts_object[foo].
00048 
00049   ACE_ASSERT (len <= this->cleanup_funcs_.size ());
00050 
00051   /// Cleanup each TSS object.
00052   for (size_t i = 0; i < len; ++i)
00053     {
00054       ACE_CLEANUP_FUNC destructor = this->cleanup_funcs_[i];
00055       if (destructor != 0)
00056         destructor (ts_objects[i], 0);
00057     }
00058 }
00059 
00060 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
00061 
00062 template class ACE_Array_Base<ACE_CLEANUP_FUNC>;
00063 
00064 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
00065 
00066 #pragma instantiate ACE_Array_Base<ACE_CLEANUP_FUNC>
00067 
00068 #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */

Generated on Mon Jun 16 13:48:03 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002