summaryrefslogtreecommitdiff
path: root/TAO/examples/Event_Comm/Consumer_Handler.h
blob: 71e5acd405dd7443ebd72b5b1025e898695b04f9 (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
80
81
82
83
84
85
86
87
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    Consumer_Handler.h
 *
 *  Subclass of Corba_Handler that sets up the Consumer handler
 *  for use with the ACE ACE_Reactor.
 *
 *  @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu) and Pradeep Gore (pradeep@cs.wustl.edu)
 */
//=============================================================================


#ifndef _CONSUMER_HANDLER_H
#define _CONSUMER_HANDLER_H

#include "Event_Comm_i.h"
#include "orbsvcs/Naming/Naming_Client.h"
#include "orbsvcs/CosNamingC.h"

/**
 * @class Consumer_Handler
 *
 * @brief The Consumer_Handler class.
 *
 * Starts up the ORB, registers the <Event_Comm::Consumer>
 * servant with the orb and gets a reference to a <Notifier>
 * from the Naming Service.
 */
class Consumer_Handler
{
public:
  /// Constructor.
  Consumer_Handler ();

  /// Destructor.
 virtual ~Consumer_Handler () = default;

  /// Initializes the ORB, gets the Notifier reference from the Naming
  /// Service, and starts the servant for the Consumer object.
  int init (int argc, ACE_TCHAR *argv[], ShutdownCallback *_shutdowncallback);

  /// runs the ORB.
  int run ();

  /// shutdown the orb.
  void close ();

  /// called to shutdown the consumer application.
  void shutdown ();

  // = Accessors
  Event_Comm::Consumer *receiver ();
  Event_Comm::Notifier *notifier ();

  /// returns the ORB's reactor.
  ACE_Reactor *reactor ();

private:
  /// gets the notifier reference from the naming service.
  /// returns 0 on success, -1 on error.
  int get_notifier ();

  /// Remember our orb.
  CORBA::ORB_var orb_;

  /// The <Consumer> implementation.
  Consumer_i receiver_i_;

  /// Pointer to an IDL <Consumer> proxy object.
  Event_Comm::Consumer_var receiver_;

  /// Pointer to an IDL <Notifier> proxy object.
  Event_Comm::Notifier_var notifier_;

  /// An instance of the name client used for resolving the factory
  /// objects.
  TAO_Naming_Client naming_services_client_;

  /// The Shutdown callback used to shutdown the consumer application.
  ShutdownCallback* shutdowncallback;
};

#define NOTIFIER_BIND_NAME "Notifier"

#endif /* _CONSUMER_HANDLER_H */