Contents | Namespace List | File List | Directories | Alphabetical List | Class Hierarchy | Class List | Namespace Members | Class Members | File Members | Related Pages
This document was created on 4 Nov 2006.

Singleton.cpp

Go to the documentation of this file.
00001 // Singleton.cpp,v 4.54 2005/10/28 16:14:55 ossama Exp
00002 
00003 #ifndef ACE_SINGLETON_CPP
00004 #define ACE_SINGLETON_CPP
00005 
00006 #include "ace/Singleton.h"
00007 
00008 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00009 # pragma once
00010 #endif /* ACE_LACKS_PRAGMA_ONCE */
00011 
00012 #if !defined (__ACE_INLINE__)
00013 #include "ace/Singleton.inl"
00014 #endif /* __ACE_INLINE__ */
00015 
00016 #include "ace/Object_Manager.h"
00017 #include "ace/Log_Msg.h"
00018 #include "ace/Framework_Component.h"
00019 #include "ace/Guard_T.h"
00020 
00021 ACE_RCSID (ace,
00022            Singleton,
00023            "Singleton.cpp,v 4.54 2005/10/28 16:14:55 ossama Exp")
00024 
00025 
00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00027 
00028 template <class TYPE, class ACE_LOCK> void
00029 ACE_Singleton<TYPE, ACE_LOCK>::dump (void)
00030 {
00031 #if defined (ACE_HAS_DUMP)
00032   ACE_TRACE ("ACE_Singleton<TYPE, ACE_LOCK>::dump");
00033 
00034 #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00035   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("instance_ = %x"),
00036               ACE_Singleton<TYPE, ACE_LOCK>::instance_i ()));
00037   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00038 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00039 #endif /* ACE_HAS_DUMP */
00040 }
00041 
00042 template <class TYPE, class ACE_LOCK> ACE_Singleton<TYPE, ACE_LOCK> *&
00043 ACE_Singleton<TYPE, ACE_LOCK>::instance_i (void)
00044 {
00045 #if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00046   // Pointer to the Singleton instance.  This works around a bug with
00047   // G++ and it's (mis-)handling of templates and statics...
00048   static ACE_Singleton<TYPE, ACE_LOCK> *singleton_ = 0;
00049 
00050   return singleton_;
00051 #else
00052   return ACE_Singleton<TYPE, ACE_LOCK>::singleton_;
00053 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00054 }
00055 
00056 template <class TYPE, class ACE_LOCK> TYPE *
00057 ACE_Singleton<TYPE, ACE_LOCK>::instance (void)
00058 {
00059   ACE_TRACE ("ACE_Singleton<TYPE, ACE_LOCK>::instance");
00060 
00061   ACE_Singleton<TYPE, ACE_LOCK> *&singleton =
00062     ACE_Singleton<TYPE, ACE_LOCK>::instance_i ();
00063 
00064   // Perform the Double-Check pattern...
00065   if (singleton == 0)
00066     {
00067       if (ACE_Object_Manager::starting_up () ||
00068           ACE_Object_Manager::shutting_down ())
00069         {
00070           // The program is still starting up, and therefore assumed
00071           // to be single threaded.  There's no need to double-check.
00072           // Or, the ACE_Object_Manager instance has been destroyed,
00073           // so the preallocated lock is not available.  Either way,
00074           // don't register for destruction with the
00075           // ACE_Object_Manager:  we'll have to leak this instance.
00076 
00077           ACE_NEW_RETURN (singleton, (ACE_Singleton<TYPE, ACE_LOCK>), 0);
00078         }
00079       else
00080         {
00081 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00082           // Obtain a lock from the ACE_Object_Manager.  The pointer
00083           // is static, so we only obtain one per ACE_Singleton
00084           // instantiation.
00085           static ACE_LOCK *lock = 0;
00086           if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
00087             // Failed to acquire the lock!
00088             return 0;
00089 
00090           ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
00091 
00092           if (singleton == 0)
00093             {
00094 #endif /* ACE_MT_SAFE */
00095               ACE_NEW_RETURN (singleton, (ACE_Singleton<TYPE, ACE_LOCK>), 0);
00096 
00097               // Register for destruction with ACE_Object_Manager.
00098               ACE_Object_Manager::at_exit (singleton);
00099 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00100             }
00101 #endif /* ACE_MT_SAFE */
00102         }
00103     }
00104 
00105   return &singleton->instance_;
00106 }
00107 
00108 template <class TYPE, class ACE_LOCK> void
00109 ACE_Singleton<TYPE, ACE_LOCK>::cleanup (void *)
00110 {
00111   delete this;
00112   ACE_Singleton<TYPE, ACE_LOCK>::instance_i () = 0;
00113 }
00114 
00115 #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00116 // Pointer to the Singleton instance.
00117 template <class TYPE, class ACE_LOCK> ACE_Singleton<TYPE, ACE_LOCK> *
00118 ACE_Singleton<TYPE, ACE_LOCK>::singleton_ = 0;
00119 
00120 template <class TYPE, class ACE_LOCK> ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *
00121 ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::singleton_ = 0;
00122 #endif /* !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) */
00123 
00124 template <class TYPE, class ACE_LOCK> void
00125 ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::dump (void)
00126 {
00127 #if defined (ACE_HAS_DUMP)
00128   ACE_TRACE ("ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::dump");
00129 
00130 #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00131   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("instance_ = %x"),
00132               ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i ()));
00133   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00134 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00135 #endif /* ACE_HAS_DUMP */
00136 }
00137 
00138 template <class TYPE, class ACE_LOCK>
00139 ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *&
00140 ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i (void)
00141 {
00142 #if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00143   // Pointer to the Singleton instance.  This works around a bug with
00144   // G++ and it's (mis-)handling of templates and statics...
00145   static ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *singleton_ = 0;
00146 
00147   return singleton_;
00148 #else
00149   return ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::singleton_;
00150 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00151 }
00152 
00153 template <class TYPE, class ACE_LOCK> TYPE *
00154 ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance (void)
00155 {
00156   ACE_TRACE ("ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance");
00157 
00158   ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *&singleton =
00159     ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i ();
00160 
00161   // Perform the Double-Check pattern...
00162   if (singleton == 0)
00163     {
00164       if (ACE_Object_Manager::starting_up () ||
00165           ACE_Object_Manager::shutting_down ())
00166         {
00167           // The program is still starting up, and therefore assumed
00168           // to be single threaded.  There's no need to double-check.
00169           // Or, the ACE_Object_Manager instance has been destroyed,
00170           // so the preallocated lock is not available.  Either way,
00171           // don't register for destruction with the
00172           // ACE_Object_Manager:  we'll have to leak this instance.
00173 
00174           ACE_NEW_RETURN (singleton, (ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>),
00175                           0);
00176         }
00177       else
00178         {
00179 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00180           // Obtain a lock from the ACE_Object_Manager.  The pointer
00181           // is static, so we only obtain one per
00182           // ACE_Unmanaged_Singleton instantiation.
00183           static ACE_LOCK *lock = 0;
00184           if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
00185             // Failed to acquire the lock!
00186             return 0;
00187 
00188           ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
00189 #endif /* ACE_MT_SAFE */
00190 
00191           if (singleton == 0)
00192             ACE_NEW_RETURN (singleton,
00193                             (ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>),
00194                             0);
00195         }
00196     }
00197 
00198   return &singleton->instance_;
00199 }
00200 
00201 template <class TYPE, class ACE_LOCK> void
00202 ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::close (void)
00203 {
00204   ACE_Unmanaged_Singleton<TYPE, ACE_LOCK> *&singleton =
00205     ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i ();
00206 
00207   if (singleton)
00208     {
00209       singleton->cleanup ();
00210       ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance_i () = 0;
00211     }
00212 }
00213 
00214 template <class TYPE, class ACE_LOCK> void
00215 ACE_TSS_Singleton<TYPE, ACE_LOCK>::dump (void)
00216 {
00217 #if defined (ACE_HAS_DUMP)
00218   ACE_TRACE ("ACE_TSS_Singleton<TYPE, ACE_LOCK>::dump");
00219 
00220 #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00221   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("instance_ = %x"),
00222               ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ()));
00223   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00224 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00225 #endif /* ACE_HAS_DUMP */
00226 }
00227 
00228 template <class TYPE, class ACE_LOCK> ACE_TSS_Singleton<TYPE, ACE_LOCK> *&
00229 ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance_i (void)
00230 {
00231 #if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00232   // Pointer to the Singleton instance.  This works around a bug with
00233   // G++ and it's (mis-)handling of templates and statics...
00234   static ACE_TSS_Singleton<TYPE, ACE_LOCK> *singleton_ = 0;
00235 
00236   return singleton_;
00237 #else
00238   return ACE_TSS_Singleton<TYPE, ACE_LOCK>::singleton_;
00239 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00240 }
00241 
00242 template <class TYPE, class ACE_LOCK> TYPE *
00243 ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance (void)
00244 {
00245   ACE_TRACE ("ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance");
00246 
00247   ACE_TSS_Singleton<TYPE, ACE_LOCK> *&singleton =
00248     ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ();
00249 
00250   // Perform the Double-Check pattern...
00251   if (singleton == 0)
00252     {
00253       if (ACE_Object_Manager::starting_up () ||
00254           ACE_Object_Manager::shutting_down ())
00255         {
00256           // The program is still starting up, and therefore assumed
00257           // to be single threaded.  There's no need to double-check.
00258           // Or, the ACE_Object_Manager instance has been destroyed,
00259           // so the preallocated lock is not available.  Either way,
00260           // don't register for destruction with the
00261           // ACE_Object_Manager:  we'll have to leak this instance.
00262 
00263           ACE_NEW_RETURN (singleton, (ACE_TSS_Singleton<TYPE, ACE_LOCK>), 0);
00264         }
00265       else
00266         {
00267 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00268 
00269           // Obtain a lock from the ACE_Object_Manager.  The pointer
00270           // is static, so we only obtain one per ACE_Singleton instantiation.
00271           static ACE_LOCK *lock = 0;
00272           if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
00273             // Failed to acquire the lock!
00274             return 0;
00275 
00276           ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
00277 
00278           if (singleton == 0)
00279             {
00280 #endif /* ACE_MT_SAFE */
00281               ACE_NEW_RETURN (singleton, (ACE_TSS_Singleton<TYPE, ACE_LOCK>),
00282                               0);
00283 
00284               // Register for destruction with ACE_Object_Manager.
00285               ACE_Object_Manager::at_exit (singleton);
00286 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00287             }
00288 #endif /* ACE_MT_SAFE */
00289         }
00290     }
00291 
00292   return ACE_TSS_GET (&singleton->instance_, TYPE);
00293 }
00294 
00295 template <class TYPE, class ACE_LOCK> void
00296 ACE_TSS_Singleton<TYPE, ACE_LOCK>::cleanup (void *)
00297 {
00298   delete this;
00299   ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance_i () = 0;
00300 }
00301 
00302 template <class TYPE, class ACE_LOCK> void
00303 ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::dump (void)
00304 {
00305 #if defined (ACE_HAS_DUMP)
00306   ACE_TRACE ("ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::dump");
00307 
00308 #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00309   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("instance_ = %x"),
00310               ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ()));
00311   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00312 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00313 #endif /* ACE_HAS_DUMP */
00314 }
00315 
00316 template <class TYPE, class ACE_LOCK>
00317 ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *&
00318 ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance_i (void)
00319 {
00320 #if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00321   // Pointer to the Singleton instance.  This works around a bug with
00322   // G++ and it's (mis-)handling of templates and statics...
00323   static ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *singleton_ = 0;
00324 
00325   return singleton_;
00326 #else
00327   return ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::singleton_;
00328 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00329 }
00330 
00331 template <class TYPE, class ACE_LOCK> TYPE *
00332 ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance (void)
00333 {
00334   ACE_TRACE ("ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance");
00335 
00336   ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *&singleton =
00337     ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ();
00338 
00339   // Perform the Double-Check pattern...
00340   if (singleton == 0)
00341     {
00342       if (ACE_Object_Manager::starting_up () ||
00343           ACE_Object_Manager::shutting_down ())
00344         {
00345           // The program is still starting up, and therefore assumed
00346           // to be single threaded.  There's no need to double-check.
00347           // Or, the ACE_Object_Manager instance has been destroyed,
00348           // so the preallocated lock is not available.  Either way,
00349           // don't register for destruction with the
00350           // ACE_Object_Manager:  we'll have to leak this instance.
00351 
00352           ACE_NEW_RETURN (singleton,
00353                           (ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>),
00354                           0);
00355         }
00356       else
00357         {
00358 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00359           // Obtain a lock from the ACE_Object_Manager.  The pointer
00360           // is static, so we only obtain one per
00361           // ACE_Unmanaged_Singleton instantiation.
00362           static ACE_LOCK *lock = 0;
00363           if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
00364             // Failed to acquire the lock!
00365             return 0;
00366 
00367           ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
00368 #endif /* ACE_MT_SAFE */
00369 
00370           if (singleton == 0)
00371             ACE_NEW_RETURN (singleton,
00372                             (ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>),
00373                             0);
00374         }
00375     }
00376 
00377   return ACE_TSS_GET (&singleton->instance_, TYPE);
00378 }
00379 
00380 template <class TYPE, class ACE_LOCK> void
00381 ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::close (void)
00382 {
00383   ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *&singleton =
00384     ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance_i ();
00385 
00386   if (singleton)
00387     singleton->cleanup ();
00388 }
00389 
00390 #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00391 // Pointer to the Singleton instance.
00392 template <class TYPE, class ACE_LOCK> ACE_TSS_Singleton <TYPE, ACE_LOCK> *
00393 ACE_TSS_Singleton<TYPE, ACE_LOCK>::singleton_ = 0;
00394 
00395 template <class TYPE, class ACE_LOCK>
00396 ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK> *
00397 ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::singleton_ = 0;
00398 #endif /* !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) */
00399 
00400 /*************************************************************************/
00401 
00402 #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00403 // Pointer to the Singleton instance.
00404 template <class TYPE, class ACE_LOCK> ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *
00405 ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::singleton_ = 0;
00406 #endif /* !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) */
00407 
00408 template <class TYPE, class ACE_LOCK> void
00409 ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::dump (void)
00410 {
00411 #if defined (ACE_HAS_DUMP)
00412   ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::dump");
00413 
00414 #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00415   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("instance_ = %x"),
00416               ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i ()));
00417   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00418 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00419 #endif /* ACE_HAS_DUMP */
00420 }
00421 
00422 template <class TYPE, class ACE_LOCK>
00423 ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *&
00424 ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i (void)
00425 {
00426   ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i");
00427 
00428 #if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
00429   // Pointer to the Singleton instance.  This works around a bug with
00430   // G++ and it's (mis-)handling of templates and statics...
00431   static ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *singleton_ = 0;
00432 
00433   return singleton_;
00434 #else
00435   return ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::singleton_;
00436 #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
00437 }
00438 
00439 template <class TYPE, class ACE_LOCK> TYPE *
00440 ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance (void)
00441 {
00442   ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance");
00443 
00444   ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *&singleton =
00445     ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i ();
00446 
00447   // Perform the Double-Check pattern...
00448   if (singleton == 0)
00449     {
00450       if (ACE_Object_Manager::starting_up () ||
00451           ACE_Object_Manager::shutting_down ())
00452         {
00453           // The program is still starting up, and therefore assumed
00454           // to be single threaded.  There's no need to double-check.
00455           // Or, the ACE_Object_Manager instance has been destroyed,
00456           // so the preallocated lock is not available.  Either way,
00457           // don't register for destruction with the
00458           // ACE_Object_Manager:  we'll have to leak this instance.
00459 
00460           ACE_NEW_RETURN (singleton, (ACE_DLL_Singleton_T<TYPE, ACE_LOCK>),
00461                           0);
00462         }
00463       else
00464         {
00465 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00466           // Obtain a lock from the ACE_Object_Manager.  The pointer
00467           // is static, so we only obtain one per
00468           // ACE_Unmanaged_Singleton instantiation.
00469           static ACE_LOCK *lock = 0;
00470           if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
00471             // Failed to acquire the lock!
00472             return 0;
00473 
00474           ACE_GUARD_RETURN (ACE_LOCK, ace_mon, *lock, 0);
00475 #endif /* ACE_MT_SAFE */
00476 
00477           if (singleton == 0)
00478             ACE_NEW_RETURN (singleton,
00479                             (ACE_DLL_Singleton_T<TYPE, ACE_LOCK>),
00480                             0);
00481         }
00482       //ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_DLL_Singleton<TYPE,ACE_LOCK>, singleton);
00483       ACE_Framework_Repository::instance ()->register_component
00484         (new ACE_Framework_Component_T<ACE_DLL_Singleton_T<TYPE, ACE_LOCK> > (singleton));
00485     }
00486 
00487   return &singleton->instance_;
00488 }
00489 
00490 template <class TYPE, class ACE_LOCK> void
00491 ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close (void)
00492 {
00493   ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close");
00494 
00495   ACE_DLL_Singleton_T<TYPE, ACE_LOCK> *&singleton =
00496     ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance_i ();
00497 
00498   delete singleton;
00499   singleton = 0;
00500 }
00501 
00502 template <class TYPE, class ACE_LOCK> void
00503 ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close_singleton (void)
00504 {
00505   ACE_TRACE ("ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close_singleton");
00506   ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::close ();
00507 }
00508 
00509 template <class TYPE, class ACE_LOCK> const ACE_TCHAR *
00510 ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::dll_name (void)
00511 {
00512   return this->instance ()->dll_name ();
00513 }
00514 
00515 template <class TYPE, class ACE_LOCK> const ACE_TCHAR *
00516 ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::name (void)
00517 {
00518   return this->instance ()->name ();
00519 }
00520 
00521 
00522 /**********************************************************************/
00523 
00524 template <class TYPE> const ACE_TCHAR*
00525 ACE_DLL_Singleton_Adapter_T<TYPE>::dll_name (void)
00526 {
00527   // @todo make this a constant somewhere (or it there already is one
00528   // then use it.
00529   return ACE_TEXT("ACE");
00530 }
00531 
00532 ACE_END_VERSIONED_NAMESPACE_DECL
00533 
00534 #endif /* ACE_SINGLETON_CPP */

Please send comments or questions to feedback@tena-sda.org.