Cleanup.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   Cleanup.h
00006  *
00007  *  Cleanup.h,v 1.9 2006/04/25 09:34:51 jwillemsen Exp
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  *  @author Jesper S. M|ller<stophph@diku.dk>
00011  *  @author and a cast of thousands...
00012  *
00013  *  Originally in OS.h.
00014  */
00015 //=============================================================================
00016 
00017 #ifndef ACE_CLEANUP_H
00018 # define ACE_CLEANUP_H
00019 
00020 # include /**/ "ace/pre.h"
00021 
00022 # include "ace/config-lite.h"
00023 
00024 # if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 #  pragma once
00026 # endif /* ACE_LACKS_PRAGMA_ONCE */
00027 
00028 #include "ace/ACE_export.h"
00029 
00030 #if (defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1)
00031 # include "ace/Global_Macros.h"
00032 # define ACE_CLEANUP_DESTROYER_NAME ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _ace_cleanup_destroyer)
00033 #else
00034 # define ACE_CLEANUP_DESTROYER_NAME ace_cleanup_destroyer
00035 #endif  /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
00036 
00037 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00038 
00039 /**
00040  * @class ACE_Cleanup
00041  *
00042  * @brief Base class for objects that are cleaned by ACE_Object_Manager.
00043  */
00044 class ACE_Export ACE_Cleanup
00045 {
00046 public:
00047   /// No-op constructor.
00048   ACE_Cleanup (void);
00049 
00050   /// Destructor.
00051   virtual ~ACE_Cleanup (void);
00052 
00053   /// Cleanup method that, by default, simply deletes itself.
00054   virtual void cleanup (void *param = 0);
00055 };
00056 
00057 // Adapter for cleanup, used by ACE_Object_Manager.
00058 extern "C" ACE_Export
00059 void ACE_CLEANUP_DESTROYER_NAME (ACE_Cleanup *, void *param = 0);
00060 
00061 /**
00062  * @class ACE_Cleanup_Info
00063  *
00064  * @brief Hold cleanup information for thread/process
00065  */
00066 class ACE_Export ACE_Cleanup_Info
00067 {
00068 public:
00069   /// Default constructor.
00070   ACE_Cleanup_Info (void);
00071 
00072   /// Equality operator.
00073   bool operator== (const ACE_Cleanup_Info &o) const;
00074 
00075   /// Inequality operator.
00076   bool operator!= (const ACE_Cleanup_Info &o) const;
00077 
00078   /// Point to object that gets passed into the <cleanup_hook_>.
00079   void *object_;
00080 
00081   /// Cleanup hook that gets called back.
00082   ACE_CLEANUP_FUNC cleanup_hook_;
00083 
00084   /// Parameter passed to the <cleanup_hook_>.
00085   void *param_;
00086 };
00087 
00088 class ACE_Cleanup_Info_Node;
00089 
00090 /**
00091  * @class ACE_OS_Exit_Info
00092  *
00093  * @brief Hold Object Manager cleanup (exit) information.
00094  *
00095  * For internal use by the ACE library, only.
00096  */
00097 class ACE_Export ACE_OS_Exit_Info
00098 {
00099 public:
00100   /// Default constructor.
00101   ACE_OS_Exit_Info (void);
00102 
00103   /// Destructor.
00104   ~ACE_OS_Exit_Info (void);
00105 
00106   /// Use to register a cleanup hook.
00107   int at_exit_i (void *object, ACE_CLEANUP_FUNC cleanup_hook, void *param);
00108 
00109   /// Look for a registered cleanup hook object.  Returns 1 if already
00110   /// registered, 0 if not.
00111   int find (void *object);
00112 
00113   /// Call all registered cleanup hooks, in reverse order of
00114   /// registration.
00115   void call_hooks ();
00116 
00117 private:
00118   /**
00119    * Keeps track of all registered objects.  The last node is only
00120    * used to terminate the list (it doesn't contain a valid
00121    * ACE_Cleanup_Info).
00122    */
00123   ACE_Cleanup_Info_Node *registered_objects_;
00124 };
00125 
00126 ACE_END_VERSIONED_NAMESPACE_DECL
00127 
00128 # if defined (ACE_HAS_INLINED_OSCALLS)
00129 #   if defined (ACE_INLINE)
00130 #     undef ACE_INLINE
00131 #   endif /* ACE_INLINE */
00132 #   define ACE_INLINE inline
00133 #   include "ace/Cleanup.inl"
00134 # endif /* ACE_HAS_INLINED_OSCALLS */
00135 
00136 # include /**/ "ace/post.h"
00137 #endif /* ACE_CLEANUP_H */

Generated on Thu Nov 9 09:41:48 2006 for ACE by doxygen 1.3.6