diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2013-04-04 16:29:51 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2013-04-04 16:29:51 +0000 |
commit | 8cd7cd2d207337d4d6b736d35864875503a89cde (patch) | |
tree | 80a59d7f61c21c3d42c74f38da45eeeb6114c4f4 | |
parent | 28f50fa84bb74f6c04ddf8f3455d3b22aa03bbef (diff) | |
download | ATCD-8cd7cd2d207337d4d6b736d35864875503a89cde.tar.gz |
ChangeLogTag:Thu
4 files changed, 80 insertions, 111 deletions
diff --git a/ACE/examples/Connection/non_blocking/CPP-acceptor.cpp b/ACE/examples/Connection/non_blocking/CPP-acceptor.cpp index 608745d721f..314c004cdb4 100644 --- a/ACE/examples/Connection/non_blocking/CPP-acceptor.cpp +++ b/ACE/examples/Connection/non_blocking/CPP-acceptor.cpp @@ -9,23 +9,14 @@ #include "ace/OS_NS_unistd.h" #include "ace/Signal.h" - - -#define PR_ST_1 ACE_PEER_STREAM_1 -#define PR_ST_2 ACE_PEER_STREAM_2 -#define PR_AC_1 ACE_PEER_ACCEPTOR_1 -#define PR_AC_2 ACE_PEER_ACCEPTOR_2 -#define PR_AD ACE_PEER_STREAM_ADDR -#define SVH SVC_HANDLER - -template <PR_ST_1> -Svc_Handler<PR_ST_2>::Svc_Handler (ACE_Reactor *r) +template <typename PEER_STREAM> +Svc_Handler<PEER_STREAM>::Svc_Handler (ACE_Reactor *r) : SVC_HANDLER (0, 0, r) { } -template <PR_ST_1> int -Svc_Handler<PR_ST_2>::close (u_long) +template <typename PEER_STREAM> int +Svc_Handler<PEER_STREAM>::close (u_long) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("calling Svc_Handler close\n"))); @@ -34,10 +25,10 @@ Svc_Handler<PR_ST_2>::close (u_long) return 0; } -template <PR_ST_1> int -Svc_Handler<PR_ST_2>::open (void *) +template <typename PEER_STREAM> int +Svc_Handler<PEER_STREAM>::open (void *) { - PR_AD client_addr; + typename PEER_STREAM::PEER_ADDR client_addr; ACE_TCHAR buf[BUFSIZ]; if (this->peer ().get_remote_addr (client_addr) == -1) @@ -64,8 +55,8 @@ Svc_Handler<PR_ST_2>::open (void *) // Receive and process the data from the client. -template <PR_ST_1> int -Svc_Handler<PR_ST_2>::handle_input (ACE_HANDLE) +template <typename PEER_STREAM> int +Svc_Handler<PEER_STREAM>::handle_input (ACE_HANDLE) { char buf[BUFSIZ]; @@ -94,16 +85,16 @@ Svc_Handler<PR_ST_2>::handle_input (ACE_HANDLE) return 0; } -template <PR_ST_1> int -Svc_Handler<PR_ST_2>::handle_timeout (const ACE_Time_Value &, +template <typename PEER_STREAM> int +Svc_Handler<PEER_STREAM>::handle_timeout (const ACE_Time_Value &, const void *) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%p\n"), ACE_TEXT ("handle_timeout"))); return 0; } -template <class SVH, PR_AC_1> int -IPC_Server<SVH, PR_AC_2>::init (int argc, ACE_TCHAR *argv[]) +template <typename SVC_HANDLER, typename PEER_ACCEPTOR> int +IPC_Server<SVC_HANDLER, PEER_ACCEPTOR>::init (int argc, ACE_TCHAR *argv[]) { const ACE_TCHAR *local_addr = argc > 1 ? argv[1] @@ -155,25 +146,25 @@ IPC_Server<SVH, PR_AC_2>::init (int argc, ACE_TCHAR *argv[]) return 0; } -template <class SVH, PR_AC_1> -IPC_Server<SVH, PR_AC_2>::IPC_Server (void) +template <typename SVC_HANDLER, typename PEER_ACCEPTOR> +IPC_Server<SVC_HANDLER, PEER_ACCEPTOR>::IPC_Server (void) : done_handler_ (ACE_Sig_Handler_Ex (ACE_Reactor::end_event_loop)) { } -template <class SVH, PR_AC_1> int -IPC_Server<SVH, PR_AC_2>::fini (void) +template <typename SVC_HANDLER, typename PEER_ACCEPTOR> int +IPC_Server<SVC_HANDLER, PEER_ACCEPTOR>::fini (void) { return 0; } -template <class SVH, PR_AC_1> -IPC_Server<SVH, PR_AC_2>::~IPC_Server (void) +template <typename SVC_HANDLER, typename PEER_ACCEPTOR> +IPC_Server<SVC_HANDLER, PEER_ACCEPTOR>::~IPC_Server (void) { } -template <class SVH, PR_AC_1> int -IPC_Server<SVH, PR_AC_2>::handle_close (ACE_HANDLE handle, +template <typename SVC_HANDLER, typename PEER_ACCEPTOR> int +IPC_Server<SVC_HANDLER, PEER_ACCEPTOR>::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask mask) { ACE_UNUSED_ARG (handle); @@ -186,8 +177,8 @@ IPC_Server<SVH, PR_AC_2>::handle_close (ACE_HANDLE handle, // Run the interative service. -template <class SVH, PR_AC_1> int -IPC_Server<SVH, PR_AC_2>::svc (void) +template <typename SVC_HANDLER, typename PEER_ACCEPTOR> int +IPC_Server<SVC_HANDLER, PEER_ACCEPTOR>::svc (void) { ACE_TCHAR buf[BUFSIZ]; @@ -207,9 +198,9 @@ IPC_Server<SVH, PR_AC_2>::svc (void) while (ACE_Reactor::event_loop_done () == 0) { - SVH sh (this->reactor ()); + SVC_HANDLER sh (this->reactor ()); - // Create a new <SVH> endpoint, which performs all processing in + // Create a new <SVC_HANDLER> endpoint, which performs all processing in // its <open> method (note no automatic restart if errno == // EINTR). @@ -230,7 +221,7 @@ IPC_Server<SVH, PR_AC_2>::svc (void) this->acceptor ().get_handle ())); } - // <SVH>'s destructor closes the stream implicitly but the + // <SVC_HANDLER>'s destructor closes the stream implicitly but the // listening endpoint stays open. } @@ -238,10 +229,4 @@ IPC_Server<SVH, PR_AC_2>::svc (void) return 0; } -#undef PR_ST_1 -#undef PR_ST_2 -#undef PR_AC_1 -#undef PR_AC_2 -#undef PR_AD -#undef SVH #endif /* CPP_ACCEPTOR_C */ diff --git a/ACE/examples/Connection/non_blocking/CPP-acceptor.h b/ACE/examples/Connection/non_blocking/CPP-acceptor.h index c06caf50b48..7d3ccfd4be4 100644 --- a/ACE/examples/Connection/non_blocking/CPP-acceptor.h +++ b/ACE/examples/Connection/non_blocking/CPP-acceptor.h @@ -13,9 +13,8 @@ #include "ace/Svc_Handler.h" #include "ace/Sig_Adapter.h" - -template <ACE_PEER_STREAM_1> -class Svc_Handler : public ACE_Svc_Handler <ACE_PEER_STREAM_2, ACE_NULL_SYNCH> +template <typename PEER_STREAM> +class Svc_Handler : public ACE_Svc_Handler <PEER_STREAM, ACE_NULL_SYNCH> { // = TITLE // This class does the work once the <ACE_Oneshot_Acceptor> has @@ -37,12 +36,12 @@ public: // Handles acceptor timeouts. private: - typedef ACE_Svc_Handler <ACE_PEER_STREAM_2, ACE_NULL_SYNCH> + typedef ACE_Svc_Handler <PEER_STREAM, ACE_NULL_SYNCH> SVC_HANDLER; }; -template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> -class IPC_Server : public ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> +template <typename SVC_HANDLER, typename PEER_ACCEPTOR> +class IPC_Server : public ACE_Oneshot_Acceptor<SVC_HANDLER, PEER_ACCEPTOR> { // = TITLE // This class illustrates how the <ACE_Oneshot_Acceptor> works. @@ -71,10 +70,10 @@ public: // Run the interative service. private: - typedef ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> + typedef ACE_Oneshot_Acceptor<SVC_HANDLER, PEER_ACCEPTOR> inherited; - ACE_PEER_ACCEPTOR_ADDR server_addr_; + typename PEER_ACCEPTOR::PEER_ADDR server_addr_; // Address of this server. ACE_Synch_Options options_; diff --git a/ACE/examples/Connection/non_blocking/CPP-connector.cpp b/ACE/examples/Connection/non_blocking/CPP-connector.cpp index a856a88f8af..eb92e82bd2b 100644 --- a/ACE/examples/Connection/non_blocking/CPP-connector.cpp +++ b/ACE/examples/Connection/non_blocking/CPP-connector.cpp @@ -8,29 +8,20 @@ #include "ace/OS_NS_unistd.h" #include "ace/Signal.h" - - -#define PR_ST_1 ACE_PEER_STREAM_1 -#define PR_ST_2 ACE_PEER_STREAM_2 -#define PR_CO_1 ACE_PEER_CONNECTOR_1 -#define PR_CO_2 ACE_PEER_CONNECTOR_2 -#define PR_AD ACE_PEER_CONNECTOR_ADDR -#define SVH SVC_HANDLER - -template <PR_ST_1> -Peer_Handler<PR_ST_2>::Peer_Handler (ACE_Reactor *r) - : action_ (&Peer_Handler<PR_ST_2>::uninitialized) +template <typename PEER_STREAM> +Peer_Handler<PEER_STREAM>::Peer_Handler (ACE_Reactor *r) + : action_ (&Peer_Handler<PEER_STREAM>::uninitialized) { this->reactor (r); } -template <PR_ST_1> int -Peer_Handler<PR_ST_2>::open (void *) +template <typename PEER_STREAM> int +Peer_Handler<PEER_STREAM>::open (void *) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("activating %d\n"), this->peer ().get_handle ())); - this->action_ = &Peer_Handler<PR_ST_2>::connected; + this->action_ = &Peer_Handler<PEER_STREAM>::connected; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("please enter input..: "))); @@ -59,8 +50,8 @@ Peer_Handler<PR_ST_2>::open (void *) return 0; } -template <PR_ST_1> int -Peer_Handler<PR_ST_2>::close (u_long) +template <typename PEER_STREAM> int +Peer_Handler<PEER_STREAM>::close (u_long) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Connect not successful: ending reactor event loop\n"))); @@ -68,15 +59,15 @@ Peer_Handler<PR_ST_2>::close (u_long) return 0; } -template <PR_ST_1> int -Peer_Handler<PR_ST_2>::uninitialized (void) +template <typename PEER_STREAM> int +Peer_Handler<PEER_STREAM>::uninitialized (void) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("uninitialized!\n"))); return 0; } -template <PR_ST_1> int -Peer_Handler<PR_ST_2>::connected (void) +template <typename PEER_STREAM> int +Peer_Handler<PEER_STREAM>::connected (void) { char buf[BUFSIZ]; @@ -106,8 +97,8 @@ Peer_Handler<PR_ST_2>::connected (void) } } -template <PR_ST_1> int -Peer_Handler<PR_ST_2>::stdio (void) +template <typename PEER_STREAM> int +Peer_Handler<PEER_STREAM>::stdio (void) { char buf[BUFSIZ]; @@ -131,26 +122,26 @@ Peer_Handler<PR_ST_2>::stdio (void) return -1; } -template <PR_ST_1> int -Peer_Handler<PR_ST_2>::handle_timeout (const ACE_Time_Value &, +template <typename PEER_STREAM> int +Peer_Handler<PEER_STREAM>::handle_timeout (const ACE_Time_Value &, const void *) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Connect timedout. "))); return this->close (); } -template <PR_ST_1> int -Peer_Handler<PR_ST_2>::handle_output (ACE_HANDLE) +template <typename PEER_STREAM> int +Peer_Handler<PEER_STREAM>::handle_output (ACE_HANDLE) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("in handle_output\n"))); return (this->*action_) (); } -template <PR_ST_1> int -Peer_Handler<PR_ST_2>::handle_signal (int, - siginfo_t *, - ucontext_t *) +template <typename PEER_STREAM> int +Peer_Handler<PEER_STREAM>::handle_signal (int, + siginfo_t *, + ucontext_t *) { // @@ Note that this code is not portable to all OS platforms since // it uses print statements within signal handler context. @@ -159,16 +150,16 @@ Peer_Handler<PR_ST_2>::handle_signal (int, return (this->*action_) (); } -template <PR_ST_1> int -Peer_Handler<PR_ST_2>::handle_input (ACE_HANDLE) +template <typename PEER_STREAM> int +Peer_Handler<PEER_STREAM>::handle_input (ACE_HANDLE) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("in handle_input\n"))); return (this->*action_) (); } -template <PR_ST_1> int -Peer_Handler<PR_ST_2>::handle_close (ACE_HANDLE h, +template <typename PEER_STREAM> int +Peer_Handler<PEER_STREAM>::handle_close (ACE_HANDLE h, ACE_Reactor_Mask mask) { ACE_DEBUG ((LM_DEBUG, @@ -176,7 +167,7 @@ Peer_Handler<PR_ST_2>::handle_close (ACE_HANDLE h, h, mask)); - if (this->action_ == &Peer_Handler<PR_ST_2>::stdio) + if (this->action_ == &Peer_Handler<PEER_STREAM>::stdio) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("moving to closed state\n"))); this->reactor ()->end_reactor_event_loop (); @@ -184,7 +175,7 @@ Peer_Handler<PR_ST_2>::handle_close (ACE_HANDLE h, else { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("moving to stdio state\n"))); - this->action_ = &Peer_Handler<PR_ST_2>::stdio; + this->action_ = &Peer_Handler<PEER_STREAM>::stdio; this->peer ().close (); ACE_OS::rewind (stdin); @@ -208,8 +199,8 @@ Peer_Handler<PR_ST_2>::handle_close (ACE_HANDLE h, return 0; } -template <class SVH, PR_CO_1> int -IPC_Client<SVH, PR_CO_2>::svc (void) +template <typename SVC_HANDLER, typename PEER_CONNECTOR> int +IPC_Client<SVC_HANDLER, PEER_CONNECTOR>::svc (void) { if (this->reactor ()) this->reactor ()->run_reactor_event_loop (); @@ -217,20 +208,20 @@ IPC_Client<SVH, PR_CO_2>::svc (void) return 0; } -template <class SVH, PR_CO_1> int -IPC_Client<SVH, PR_CO_2>::fini (void) +template <typename SVC_HANDLER, typename PEER_CONNECTOR> int +IPC_Client<SVC_HANDLER, PEER_CONNECTOR>::fini (void) { return 0; } -template <class SVH, PR_CO_1> -IPC_Client<SVH, PR_CO_2>::IPC_Client (void) +template <typename SVC_HANDLER, typename PEER_CONNECTOR> +IPC_Client<SVC_HANDLER, PEER_CONNECTOR>::IPC_Client (void) : done_handler_ (ACE_Sig_Handler_Ex (ACE_Reactor::end_event_loop)) { } -template <class SVH, PR_CO_1> int -IPC_Client<SVH, PR_CO_2>::init (int argc, ACE_TCHAR *argv[]) +template <typename SVC_HANDLER, typename PEER_CONNECTOR> int +IPC_Client<SVC_HANDLER, PEER_CONNECTOR>::init (int argc, ACE_TCHAR *argv[]) { // Call down to the CONNECTOR's open() method to do the // initialization. @@ -251,13 +242,13 @@ IPC_Client<SVH, PR_CO_2>::init (int argc, ACE_TCHAR *argv[]) ACE_TEXT ("%p\n"), ACE_TEXT ("register_handler")), -1); - PR_AD remote_addr (r_addr); + typename PEER_CONNECTOR::PEER_ADDR remote_addr (r_addr); this->options_.set (ACE_Synch_Options::USE_REACTOR, timeout); - SVH *sh; + SVC_HANDLER *sh; ACE_NEW_RETURN (sh, - SVH (this->reactor ()), + SVC_HANDLER (this->reactor ()), -1); // Connect to the peer. @@ -273,15 +264,9 @@ IPC_Client<SVH, PR_CO_2>::init (int argc, ACE_TCHAR *argv[]) return 0; } -template <class SVH, PR_CO_1> -IPC_Client<SVH, PR_CO_2>::~IPC_Client (void) +template <typename SVC_HANDLER, typename PEER_CONNECTOR> +IPC_Client<SVC_HANDLER, PEER_CONNECTOR>::~IPC_Client (void) { } -#undef PR_ST_1 -#undef PR_ST_2 -#undef PR_CO_1 -#undef PR_CO_2 -#undef PR_AD -#undef SVH #endif /* CPP_CONNECTOR_C */ diff --git a/ACE/examples/Connection/non_blocking/CPP-connector.h b/ACE/examples/Connection/non_blocking/CPP-connector.h index 86ce63493f0..5f11cbf27e0 100644 --- a/ACE/examples/Connection/non_blocking/CPP-connector.h +++ b/ACE/examples/Connection/non_blocking/CPP-connector.h @@ -14,8 +14,8 @@ #include "ace/Svc_Handler.h" #include "ace/Sig_Adapter.h" -template <ACE_PEER_STREAM_1> -class Peer_Handler : public ACE_Svc_Handler<ACE_PEER_STREAM_2, ACE_SYNCH> +template <typename PEER_STREAM> +class Peer_Handler : public ACE_Svc_Handler<PEER_STREAM, ACE_SYNCH> { // = TITLE // Handles communication with the server. @@ -48,12 +48,12 @@ protected: int connected (void); int stdio (void); - int (Peer_Handler<ACE_PEER_STREAM_2>::*action_) (void); + int (Peer_Handler<PEER_STREAM>::*action_) (void); // Keeps track of which state we are in. }; -template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> -class IPC_Client : public ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2> +template <typename SVC_HANDLER, typename PEER_CONNECTOR> +class IPC_Client : public ACE_Connector<SVC_HANDLER, PEER_CONNECTOR> { // = TITLE // This class illustrates how the <ACE_Connector> works. @@ -76,7 +76,7 @@ public: // Run the svc. private: - typedef ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2> + typedef ACE_Connector<SVC_HANDLER, PEER_CONNECTOR> inherited; ACE_Synch_Options options_; |