3 //=============================================================================
5 * @file Dynamic_Service_Dependency.h
7 * $Id: Dynamic_Service_Dependency.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Iliyan Jeliazkov <iliyan@ociweb.com>
11 //=============================================================================
13 #ifndef ACE_DYNAMIC_SERVICE_DEPENDENCY_H
14 #define ACE_DYNAMIC_SERVICE_DEPENDENCY_H
16 #include /**/ "ace/pre.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/Dynamic_Service_Base.h"
24 #include "ace/Service_Object.h"
27 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 * @class ACE_Dynamic_Service_Dependency
32 * @brief Provides a way to declare dependency on specific service,
33 * thus helping to avoid order of initialization issues with instances
34 * of an objects whose implementation code resides in dynamically loaded
37 * It is disastrous to have dynamically loadable services create and give away
38 * ownership of objects and then ending up being unloaded before all those
39 * instances have been deleted. Normally the code for such objects classes
40 * resides within the TEXT segment of the DLL, which implements the service.
41 * If a service gets removed, its DLL may be unmapped from memory and then
42 * any attempt to invoke a method on the said objects will cause SEGV.
44 * Such instances must contain a member of ACE_Dynamic_Service_Dependency
45 * initialized with the service they depend on.
46 * ACE_Dynamic_Service_Dependency's constructor and destructor are
47 * "magical" - they work by maintaining the underlying dynamic service's
48 * DLL reference count.
50 class ACE_Export ACE_Dynamic_Service_Dependency
53 ACE_Dynamic_Service_Dependency (const ACE_Service_Gestalt
*cfg
,
54 const ACE_TCHAR
*principal
);
55 ACE_Dynamic_Service_Dependency (const ACE_TCHAR
*principal
);
56 ~ACE_Dynamic_Service_Dependency (void);
59 void init (const ACE_Service_Gestalt
*cfg
, const ACE_TCHAR
*principal
);
65 ACE_END_VERSIONED_NAMESPACE_DECL
68 #include /**/ "ace/post.h"
70 #endif /* ACE_DYNAMIC_SERVICE_DEPENDENCY_H */