00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Dynamic_Service_Dependency.h 00006 * 00007 * Dynamic_Service_Dependency.h,v 4.3 2006/05/17 19:09:10 shuston Exp 00008 * 00009 * @author Iliyan Jeliazkov <iliyan@ociweb.com> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef ACE_DYNAMIC_SERVICE_DEPENDENCY_H 00014 #define ACE_DYNAMIC_SERVICE_DEPENDENCY_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 00019 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00020 # pragma once 00021 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00022 00023 #include "ace/Dynamic_Service_Base.h" 00024 #include "ace/Service_Object.h" 00025 #include "ace/DLL.h" 00026 00027 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00028 00029 /** 00030 * @class ACE_Dynamic_Service_Dependency 00031 * 00032 * @brief Provides a way to declare dependency on specific service, 00033 * thus helping to avoid order of initialization issues with instances 00034 * of an objects whose implementation code resides in dynamically loaded 00035 * services. 00036 * 00037 * It is disastrous to have dynamically loadable services create and give away 00038 * ownership of objects and then ending up being unloaded before all those 00039 * instances have been deleted. Normally the code for such objects classes 00040 * resides within the TEXT segment of the DLL, which implements the service. 00041 * If a service gets removed, its DLL may be unmapped from memory and then 00042 * any attempt to invoke a method on the said objects will cause SEGV. 00043 * 00044 * Such instances must contain a member of ACE_Dynamic_Service_Dependency 00045 * initialized with the service they depend on. 00046 * ACE_Dynamic_Service_Dependency's constructor and destructor are 00047 * "magical" - they work by maintaining the underlying dynamic service's 00048 * DLL reference count. 00049 */ 00050 class ACE_Export ACE_Dynamic_Service_Dependency 00051 { 00052 public: 00053 ACE_Dynamic_Service_Dependency (const ACE_Service_Gestalt *cfg, 00054 const ACE_TCHAR *principal); 00055 ACE_Dynamic_Service_Dependency (const ACE_TCHAR *principal); 00056 ~ACE_Dynamic_Service_Dependency (void); 00057 00058 private: 00059 void init (const ACE_Service_Gestalt *cfg, const ACE_TCHAR *principal); 00060 00061 private: 00062 ACE_DLL tracker_; 00063 }; 00064 00065 ACE_END_VERSIONED_NAMESPACE_DECL 00066 00067 00068 #include /**/ "ace/post.h" 00069 00070 #endif /* ACE_DYNAMIC_SERVICE_DEPENDENCY_H */