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