// -*- C++ -*- //============================================================================= /** * @file NT_Naming_Service.h * * $Id$ * * Run the TAO Naming Service as a Windows NT Service. * * * @author John Tucker and Mike Vitalo */ //============================================================================= #ifndef TAO_NT_NAMING_SERVICE_H #define TAO_NT_NAMING_SERVICE_H #include /**/ "ace/NT_Service.h" #if defined (ACE_WIN32) && !defined (ACE_LACKS_WIN32_SERVICES) #include /**/ "ace/Singleton.h" #include /**/ "ace/Synch.h" #include /**/ "tao/orbconf.h" /** * @class TAO_NT_Naming_Service * * @brief Run the TAO Naming Service as a Windows NT Service. */ class TAO_NT_Naming_Service : public ACE_NT_Service { public: typedef TAO_SYNCH_RECURSIVE_MUTEX MUTEX; // = Initialization and termination hooks. TAO_NT_Naming_Service (void); virtual ~TAO_NT_Naming_Service (void); /// We override because it handles stop requests /// privately. virtual void handle_control (DWORD control_code); /// We override so a 'stop' control code can pop /// the reactor off of its wait. virtual int handle_exception (ACE_HANDLE h); /// This is a virtual method inherited from ACE_NT_Service. virtual int svc (void); /// Initialize the objects argc_ and argv_ attributes values. virtual int init (int argc, ACE_TCHAR *argv[]); /// Helper function for setting or reporting command line args int set_args (const ACE_TCHAR *args); private: void arg_manip (char *args, DWORD arglen, bool query); void report_error (const ACE_TCHAR *format, const ACE_TCHAR *val, LONG result); // = Keep track of the "command-line" arguments. /// Argument count. int argc_; int argc_save_; /// Argument list. ACE_TCHAR **argv_; ACE_TCHAR **argv_save_; friend class ACE_Singleton; friend class AutoFinalizer; }; /** * A class with a "magic" constructor/desructor to call the inherited * from ACE_NT_Service report_status() when an instance of it goes out * of scope, should an exception occurs. */ class AutoFinalizer { public: AutoFinalizer (TAO_NT_Naming_Service &service); ~AutoFinalizer (); private: TAO_NT_Naming_Service &service_; }; typedef ACE_Singleton SERVICE; #endif /* ACE_WIN32 && !ACE_LACKS_WIN32_SERVICES */ #endif /* TAO_NT_NAMING_SERVER_H */