3 //=============================================================================
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 * @author Jesper S. M|ller<stophph@diku.dk>
9 * @author and a cast of thousands...
11 //=============================================================================
14 # define ACE_CLEANUP_H
16 # include /**/ "ace/pre.h"
18 # include "ace/config-lite.h"
20 # if !defined (ACE_LACKS_PRAGMA_ONCE)
22 # endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include /**/ "ace/ACE_export.h"
26 # include "ace/Intrusive_List.h"
27 # include "ace/Intrusive_List_Node.h"
29 #if (defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1)
30 # include "ace/Global_Macros.h"
31 # define ACE_CLEANUP_DESTROYER_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ace_cleanup_destroyer)
33 # define ACE_CLEANUP_DESTROYER_NAME ace_cleanup_destroyer
34 #endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
36 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
41 * @brief Base class for objects that are cleaned by ACE_Object_Manager.
43 class ACE_Export ACE_Cleanup
46 /// No-op constructor.
50 virtual ~ACE_Cleanup ();
52 /// Cleanup method that, by default, simply deletes itself.
53 virtual void cleanup (void *param
= 0);
56 /// Adapter for cleanup, used by ACE_Object_Manager.
58 void ACE_CLEANUP_DESTROYER_NAME (ACE_Cleanup
*, void *param
= 0);
61 * @class ACE_Cleanup_Info_Node
63 * @brief For maintaining a list of ACE_Cleanup_Info items.
65 * For internal use by ACE_Object_Manager.
67 class ACE_Cleanup_Info_Node
: public ACE_Intrusive_List_Node
<ACE_Cleanup_Info_Node
>
70 ACE_Cleanup_Info_Node ();
71 ACE_Cleanup_Info_Node (void *object
,
72 ACE_CLEANUP_FUNC cleanup_hook
,
75 ~ACE_Cleanup_Info_Node ();
77 /// Equality operator.
78 bool operator== (const ACE_Cleanup_Info_Node
&o
) const;
80 /// Inequality operator.
81 bool operator!= (const ACE_Cleanup_Info_Node
&o
) const;
85 ACE_CLEANUP_FUNC
cleanup_hook ();
89 ACE_ALLOC_HOOK_DECLARE
;
92 /// Point to object that gets passed into the <cleanup_hook_>.
95 /// Cleanup hook that gets called back.
96 ACE_CLEANUP_FUNC cleanup_hook_
;
98 /// Parameter passed to the <cleanup_hook_>.
101 /// Name of the cleanup object
105 typedef ACE_Intrusive_List
<ACE_Cleanup_Info_Node
> ACE_Cleanup_Info_Node_List
;
108 * @class ACE_OS_Exit_Info
110 * @brief Hold Object Manager cleanup (exit) information.
114 * For internal use by the ACE library, only.
116 class ACE_Export ACE_OS_Exit_Info
119 /// Default constructor.
123 ~ACE_OS_Exit_Info ();
125 /// Use to register a cleanup hook.
126 int at_exit_i (void *object
, ACE_CLEANUP_FUNC cleanup_hook
, void *param
, const char* name
= 0);
128 /// Look for a registered cleanup hook object. Returns true if already
129 /// registered, false if not.
130 bool find (void *object
);
132 /// Remove a registered cleanup hook object. Returns true if removed
134 bool remove (void *object
);
136 /// Call all registered cleanup hooks, in reverse order of
142 * Keeps track of all registered objects.
144 ACE_Cleanup_Info_Node_List registered_objects_
;
147 ACE_END_VERSIONED_NAMESPACE_DECL
149 # if defined (ACE_HAS_INLINED_OSCALLS)
150 # if defined (ACE_INLINE)
152 # endif /* ACE_INLINE */
153 # define ACE_INLINE inline
154 # include "ace/Cleanup.inl"
155 # endif /* ACE_HAS_INLINED_OSCALLS */
157 # include /**/ "ace/post.h"
158 #endif /* ACE_CLEANUP_H */