ACE_DLL_Strategy< SVC_HANDLER > Class Template Reference

Defines the interface for specifying a creation strategy for a SVC_HANDLER based on dynamic linking of the SVC_HANDLER. More...

#include <Strategies_T.h>

Inheritance diagram for ACE_DLL_Strategy< SVC_HANDLER >:

Inheritance graph
[legend]
Collaboration diagram for ACE_DLL_Strategy< SVC_HANDLER >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Creation_Strategy<
SVC_HANDLER > 
base_type

Public Member Functions

 ACE_DLL_Strategy (void)
 "Do-nothing" constructor.
 ACE_DLL_Strategy (const ACE_TCHAR dll_name[], const ACE_TCHAR factory_function[], const ACE_TCHAR svc_name[], ACE_Service_Repository *, ACE_Thread_Manager *=0)
int open (const ACE_TCHAR dll_name[], const ACE_TCHAR factory_function[], const ACE_TCHAR svc_name[], ACE_Service_Repository *, ACE_Thread_Manager *=0)
virtual int make_svc_handler (SVC_HANDLER *&)
void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Protected Types

typedef ACE_Creation_Strategy<
SVC_HANDLER > 
inherited

Protected Attributes

ACE_TCHAR dll_name_ [MAXPATHLEN+1]
 Name of the DLL to dynamically link.
ACE_TCHAR factory_function_ [MAXPATHLEN+1]
ACE_TCHAR svc_name_ [MAXNAMELEN+1]
 Name of the service.
ACE_Service_Repositorysvc_rep_
 Pointer to the <Service_Repository>.

Detailed Description

template<class SVC_HANDLER>
class ACE_DLL_Strategy< SVC_HANDLER >

Defines the interface for specifying a creation strategy for a SVC_HANDLER based on dynamic linking of the SVC_HANDLER.

Definition at line 181 of file Strategies_T.h.


Member Typedef Documentation

template<class SVC_HANDLER>
typedef ACE_Creation_Strategy<SVC_HANDLER> ACE_DLL_Strategy< SVC_HANDLER >::base_type

Definition at line 186 of file Strategies_T.h.

template<class SVC_HANDLER>
typedef ACE_Creation_Strategy<SVC_HANDLER> ACE_DLL_Strategy< SVC_HANDLER >::inherited [protected]

Definition at line 221 of file Strategies_T.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER>
ACE_INLINE ACE_DLL_Strategy< SVC_HANDLER >::ACE_DLL_Strategy ( void   ) 

"Do-nothing" constructor.

Definition at line 60 of file Strategies_T.inl.

References ACE_TRACE.

00061 {
00062   ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::ACE_DLL_Strategy");
00063 }

template<class SVC_HANDLER>
ACE_INLINE ACE_DLL_Strategy< SVC_HANDLER >::ACE_DLL_Strategy ( const ACE_TCHAR  dll_name[],
const ACE_TCHAR  factory_function[],
const ACE_TCHAR  svc_name[],
ACE_Service_Repository ,
ACE_Thread_Manager = 0 
)

Initialize the DLL strategy based upon the service's DLL information contained in the <svc_dll_info> string.

Definition at line 42 of file Strategies_T.inl.

References ACE_ERROR, ACE_TEXT, ACE_TRACE, and LM_ERROR.

00047 {
00048   ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::ACE_DLL_Strategy");
00049   if (this->open (dll_name,
00050                   factory_function,
00051                   svc_name,
00052                   svc_rep,
00053                   thr_mgr) == -1)
00054     ACE_ERROR ((LM_ERROR,
00055                 ACE_TEXT ("%p\n"),
00056                 ACE_TEXT ("open")));
00057 }


Member Function Documentation

template<class SVC_HANDLER>
void ACE_DLL_Strategy< SVC_HANDLER >::dump ( void   )  const

Dump the state of an object.

Reimplemented from ACE_Creation_Strategy< SVC_HANDLER >.

Definition at line 1233 of file Strategies_T.cpp.

References ACE_TRACE.

01234 {
01235 #if defined (ACE_HAS_DUMP)
01236   ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::dump");
01237 #endif /* ACE_HAS_DUMP */
01238 }

template<class SVC_HANDLER>
int ACE_DLL_Strategy< SVC_HANDLER >::make_svc_handler ( SVC_HANDLER *&   )  [virtual]

Create a SVC_HANDLER by dynamically linking it from a DLL. Returns -1 on failure, else 0.

Reimplemented from ACE_Creation_Strategy< SVC_HANDLER >.

Definition at line 114 of file Strategies_T.cpp.

References ACE_ALLOCATOR_RETURN, ACE_NEW_RETURN, ACE_TRACE, ACE_OS::dlopen(), and ACE_OS::dlsym().

00115 {
00116   ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler");
00117 
00118   // Open the shared library.
00119   ACE_SHLIB_HANDLE handle = ACE_OS::dlopen (this->dll_name_);
00120 
00121   // Extract the factory function.
00122 #if defined (ACE_OPENVMS)
00123   SVC_HANDLER *(*factory)(void) =
00124     (SVC_HANDLER *(*)(void)) ACE::ldsymbol (handle,
00125                                             this->factory_function_);
00126 #else
00127   SVC_HANDLER *(*factory)(void) =
00128     (SVC_HANDLER *(*)(void)) ACE_OS::dlsym (handle,
00129                                             this->factory_function_);
00130 #endif
00131 
00132   // Call the factory function to obtain the new SVC_Handler (should
00133   // use RTTI here when it becomes available...)
00134   SVC_HANDLER *svc_handler = 0;
00135 
00136   ACE_ALLOCATOR_RETURN (svc_handler, (*factory)(), -1);
00137 
00138   if (svc_handler != 0)
00139     {
00140       // Create an ACE_Service_Type containing the SVC_Handler and
00141       // insert into this->svc_rep_;
00142 
00143       ACE_Service_Type_Impl *stp = 0;
00144       ACE_NEW_RETURN (stp,
00145                       ACE_Service_Object_Type (svc_handler,
00146                                                this->svc_name_),
00147                       -1);
00148 
00149       ACE_Service_Type *srp = 0;
00150 
00151       ACE_NEW_RETURN (srp,
00152                       ACE_Service_Type (this->svc_name_,
00153                                         stp,
00154                                         handle,
00155                                         1),
00156                       -1);
00157       if (srp == 0)
00158         {
00159           delete stp;
00160           errno = ENOMEM;
00161           return -1;
00162         }
00163 
00164       if (this->svc_rep_->insert (srp) == -1)
00165         return -1;
00166       // @@ Somehow, we need to deal with this->thr_mgr_...
00167     }
00168 
00169   sh = svc_handler;
00170   return 0;
00171 }

template<class SVC_HANDLER>
int ACE_DLL_Strategy< SVC_HANDLER >::open ( const ACE_TCHAR  dll_name[],
const ACE_TCHAR  factory_function[],
const ACE_TCHAR  svc_name[],
ACE_Service_Repository ,
ACE_Thread_Manager = 0 
)

Initialize the DLL strategy based upon the service's DLL information contained in the <svc_dll_info> string.

Definition at line 96 of file Strategies_T.cpp.

References ACE_TRACE, ACE_OS::open(), ACE_OS::strcpy(), and ACE_DLL_Strategy< SVC_HANDLER >::svc_rep_.

00101 {
00102   ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::open");
00103   this->inherited::open (thr_mgr);
00104   ACE_OS::strcpy (this->dll_name_, dll_name);
00105   ACE_OS::strcpy (this->factory_function_, factory_function);
00106   ACE_OS::strcpy (this->svc_name_, svc_name);
00107   this->svc_rep_ = svc_rep;
00108   return 0;
00109 }


Member Data Documentation

template<class SVC_HANDLER>
ACE_DLL_Strategy< SVC_HANDLER >::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

Reimplemented from ACE_Creation_Strategy< SVC_HANDLER >.

Definition at line 218 of file Strategies_T.h.

template<class SVC_HANDLER>
ACE_TCHAR ACE_DLL_Strategy< SVC_HANDLER >::dll_name_[MAXPATHLEN+1] [protected]

Name of the DLL to dynamically link.

Definition at line 224 of file Strategies_T.h.

template<class SVC_HANDLER>
ACE_TCHAR ACE_DLL_Strategy< SVC_HANDLER >::factory_function_[MAXPATHLEN+1] [protected]

Name of the factory function in the shared library to use to obtain a pointer to the new SVC_HANDLER.

Definition at line 228 of file Strategies_T.h.

template<class SVC_HANDLER>
ACE_TCHAR ACE_DLL_Strategy< SVC_HANDLER >::svc_name_[MAXNAMELEN+1] [protected]

Name of the service.

Definition at line 231 of file Strategies_T.h.

template<class SVC_HANDLER>
ACE_Service_Repository* ACE_DLL_Strategy< SVC_HANDLER >::svc_rep_ [protected]

Pointer to the <Service_Repository>.

Definition at line 234 of file Strategies_T.h.

Referenced by ACE_DLL_Strategy< SVC_HANDLER >::open().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:04 2010 for ACE by  doxygen 1.4.7