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 .


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 string.

Definition at line 42 of file Strategies_T.inl.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, LM_ERROR, and ACE_DLL_Strategy< SVC_HANDLER >::open().

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_LIB_TEXT ("%p\n"),
00056                 ACE_LIB_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 1234 of file Strategies_T.cpp.

References ACE_TRACE.

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

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 115 of file Strategies_T.cpp.

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

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

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 string.

Definition at line 97 of file Strategies_T.cpp.

References ACE_TCHAR, ACE_TRACE, and ACE_OS::strcpy().

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

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


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 .

Definition at line 234 of file Strategies_T.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:21:42 2006 for ACE by doxygen 1.3.6