Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_DLL_Strategy 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:

Inheritance graph
[legend]
Collaboration diagram for ACE_DLL_Strategy:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Creation_Strategy<
SVC_HANDLER > 
base_type

Public Methods

 ACE_DLL_Strategy (void)
 "Do-nothing" constructor. More...

 ACE_DLL_Strategy (const char dll_name[], const char factory_function[], const char 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. More...

int open (const char dll_name[], const char factory_function[], const char 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. More...

virtual int make_svc_handler (SVC_HANDLER *&)
 Create a SVC_HANDLER by dynamically linking it from a DLL. Returns -1 on failure, else 0. More...

void dump (void) const
 Dump the state of an object. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Types

typedef ACE_Creation_Strategy<
SVC_HANDLER > 
inherited

Protected Attributes

char dll_name_ [MAXPATHLEN+1]
 Name of the DLL to dynamically link. More...

char factory_function_ [MAXPATHLEN+1]
 Name of the factory function in the shared library to use to obtain a pointer to the new SVC_HANDLER. More...

char svc_name_ [MAXNAMELEN+1]
 Name of the service. More...

ACE_Service_Repositorysvc_rep_
 Pointer to the <Service_Repository>. More...


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 178 of file Strategies_T.h.


Member Typedef Documentation

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

Definition at line 183 of file Strategies_T.h.

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

Definition at line 218 of file Strategies_T.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER>
ASYS_INLINE ACE_DLL_Strategy< SVC_HANDLER >::ACE_DLL_Strategy void   
 

"Do-nothing" constructor.

Definition at line 116 of file Strategies_T.i.

References ACE_TRACE.

00117 {
00118   ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::ACE_DLL_Strategy");
00119 }

template<class SVC_HANDLER>
ASYS_INLINE ACE_DLL_Strategy< SVC_HANDLER >::ACE_DLL_Strategy const char    dll_name[],
const char    factory_function[],
const char    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 98 of file Strategies_T.i.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, and open.

00103 {
00104   ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::ACE_DLL_Strategy");
00105   if (this->open (dll_name,
00106                   factory_function,
00107                   svc_name,
00108                   svc_rep,
00109                   thr_mgr) == -1)
00110     ACE_ERROR ((LM_ERROR,
00111                 ACE_LIB_TEXT ("%p\n"),
00112                 ACE_LIB_TEXT ("open")));
00113 }


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.

Definition at line 1143 of file Strategies_T.cpp.

References ACE_TRACE.

01144 {
01145   ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::dump");
01146 }

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.

Definition at line 70 of file Strategies_T.cpp.

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

00071 {
00072   ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler");
00073 
00074   // Open the shared library.
00075   ACE_SHLIB_HANDLE handle = ACE_OS::dlopen (this->dll_name_);
00076 
00077   // Extract the factory function.
00078   SVC_HANDLER *(*factory)(void) =
00079     (SVC_HANDLER *(*)(void)) ACE_OS::dlsym (handle,
00080                                             this->factory_function_);
00081 
00082   // Call the factory function to obtain the new SVC_Handler (should
00083   // use RTTI here when it becomes available...)
00084   SVC_HANDLER *svc_handler;
00085 
00086   ACE_ALLOCATOR_RETURN (svc_handler, (*factory)(), -1);
00087 
00088   if (svc_handler != 0)
00089     {
00090       // Create an ACE_Service_Type containing the SVC_Handler and
00091       // insert into this->svc_rep_;
00092 
00093       ACE_Service_Type_Impl *stp;
00094       ACE_NEW_RETURN (stp,
00095                       ACE_Service_Object_Type (svc_handler,
00096                                                this->svc_name_),
00097                       -1);
00098 
00099       ACE_Service_Type *srp = 0;
00100 
00101       ACE_NEW_RETURN (srp,
00102                       ACE_Service_Type (this->svc_name_,
00103                                         stp,
00104                                         handle,
00105                                         1),
00106                       -1);
00107       if (srp == 0)
00108         {
00109           delete stp;
00110           errno = ENOMEM;
00111           return -1;
00112         }
00113 
00114       if (this->svc_rep_->insert (srp) == -1)
00115         return -1;
00116       // @@ Somehow, we need to deal with this->thr_mgr_...
00117     }
00118 
00119   sh = svc_handler;
00120   return 0;
00121 }

template<class SVC_HANDLER>
int ACE_DLL_Strategy< SVC_HANDLER >::open const char    dll_name[],
const char    factory_function[],
const char    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 52 of file Strategies_T.cpp.

References ACE_TRACE, ACE_OS_String::strcpy, and svc_rep_.

Referenced by ACE_DLL_Strategy.

00057 {
00058   ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::open");
00059   this->inherited::open (thr_mgr);
00060   ACE_OS::strcpy (this->dll_name_, dll_name);
00061   ACE_OS::strcpy (this->factory_function_, factory_function);
00062   ACE_OS::strcpy (this->svc_name_, svc_name);
00063   this->svc_rep_ = svc_rep;
00064   return 0;
00065 }


Member Data Documentation

template<class SVC_HANDLER>
ACE_DLL_Strategy::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Creation_Strategy.

Definition at line 215 of file Strategies_T.h.

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

Name of the DLL to dynamically link.

Definition at line 221 of file Strategies_T.h.

template<class SVC_HANDLER>
char ACE_DLL_Strategy::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 225 of file Strategies_T.h.

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

Name of the service.

Definition at line 228 of file Strategies_T.h.

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

Pointer to the <Service_Repository>.

Definition at line 231 of file Strategies_T.h.

Referenced by make_svc_handler, and open.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:47:18 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002