Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / TAO_Singleton.h
blob85c820a5225a7f312558e95e0372db719f4de5d7
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file TAO_Singleton.h
7 * Header file for the TAO-specific Singleton implementation.
8 * Based entirely on ace/Singleton.*.
10 * @author Ossama Othman <ossama@uci.edu>
12 //=============================================================================
15 #ifndef TAO_SINGLETON_H
16 #define TAO_SINGLETON_H
18 #include /**/ "ace/pre.h"
20 #include "ace/TSS_T.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 # pragma once
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include /**/ "tao/Versioned_Namespace.h"
28 #include "ace/Cleanup.h"
31 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
33 /**
34 * @class TAO_Singleton
36 * @brief TAO-specific Singleton class
38 * TAO_Singletons are used by TAO to register TAO-specific
39 * singleton instances with the TAO_Object_Manager. This
40 * ensures that TAO singletons are isolated from ACE's
41 * Object_Manager, thus allowing TAO to be safely dynamically
42 * unloaded.
44 template <class TYPE, class ACE_LOCK>
45 class TAO_Singleton : public ACE_Cleanup
47 public:
48 /// Global access point to the Singleton.
49 static TYPE *instance ();
51 /// Cleanup method, used by @c ace_cleanup_destroyer to destroy the
52 /// singleton.
53 virtual void cleanup (void *param = 0);
55 /// Dump the state of the object.
56 static void dump ();
58 protected:
59 /// Default constructor.
60 TAO_Singleton ();
62 /// Contained instance.
63 TYPE instance_;
65 /// Pointer to the Singleton (ACE_Cleanup) instance.
66 static TAO_Singleton<TYPE, ACE_LOCK> *singleton_;
68 /// Get pointer to the TAO Singleton instance.
69 static TAO_Singleton<TYPE, ACE_LOCK> *&instance_i ();
72 /**
73 * @class TAO_TSS_Singleton
75 * @brief TAO-specific Singleton class
77 * TAO_Singletons are used by TAO to register TAO-specific
78 * singleton instances with the TAO_Object_Manager. This
79 * ensures that TAO singletons are isolated from ACE's
80 * Object_Manager, thus allowing TAO to be safely dynamically
81 * unloaded.
83 template <class TYPE, class ACE_LOCK>
84 class TAO_TSS_Singleton : public ACE_Cleanup,
85 private ACE_Copy_Disabled
87 public:
88 /// Global access point to the Singleton.
89 static TYPE *instance ();
91 /// Cleanup method, used by @c ace_cleanup_destroyer to destroy the
92 /// singleton.
93 virtual void cleanup (void *param = 0);
95 /// Dump the state of the object.
96 static void dump ();
98 protected:
99 /// Default constructor.
100 TAO_TSS_Singleton ();
102 /// Contained instance.
103 ACE_TSS_TYPE (TYPE) instance_;
105 /// Pointer to the Singleton (ACE_Cleanup) instance.
106 static TAO_TSS_Singleton<TYPE, ACE_LOCK> *singleton_;
108 /// Get pointer to the TAO TSS Singleton instance.
109 static TAO_TSS_Singleton<TYPE, ACE_LOCK> *&instance_i ();
112 TAO_END_VERSIONED_NAMESPACE_DECL
114 #if defined (__ACE_INLINE__)
115 #include "tao/TAO_Singleton.inl"
116 #endif /* __ACE_INLINE__ */
118 #include "tao/TAO_Singleton.cpp"
120 #include /**/ "ace/post.h"
122 #endif /* TAO_SINGLETON_H */