Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Cleanup.h
blob08e26bac57c09ea99b4af76d653c13df78f8d509
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Cleanup.h
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 //=============================================================================
13 #ifndef ACE_CLEANUP_H
14 # define ACE_CLEANUP_H
16 # include /**/ "ace/pre.h"
18 # include "ace/config-lite.h"
20 # if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # 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)
32 #else
33 # define ACE_CLEANUP_DESTROYER_NAME ace_cleanup_destroyer
34 #endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
36 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
38 /**
39 * @class ACE_Cleanup
41 * @brief Base class for objects that are cleaned by ACE_Object_Manager.
43 class ACE_Export ACE_Cleanup
45 public:
46 /// No-op constructor.
47 ACE_Cleanup ();
49 /// Destructor.
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.
57 extern "C" ACE_Export
58 void ACE_CLEANUP_DESTROYER_NAME (ACE_Cleanup *, void *param = 0);
60 /**
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>
69 public:
70 ACE_Cleanup_Info_Node ();
71 ACE_Cleanup_Info_Node (void *object,
72 ACE_CLEANUP_FUNC cleanup_hook,
73 void *param,
74 const char *name);
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;
83 void* object();
85 ACE_CLEANUP_FUNC cleanup_hook ();
87 void *param ();
89 ACE_ALLOC_HOOK_DECLARE;
91 private:
92 /// Point to object that gets passed into the <cleanup_hook_>.
93 void *object_;
95 /// Cleanup hook that gets called back.
96 ACE_CLEANUP_FUNC cleanup_hook_;
98 /// Parameter passed to the <cleanup_hook_>.
99 void *param_;
101 /// Name of the cleanup object
102 const char *name_;
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.
112 * @internal
114 * For internal use by the ACE library, only.
116 class ACE_Export ACE_OS_Exit_Info
118 public:
119 /// Default constructor.
120 ACE_OS_Exit_Info ();
122 /// Destructor.
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
133 /// false if not.
134 bool remove (void *object);
136 /// Call all registered cleanup hooks, in reverse order of
137 /// registration.
138 void call_hooks ();
140 private:
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)
151 # undef 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 */