[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / Asynch_Connector.h
blob7c7969cc20d65c9953ddb8a54fe7e57514b64ff4
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Asynch_Connector.h
7 * $Id: Asynch_Connector.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Alexander Libman <alibman@ihug.com.au>
11 //=============================================================================
13 #ifndef ACE_ASYNCH_CONNECTOR_H
14 #define ACE_ASYNCH_CONNECTOR_H
15 #include /**/ "ace/pre.h"
17 #include /**/ "ace/config-all.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #if (defined (ACE_WIN32) || defined (ACE_HAS_AIO_CALLS)) && !defined(ACE_HAS_WINCE)
24 // This only works on platforms that support async i/o.
26 #include "ace/Asynch_IO.h"
27 #include "ace/INET_Addr.h"
29 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
31 // Forward declarations
32 class ACE_Message_Block;
34 /**
35 * @class ACE_Asynch_Connector
37 * @brief This class is an example of the Connector pattern. This class
38 * will establish new connections and create new HANDLER objects to handle
39 * the new connections.
41 * Unlike the ACE_Connector, however, this class is designed to
42 * be used asynchronously with the ACE Proactor framework.
45 template <class HANDLER>
46 class ACE_Asynch_Connector : public ACE_Handler
48 public:
49 /// A do nothing constructor.
50 ACE_Asynch_Connector (void);
52 /// Virtual destruction
53 virtual ~ACE_Asynch_Connector (void);
55 /**
56 * This opens asynch connector
58 virtual int open (bool pass_addresses = false,
59 ACE_Proactor *proactor = 0,
60 bool validate_new_connection = true);
62 /// This initiates a new asynchronous connect
63 virtual int connect (const ACE_INET_Addr &remote_sap,
64 const ACE_INET_Addr &local_sap =
65 (const ACE_INET_Addr &)ACE_Addr::sap_any,
66 int reuse_addr = 1,
67 const void *act = 0);
69 /**
70 * This cancels all pending accepts operations that were issued by
71 * the calling thread.
73 * @note On Windows, this method does not cancel connect operations
74 * issued by other threads.
76 * @note On POSIX, delegates cancelation to ACE_POSIX_Asynch_Connect.
78 virtual int cancel (void);
81 /**
82 * Template method to validate peer before service is opened.
83 * This method is called when the connection attempt completes,
84 * whether it succeeded or failed, if the @a validate_connection
85 * argument to @c open() was non-zero or the @c validate_new_connection()
86 * method is called to turn this feature on. The default implementation
87 * returns 0. Users can (and probably should) reimplement this method
88 * to learn about the success or failure of the connection attempt.
89 * If the connection completed successfully, this method can be used to
90 * perform validation of the peer using it's address, running an
91 * authentication procedure (such as SSL) or anything else necessary or
92 * desireable. The return value from this method determines whether or
93 * not ACE will continue opening the service or abort the connection.
95 * @param result Result of the connection acceptance. Use
96 * result.success() to determine success or failure of
97 * the connection attempt.
98 * @param remote Peer's address. If the connection failed, this object
99 * is undefined.
100 * @param local Local address connection was completed from. If the
101 * connection failed, this object is undefined.
103 * @retval -1 ACE_Asynch_Connector will close the connection, and
104 * the service will not be opened.
105 * @retval 0 Service opening will proceeed.
106 * @return Return value is ignored if the connection attempt failed.
108 virtual int validate_connection (const ACE_Asynch_Connect::Result& result,
109 const ACE_INET_Addr &remote,
110 const ACE_INET_Addr& local);
113 // These are low level tweaking methods
116 /// Set and get flag that indicates if parsing and passing of
117 /// addresses to the service_handler is necessary.
118 virtual bool pass_addresses (void) const;
119 virtual void pass_addresses (bool new_value);
121 /// Set and get flag that indicates if address validation is
122 /// required.
123 virtual bool validate_new_connection (void) const;
124 virtual void validate_new_connection (bool new_value);
126 protected:
128 /// This is called when an outstanding accept completes.
129 virtual void handle_connect (const ACE_Asynch_Connect::Result &result);
132 /// This parses the address from read buffer.
133 void parse_address (const ACE_Asynch_Connect::Result &result,
134 ACE_INET_Addr &remote_address,
135 ACE_INET_Addr &local_address);
137 /// Return the asynch Connect object.
138 ACE_Asynch_Connect & asynch_connect (void);
141 * This is the template method used to create new handler.
142 * Subclasses must overwrite this method if a new handler creation
143 * strategy is required.
145 virtual HANDLER *make_handler (void);
147 private:
149 /// Asynch_Connect used to make life easier :-)
150 ACE_Asynch_Connect asynch_connect_;
152 /// Flag that indicates if parsing of addresses is necessary.
153 bool pass_addresses_;
155 /// Flag that indicates if address validation is required.
156 bool validate_new_connection_;
159 ACE_END_VERSIONED_NAMESPACE_DECL
161 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
162 #include "ace/Asynch_Connector.cpp"
163 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
165 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
166 #pragma implementation ("Asynch_Connector.cpp")
167 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
169 #endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS */
170 #include /**/ "ace/post.h"
171 #endif /* ACE_ASYNCH_CONNECTOR_H */