summaryrefslogtreecommitdiff
path: root/TAO/examples/Callback_Quoter/Consumer_Input_Handler.h
blob: bc45d738917c5ae446faec96e5e537f1f2eff070 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* -*- C++ -*- */
// $Id$

// ===========================================================
//
//
// = LIBRARY
//    TAO/examples/Callback_Quoter
//
// = FILENAME
//    Consumer_Input_Handler.h
//
// = DESCRIPTION
//    Definition of the Callback_Qouter Consumer Client class, Consumer_Input_Handler.
//
// = AUTHOR
//    Kirthika Parameswaran <kirthika@cs.wustl.edu>
//
// ===========================================================

#if !defined (CONSUMER_INPUT_HANDLER_H)
#define CONSUMER_INPUT_HANDLER_H

#include "ConsumerC.h"
#include "NotifierC.h"
#include "Consumer_i.h"
#include "ace/Read_Buffer.h"
#include "tao/TAO.h"
#include "orbsvcs/Naming/Naming_Utils.h"
#include "orbsvcs/CosNamingC.h"

class Consumer_Input_Handler : public ACE_Event_Handler
{
  // = TITLE
  //    Callback Quoter Consumer Client class.
  //
  // = DESCRIPTION
  //    Connects to the Callback Quoter server and
  //    registers the Consumer object with the it
  //    and receives the stock status from the Notifier.

public:
  // = Initialization and termination methods.
  Consumer_Input_Handler (void);
  // Constructor.

  ~Consumer_Input_Handler (void);
  // Destructor.

  int init (int argc, char *argv[]);
  // Initialize the client communication with the server.

  int run (void);
  // Start the ORB object.

  virtual int handle_input (ACE_HANDLE);
  // Handle the user input.

private:
  int read_ior (char *filename);
  // Function to read the server IOR from a file.

  int parse_args (void);
  // Parse the command line arguments.  Returns 0 on success, -1 on
  // error.

  int via_naming_service (void);
  // This method initialises the naming service and registers the
  // object with the POA.

  int argc_;
  // # of arguments on the command line.

  char **argv_;
  // arguments from command line.

  char *ior_;
  // IOR of the obj ref of the server.

  int shutdown_;
  // Flag for server shutdown.

  CORBA::Environment env_;
  // Environment variable.

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

  int use_naming_service_;
  // This variable denotes whether the naming service
  // is used or not.

  char *stock_name_;
  // the name of the stock the consumer is interested in.

  int threshold_value_;
  // the desired price of the stock.

  Notifier_var server_;
  // Server object ptr.

  CORBA::ORB_var orb_;
  // Our orb.

  Consumer_i *consumer_servant_;
  // The consumer object.

  Callback_Quoter::Consumer_var consumer_var_;
  // Pointer to the consumerobject registered with the ORB.

  int registered_;
  // Flag which notes whether the consumer has got registered with the
  // Notifier-server.

  int unregistered_;
  // Flag which notes whether the consumer has got unregistered from
  // the Notifier-server.
};

#define REGISTER_STRING "register"
// The string that the user must type to register the consumer with
// the Notifier_server.

#define UNREGISTER_STRING "unregister"
// The string that the user must type to unregister the consumer with
// the Notifier_server.

#define EXIT_STRING "quit"
// The string the user must type to quit the consumer client
// application.

#endif /* CONSUMER_INPUT_HANDLER_H */