3 //=============================================================================
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)
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include /**/ "tao/Versioned_Namespace.h"
28 #include "ace/Cleanup.h"
31 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
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
44 template <class TYPE
, class ACE_LOCK
>
45 class TAO_Singleton
: public ACE_Cleanup
48 /// Global access point to the Singleton.
49 static TYPE
*instance ();
51 /// Cleanup method, used by @c ace_cleanup_destroyer to destroy the
53 virtual void cleanup (void *param
= 0);
55 /// Dump the state of the object.
59 /// Default constructor.
62 /// Contained 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 ();
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
83 template <class TYPE
, class ACE_LOCK
>
84 class TAO_TSS_Singleton
: public ACE_Cleanup
,
85 private ACE_Copy_Disabled
88 /// Global access point to the Singleton.
89 static TYPE
*instance ();
91 /// Cleanup method, used by @c ace_cleanup_destroyer to destroy the
93 virtual void cleanup (void *param
= 0);
95 /// Dump the state of the object.
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 */