diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-07-28 18:32:05 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-07-28 18:32:05 +0000 |
commit | a1213414bb568b49a39c02a16558684a0ad67e1e (patch) | |
tree | b5b9a6e78f03de5d6709600d1895ba7fb2926de3 | |
parent | 3bb5727bb7255cc85b7c4f0eb7afdfd87fc2185e (diff) | |
download | ATCD-a1213414bb568b49a39c02a16558684a0ad67e1e.tar.gz |
*** empty log message ***
-rw-r--r-- | ace/Service_Object.h | 28 | ||||
-rw-r--r-- | ace/Service_Object.i | 16 | ||||
-rw-r--r-- | netsvcs/servers/main.cpp | 29 |
3 files changed, 51 insertions, 22 deletions
diff --git a/ace/Service_Object.h b/ace/Service_Object.h index 7954ea3b8c6..ac7131b8266 100644 --- a/ace/Service_Object.h +++ b/ace/Service_Object.h @@ -86,6 +86,34 @@ protected: // Flags that control serivce behavior (particularly deletion). }; +class ACE_Export ACE_Service_Object_Ptr + // = TITLE + // This is a smart pointer that holds onto the associated + // <ACE_Service_Object> * until the current scope is left, at + // which point the object's <fini> hook is called. + // + // = DESCRIPTION + // This class is similar to the Standard C++ Library class + // <auto_ptr>. It is used in conjunction with statically linked + // <ACE_Service_Objects>, as shown in the + // ./netsvcs/server/main.cpp example. +{ +public: + // = Initialization and termination methods. + ACE_Service_Object_Ptr (ACE_Service_Object *so); + // Acquire ownership of the <so>. + + ~ACE_Service_Object_Ptr (void); + // Release the held <ACE_Service_Object> by calling its <fini> hook. + + ACE_Service_Object *operator-> (); + // Smart pointer to access the underlying <ACE_Service_Object>. + +private: + ACE_Service_Object *service_object_; + // Holds the service object until we're done. +}; + #if defined (__ACE_INLINE__) #include "ace/Service_Object.i" #endif /* __ACE_INLINE__ */ diff --git a/ace/Service_Object.i b/ace/Service_Object.i index e85fd0323bb..4ed2a422783 100644 --- a/ace/Service_Object.i +++ b/ace/Service_Object.i @@ -3,6 +3,22 @@ // Service_Object.i +ACE_Service_Object_Ptr::ACE_Service_Object_Ptr (ACE_Service_Object *so) + : service_object_ (so) +{ +} + +ACE_Service_Object_Ptr::~ACE_Service_Object_Ptr (void) +{ + this->service_object_->fini (); +} + +ACE_Service_Object * +ACE_Service_Object_Ptr::operator-> () +{ + return this->service_object_; +} + ACE_INLINE const void * ACE_Service_Type::object (void) const { diff --git a/netsvcs/servers/main.cpp b/netsvcs/servers/main.cpp index 237bb0b5f29..0f313da733d 100644 --- a/netsvcs/servers/main.cpp +++ b/netsvcs/servers/main.cpp @@ -9,21 +9,6 @@ #include "Server_Logging_Handler.h" #include "Logging_Strategy.h" -class Service_Ptr -{ -public: - Service_Ptr (ACE_Service_Object *so) - : service_object_ (so) {} - - ~Service_Ptr (void) { this->service_object_->fini (); } - - ACE_Service_Object *operator-> () { return this->service_object_; } - -private: - ACE_Service_Object *service_object_; - // Holds the service object until we're done. -}; - int main (int argc, char *argv[]) { @@ -57,14 +42,14 @@ main (int argc, char *argv[]) l_argv[0] = "-p " ACE_DEFAULT_NAME_SERVER_PORT_STR; l_argv[1] = 0; - Service_Ptr sp_1 = ACE_SVC_INVOKE (ACE_Name_Acceptor); + ACE_Service_Object_Ptr sp_1 = ACE_SVC_INVOKE (ACE_Name_Acceptor); if (sp_1->init (1, l_argv) == -1) ACE_ERROR ((LM_ERROR, "%p\n%a", "Name_Service", 1)); l_argv[0] = "-p " ACE_DEFAULT_TIME_SERVER_PORT_STR; l_argv[1] = 0; - Service_Ptr sp_2 = ACE_SVC_INVOKE (ACE_TS_Server_Acceptor); + ACE_Service_Object_Ptr sp_2 = ACE_SVC_INVOKE (ACE_TS_Server_Acceptor); if (sp_2->init (1, l_argv) == -1) ACE_ERROR ((LM_ERROR, "%p\n%a", "ACE_TS_Server_Acceptor", 1)); @@ -72,28 +57,28 @@ main (int argc, char *argv[]) l_argv[0] = argv[0]; l_argv[1] = "-p 10011"; l_argv[2] = 0; - Service_Ptr sp_3 = ACE_SVC_INVOKE (ACE_TS_Clerk_Processor); + ACE_Service_Object_Ptr sp_3 = ACE_SVC_INVOKE (ACE_TS_Clerk_Processor); if (sp_3->init (2, l_argv) == -1) ACE_ERROR ((LM_ERROR, "%p\n%a", "ACE_TS_Clerk_Processor", 1)); l_argv[0] = "-p " ACE_DEFAULT_TOKEN_SERVER_PORT_STR; l_argv[1] = 0; - Service_Ptr sp_4 = ACE_SVC_INVOKE (ACE_Token_Acceptor); + ACE_Service_Object_Ptr sp_4 = ACE_SVC_INVOKE (ACE_Token_Acceptor); if (sp_4->init (1, l_argv) == -1) ACE_ERROR ((LM_ERROR, "%p\n%a", "Token_Service", 1)); l_argv[0] = "-p " ACE_DEFAULT_LOGGING_SERVER_PORT_STR; l_argv[1] = 0; - Service_Ptr sp_5 = ACE_SVC_INVOKE (ACE_Server_Logging_Acceptor); + ACE_Service_Object_Ptr sp_5 = ACE_SVC_INVOKE (ACE_Server_Logging_Acceptor); if (sp_5->init (1, l_argv) == -1) ACE_ERROR ((LM_ERROR, "%p\n%a", "Logging_Service", 1)); l_argv[0] = "-p " ACE_DEFAULT_THR_LOGGING_SERVER_PORT_STR; l_argv[1] = 0; - Service_Ptr sp_6 = ACE_SVC_INVOKE (ACE_Thr_Server_Logging_Acceptor); + ACE_Service_Object_Ptr sp_6 = ACE_SVC_INVOKE (ACE_Thr_Server_Logging_Acceptor); if (sp_6->init (1, l_argv) == -1) ACE_ERROR ((LM_ERROR, "%p\n%a", "Thr_Logging_Service", 1)); @@ -104,7 +89,7 @@ main (int argc, char *argv[]) ACE_Reactor::run_event_loop (); - // Destructors of Service_Ptr's automagically call fini(). + // Destructors of ACE_Service_Object_Ptr's automagically call fini(). } else // Use dynamic linking. |