summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/Notify_Service/NT_Notify_Service.h
blob: 1548b5606ec773f52fd15f4a6093b7cc09de5392 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    NT_Notify_Service.h
 *
 *  Run the TAO Notify Service as a Windows NT Service.
 *
 *  @author John Tucker <jtucker@infoglide.com>
 *  @author Mike Vitalo <mvitalo@infoglide.com>
 *  @author David Robison <drrobison@openroadsconsulting.com>
 */
//=============================================================================


#ifndef TAO_NT_NOTIFY_SERVICE_H
#define TAO_NT_NOTIFY_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_Notify_Service
 *
 * @brief Run the TAO Notify Service as a Windows NT Service.
 */
class TAO_NT_Notify_Service : public ACE_NT_Service
{
public:
  typedef TAO_SYNCH_RECURSIVE_MUTEX MUTEX;

  TAO_NT_Notify_Service (void);
  virtual ~TAO_NT_Notify_Service (void);

  /// We override <handle_control> because it handles stop requests
  /// privately.
  virtual void handle_control (DWORD control_code);

  /// We override <handle_exception> 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 ();

  /// 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<TAO_NT_Notify_Service, MUTEX>;
};

typedef ACE_Singleton<TAO_NT_Notify_Service, TAO_NT_Notify_Service::MUTEX> SERVICE;

#endif /* ACE_WIN32 && !ACE_LACKS_WIN32_SERVICES */
#endif /* TAO_NT_NOTIFY_SERVER_H */