00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file PG_Group_Guard.h 00006 * 00007 * PG_Group_Guard.h,v 1.5 2006/03/14 06:14:34 jtc Exp 00008 * 00009 * @author Ossama Othman <ossama@uci.edu> 00010 */ 00011 //============================================================================= 00012 00013 00014 #ifndef TAO_PG_GROUP_GUARD_H 00015 #define TAO_PG_GROUP_GUARD_H 00016 00017 #include /**/ "ace/pre.h" 00018 00019 #include "ace/config-all.h" 00020 00021 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00022 #pragma once 00023 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00024 00025 #include "orbsvcs/PortableGroup/PG_Factory_Set.h" 00026 00027 #include "tao/PortableServer/PortableServerC.h" 00028 00029 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00030 00031 /// Forward declarations. 00032 class TAO_PG_GenericFactory; 00033 class TAO_PG_ObjectGroupManager; 00034 00035 /** 00036 * @class TAO_PG_Group_Guard 00037 * 00038 * @brief Guard implementation used to make object group cleanup 00039 * exception-safe. 00040 * 00041 * This guard's destructor performs cleanup of object group 00042 * resources. Thus, cleanup is performed when this guard goes out of 00043 * scope unless explicitly released from that responsibility. 00044 * 00045 * This guard is meant to be used internally by the 00046 * TAO_PG_GenericFactory class. 00047 */ 00048 class TAO_PG_Group_Guard 00049 { 00050 public: 00051 00052 /// Constructor. 00053 TAO_PG_Group_Guard (TAO_PG_GenericFactory & generic_factory, 00054 TAO_PG_Factory_Set & factory_set, 00055 TAO_PG_ObjectGroupManager & group_manager, 00056 const PortableServer::ObjectId & oid); 00057 00058 /// Destructor. 00059 ~TAO_PG_Group_Guard (void); 00060 00061 /// Relinquish cleanup responsibility. 00062 void release (void); 00063 00064 private: 00065 00066 /// Reference to the infrastructure TAO_PG_GenericFactory that 00067 /// created the below TAO_PG_Factory_Set. 00068 TAO_PG_GenericFactory & generic_factory_; 00069 00070 /// Reference to the TAO_PG_Factory_Set that contains all 00071 /// application-specific GenericFactory object references. 00072 TAO_PG_Factory_Set & factory_set_; 00073 00074 /// Reference to the TAO_PG_ObjectGroupManager that maintains the 00075 /// object group map. 00076 TAO_PG_ObjectGroupManager & group_manager_; 00077 00078 /// Reference to the ObjectId that is the map key necessary to 00079 /// unbind the corresponding object group map entry from the map 00080 /// upon destruction. 00081 const PortableServer::ObjectId & oid_; 00082 00083 /// Flag that dictates whether or not the destructor will perform 00084 /// cleanup. 00085 int released_; 00086 00087 }; 00088 00089 TAO_END_VERSIONED_NAMESPACE_DECL 00090 00091 #include /**/ "ace/post.h" 00092 00093 #endif /* TAO_PG_GROUP_GUARD_H */