ACE_Connector< SVC_HANDLER, > Class Template Reference

Generic factory for actively connecting clients and creating service handlers (SVC_HANDLERs). More...

#include <Connector.h>

Inheritance diagram for ACE_Connector< SVC_HANDLER, >:

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

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_TYPENAME SVC_HANDLER::addr_type addr_type
typedef ACE_PEER_CONNECTOR connector_type
typedef SVC_HANDLER handler_type
typedef ACE_TYPENAME SVC_HANDLER::stream_type stream_type
typedef ACE_TYPENAME _ACE_PEER_CONNECTOR::PEER_ADDR ACE_TYPENAME_ACE_PEER_CONNECTOR_PEER_ADDR

Public Member Functions

 ACE_Connector (ACE_Reactor *r=ACE_Reactor::instance(), int flags=0)
virtual int open (ACE_Reactor *r=ACE_Reactor::instance(), int flags=0)
virtual ~ACE_Connector (void)
 Shutdown a connector and release resources.

virtual int connect (SVC_HANDLER *&svc_handler, const ACE_PEER_CONNECTOR_ADDR &remote_addr, const ACE_Synch_Options &synch_options=ACE_Synch_Options::defaults, const ACE_PEER_CONNECTOR_ADDR &local_addr=(ACE_TYPENAME_ACE_PEER_CONNECTOR_PEER_ADDR &) ACE_PEER_CONNECTOR_ADDR_ANY, int reuse_addr=0, int flags=O_RDWR, int perms=0)
virtual int connect (SVC_HANDLER *&svc_handler_hint, SVC_HANDLER *&svc_handler, const ACE_PEER_CONNECTOR_ADDR &remote_addr, const ACE_Synch_Options &synch_options=ACE_Synch_Options::defaults, const ACE_PEER_CONNECTOR_ADDR &local_addr=(ACE_TYPENAME_ACE_PEER_CONNECTOR_PEER_ADDR &) ACE_PEER_CONNECTOR_ADDR_ANY, int reuse_addr=0, int flags=O_RDWR, int perms=0)
virtual int connect_n (size_t n, SVC_HANDLER *svc_handlers[], ACE_PEER_CONNECTOR_ADDR remote_addrs[], ACE_TCHAR *failed_svc_handlers=0, const ACE_Synch_Options &synch_options=ACE_Synch_Options::defaults)
virtual int cancel (SVC_HANDLER *svc_handler)
virtual int close (void)
virtual ACE_PEER_CONNECTOR & connector (void) const
 Return the underlying PEER_CONNECTOR object.

virtual void initialize_svc_handler (ACE_HANDLE handle, SVC_HANDLER *svc_handler)
 Initialize Svc_Handler.

virtual void reactor (ACE_Reactor *reactor)
 Set Reactor.

virtual ACE_Reactorreactor (void) const
 Get Reactor.

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_NonBlocking_Connect_Handler<
SVC_HANDLER > 
NBCH

Protected Member Functions

virtual int make_svc_handler (SVC_HANDLER *&sh)
virtual int connect_svc_handler (SVC_HANDLER *&svc_handler, const ACE_PEER_CONNECTOR_ADDR &remote_addr, ACE_Time_Value *timeout, const ACE_PEER_CONNECTOR_ADDR &local_addr, int reuse_addr, int flags, int perms)
virtual int connect_svc_handler (SVC_HANDLER *&svc_handler, SVC_HANDLER *&sh_copy, const ACE_PEER_CONNECTOR_ADDR &remote_addr, ACE_Time_Value *timeout, const ACE_PEER_CONNECTOR_ADDR &local_addr, int reuse_addr, int flags, int perms)
virtual int activate_svc_handler (SVC_HANDLER *svc_handler)
int nonblocking_connect (SVC_HANDLER *, const ACE_Synch_Options &)
 Creates and registers ACE_NonBlocking_Connect_Handler.

virtual int connect_i (SVC_HANDLER *&svc_handler, SVC_HANDLER **sh_copy, const ACE_PEER_CONNECTOR_ADDR &remote_addr, const ACE_Synch_Options &synch_options, const ACE_PEER_CONNECTOR_ADDR &local_addr, int reuse_addr, int flags, int perms)
 Implementation the methods.

ACE_Unbounded_Set< ACE_HANDLE > & non_blocking_handles (void)
virtual int init (int argc, ACE_TCHAR *argv[])
virtual int fini (void)
 Calls to shutdown the Connector gracefully.

virtual int info (ACE_TCHAR **, size_t) const
 Default version returns address info in .

virtual int suspend (void)
virtual int resume (void)

Private Attributes

ACE_PEER_CONNECTOR connector_
 This is the peer connector factory.

int flags_
ACE_Reactorreactor_
 Pointer to the Reactor.

ACE_Unbounded_Set< ACE_HANDLE > non_blocking_handles_
 Handle set representing the non-blocking connects in progress.


Detailed Description

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1>
class ACE_Connector< SVC_HANDLER, >

Generic factory for actively connecting clients and creating service handlers (SVC_HANDLERs).

Implements the strategy for actively establishing connections with clients. An ACE_Connector is parameterized by concrete types that conform to the interfaces of PEER_CONNECTOR and SVC_HANDLER. The PEER_CONNECTOR is instantiated with a transport mechanism that actively establishes connections. The SVC_HANDLER is instantiated with a concrete type that performs the application-specific service. Both blocking and non-blocking connects are supported. Further, non-blocking connects support timeouts.

Definition at line 154 of file Connector.h.


Member Typedef Documentation

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
typedef ACE_TYPENAME _ACE_PEER_CONNECTOR::PEER_ADDR ACE_Connector< SVC_HANDLER, >::ACE_TYPENAME_ACE_PEER_CONNECTOR_PEER_ADDR
 

Definition at line 170 of file Connector.h.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
typedef ACE_TYPENAME SVC_HANDLER::addr_type ACE_Connector< SVC_HANDLER, >::addr_type
 

Definition at line 159 of file Connector.h.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
typedef ACE_PEER_CONNECTOR ACE_Connector< SVC_HANDLER, >::connector_type
 

Definition at line 160 of file Connector.h.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
typedef SVC_HANDLER ACE_Connector< SVC_HANDLER, >::handler_type
 

Definition at line 161 of file Connector.h.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
typedef ACE_NonBlocking_Connect_Handler<SVC_HANDLER> ACE_Connector< SVC_HANDLER, >::NBCH [protected]
 

Definition at line 283 of file Connector.h.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
typedef ACE_TYPENAME SVC_HANDLER::stream_type ACE_Connector< SVC_HANDLER, >::stream_type
 

Definition at line 162 of file Connector.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
ACE_Connector< SVC_HANDLER, >::ACE_Connector ACE_Reactor r = ACE_Reactor::instance(),
int  flags = 0
 

Initialize a connector. flags indicates how 's should be initialized prior to being activated. Right now, the only flag that is processed is ACE_NONBLOCK, which enabled non-blocking I/O on the when it is opened.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual ACE_Connector< SVC_HANDLER, >::~ACE_Connector void   )  [virtual]
 

Shutdown a connector and release resources.


Member Function Documentation

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::activate_svc_handler SVC_HANDLER *  svc_handler  )  [protected, virtual]
 

Bridge method for activating a with the appropriate concurrency strategy. The default behavior of this method is to activate the SVC_HANDLER by calling its method (which allows the SVC_HANDLER to define its own concurrency strategy). However, subclasses can override this strategy to do more sophisticated concurrency activations (such as creating the SVC_HANDLER as an "active object" via multi-threading or multi-processing).

Reimplemented in ACE_Strategy_Connector< SVC_HANDLER, >.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::cancel SVC_HANDLER *  svc_handler  )  [virtual]
 

Cancel a that was started asynchronously. Note that this is the only case when the Connector does not actively close the . It is left up to the caller of to decide the fate of the .

Referenced by ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::close().

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::close void   )  [virtual]
 

Close down the Connector. All pending non-blocking connects are canceled and the corresponding svc_handler is closed.

Reimplemented in ACE_Strategy_Connector< SVC_HANDLER, >.

Referenced by ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::fini(), and ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::~ACE_Connector().

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::connect SVC_HANDLER *&  svc_handler_hint,
SVC_HANDLER *&  svc_handler,
const ACE_PEER_CONNECTOR_ADDR &  remote_addr,
const ACE_Synch_Options synch_options = ACE_Synch_Options::defaults,
const ACE_PEER_CONNECTOR_ADDR &  local_addr = (ACE_TYPENAME_ACE_PEER_CONNECTOR_PEER_ADDR &) ACE_PEER_CONNECTOR_ADDR_ANY,
int  reuse_addr = 0,
int  flags = O_RDWR,
int  perms = 0
[virtual]
 

This is a variation on the previous method. On cached connectors the variable can be used as a hint for future lookups. Since this variable is modified in the context of the internal cache its use is thread-safe. But the actual svc_handler for the current connection is returned in the second parameter . If the connection fails the hook on the will be called automatically to prevent resource leaks.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::connect SVC_HANDLER *&  svc_handler,
const ACE_PEER_CONNECTOR_ADDR &  remote_addr,
const ACE_Synch_Options synch_options = ACE_Synch_Options::defaults,
const ACE_PEER_CONNECTOR_ADDR &  local_addr = (ACE_TYPENAME_ACE_PEER_CONNECTOR_PEER_ADDR &) ACE_PEER_CONNECTOR_ADDR_ANY,
int  reuse_addr = 0,
int  flags = O_RDWR,
int  perms = 0
[virtual]
 

Initiate connection of to peer at using . If the caller wants to designate the selected they can (and can also insist that the be reused by passing a value == 1). flags and can be used to pass any flags that are needed to perform specific operations such as opening a file within connect with certain permissions. If the connection fails the hook on the will be called automatically to prevent resource leaks.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::connect_i SVC_HANDLER *&  svc_handler,
SVC_HANDLER **  sh_copy,
const ACE_PEER_CONNECTOR_ADDR &  remote_addr,
const ACE_Synch_Options synch_options,
const ACE_PEER_CONNECTOR_ADDR &  local_addr,
int  reuse_addr,
int  flags,
int  perms
[protected, virtual]
 

Implementation the methods.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::connect_n size_t  n,
SVC_HANDLER *  svc_handlers[],
ACE_PEER_CONNECTOR_ADDR  remote_addrs[],
ACE_TCHAR failed_svc_handlers = 0,
const ACE_Synch_Options synch_options = ACE_Synch_Options::defaults
[virtual]
 

Initiate connection of to peers at using . Returns -1 if failure occurs and 0 otherwise. If is non-NULL, a 1 is placed in the corresponding index of for each <svc_handlers[i]> that failed to connect, else a 0 is placed in that index.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::connect_svc_handler SVC_HANDLER *&  svc_handler,
SVC_HANDLER *&  sh_copy,
const ACE_PEER_CONNECTOR_ADDR &  remote_addr,
ACE_Time_Value timeout,
const ACE_PEER_CONNECTOR_ADDR &  local_addr,
int  reuse_addr,
int  flags,
int  perms
[protected, virtual]
 

Reimplemented in ACE_Strategy_Connector< SVC_HANDLER, >.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::connect_svc_handler SVC_HANDLER *&  svc_handler,
const ACE_PEER_CONNECTOR_ADDR &  remote_addr,
ACE_Time_Value timeout,
const ACE_PEER_CONNECTOR_ADDR &  local_addr,
int  reuse_addr,
int  flags,
int  perms
[protected, virtual]
 

Bridge method for connecting the to the . The default behavior delegates to the <PEER_CONNECTOR::connect>.

Reimplemented in ACE_Strategy_Connector< SVC_HANDLER, >.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual ACE_PEER_CONNECTOR& ACE_Connector< SVC_HANDLER, >::connector void   )  const [virtual]
 

Return the underlying PEER_CONNECTOR object.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
void ACE_Connector< SVC_HANDLER, >::dump void   )  const
 

Dump the state of an object.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::fini void   )  [protected, virtual]
 

Calls to shutdown the Connector gracefully.

Reimplemented from ACE_Shared_Object.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::info ACE_TCHAR **  ,
size_t 
const [protected, virtual]
 

Default version returns address info in .

Reimplemented from ACE_Shared_Object.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::init int  argc,
ACE_TCHAR argv[]
[protected, virtual]
 

Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful.

Reimplemented from ACE_Shared_Object.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual void ACE_Connector< SVC_HANDLER, >::initialize_svc_handler ACE_HANDLE  handle,
SVC_HANDLER *  svc_handler
[virtual]
 

Initialize Svc_Handler.

Implements ACE_Connector_Base< SVC_HANDLER >.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::make_svc_handler SVC_HANDLER *&  sh  )  [protected, virtual]
 

Bridge method for creating a SVC_HANDLER. The default is to create a new SVC_HANDLER only if == 0, else is unchanged. However, subclasses can override this policy to perform SVC_HANDLER creation in any way that they like (such as creating subclass instances of SVC_HANDLER, using a singleton, dynamically linking the handler, etc.). Returns -1 if failure, else 0.

Reimplemented in ACE_Strategy_Connector< SVC_HANDLER, >.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
ACE_Unbounded_Set<ACE_HANDLE>& ACE_Connector< SVC_HANDLER, >::non_blocking_handles void   )  [protected, virtual]
 

Return the handle set representing the non-blocking connects in progress.

Implements ACE_Connector_Base< SVC_HANDLER >.

Referenced by ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::close().

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
int ACE_Connector< SVC_HANDLER, >::nonblocking_connect SVC_HANDLER *  ,
const ACE_Synch_Options
[protected]
 

Creates and registers ACE_NonBlocking_Connect_Handler.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::open ACE_Reactor r = ACE_Reactor::instance(),
int  flags = 0
[virtual]
 

Initialize a connector. flags indicates how 's should be initialized prior to being activated. Right now, the only flag that is processed is ACE_NONBLOCK, which enabled non-blocking I/O on the when it is opened.

Reimplemented in ACE_Strategy_Connector< SVC_HANDLER, >.

Referenced by ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::ACE_Connector().

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual ACE_Reactor* ACE_Connector< SVC_HANDLER, >::reactor void   )  const [virtual]
 

Get Reactor.

Reimplemented from ACE_Event_Handler.

Referenced by ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::cancel(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::close(), and ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::open().

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual void ACE_Connector< SVC_HANDLER, >::reactor ACE_Reactor reactor  )  [virtual]
 

Set Reactor.

Reimplemented from ACE_Event_Handler.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::resume void   )  [protected, virtual]
 

Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful.

Reimplemented from ACE_Service_Object.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
virtual int ACE_Connector< SVC_HANDLER, >::suspend void   )  [protected, virtual]
 

Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful.

Reimplemented from ACE_Service_Object.


Member Data Documentation

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
ACE_Connector< SVC_HANDLER, >::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 279 of file Connector.h.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
ACE_PEER_CONNECTOR ACE_Connector< SVC_HANDLER, >::connector_ [private]
 

This is the peer connector factory.

Definition at line 372 of file Connector.h.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
int ACE_Connector< SVC_HANDLER, >::flags_ [private]
 

Flags that indicate how 's should be initialized prior to being activated. Right now, the only flag that is processed is ACE_NONBLOCK, which enabled non-blocking I/O on the when it is opened.

Definition at line 380 of file Connector.h.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
ACE_Unbounded_Set<ACE_HANDLE> ACE_Connector< SVC_HANDLER, >::non_blocking_handles_ [private]
 

Handle set representing the non-blocking connects in progress.

Definition at line 386 of file Connector.h.

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1 >
ACE_Reactor* ACE_Connector< SVC_HANDLER, >::reactor_ [private]
 

Pointer to the Reactor.

Reimplemented from ACE_Event_Handler.

Definition at line 383 of file Connector.h.


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