Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / examples / Callback_Quoter / Consumer_Handler.h
blobc21f2fbbb44f5254c57fdb7178ebb4046b2cd574
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Consumer_Handler.h
7 * Definition of the Callback_Qouter Consumer Client class, Consumer_Handler.
9 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
11 //=============================================================================
14 #ifndef CONSUMER_HANDLER_H
15 #define CONSUMER_HANDLER_H
17 #include "ConsumerC.h"
18 #include "NotifierC.h"
19 #include "Consumer_i.h"
20 #include "ace/Read_Buffer.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 # pragma once
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include "orbsvcs/Naming/Naming_Client.h"
27 #include "orbsvcs/CosNamingC.h"
29 #include "Consumer_Input_Handler.h"
30 #include "Consumer_Signal_Handler.h"
32 class Consumer_Input_Handler;
33 class Consumer_Signal_Handler;
35 /**
36 * @class Consumer_Handler
38 * @brief Callback Quoter Consumer Client class.
40 * Connects to the Callback Quoter server and
41 * registers the Consumer object with the it
42 * and receives the stock status from the Notifier.
44 class Consumer_Handler
46 public:
47 /// Constructor.
48 Consumer_Handler (void);
50 /// Destructor.
51 ~Consumer_Handler (void);
53 /// Initialize the client communication with the server.
54 int init (int argc, ACE_TCHAR *argv[]);
56 /// Start the ORB object.
57 int run (void);
59 /// the name of the stock the consumer is interested in.
60 ACE_CString stock_name_;
62 /// the desired price of the stock.
63 int threshold_value_;
65 /// Server object ptr.
66 Notifier_var server_;
68 /// The consumer object.
69 Consumer_i *consumer_servant_;
71 /// Pointer to the consumer object registered with the ORB.
72 Callback_Quoter::Consumer_var consumer_var_;
74 /// This method gives the reactor pointer.
75 ACE_Reactor* reactor_used (void) const;
77 /// Flag which notes whether the consumer has got registered with the
78 /// Notifier-server.
79 int registered_;
81 /// Flag which notes whether the consumer has got unregistered from
82 /// the Notifier-server.
83 int unregistered_;
85 private:
87 /// Our orb.
88 CORBA::ORB_var orb_;
90 /// Function to read the server IOR from a file.
91 int read_ior (ACE_TCHAR *filename);
93 /// Parse the command line arguments. Returns 0 on success, -1 on
94 /// error.
95 int parse_args (void);
97 /// This method initialises the naming service and registers the
98 /// object with the POA.
99 int via_naming_service (void);
101 /// # of arguments on the command line.
102 int argc_;
104 /// arguments from command line.
105 ACE_TCHAR **argv_;
107 /// IOR of the obj ref of the server.
108 ACE_TCHAR *ior_;
110 /// Flag for server shutdown.
111 int shutdown_;
113 /// An instance of the name client used for resolving the factory
114 /// objects.
115 TAO_Naming_Client naming_services_client_;
117 /// This variable denotes whether the naming service
118 /// is used or not.
119 int use_naming_service_;
121 /// Reference to the input_event_handler.
122 Consumer_Input_Handler *consumer_input_handler_;
124 /// Reference to the signal_event_handler.
125 Consumer_Signal_Handler *consumer_signal_handler_;
127 /// Is the example interactive?
128 int interactive_;
131 #endif /* CONSUMER_HANDLER_H */