Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / examples / Callback_Quoter / Supplier_i.h
blob69a37aed83ac75325c72dae9564818ecaa5b635b
1 // -*- C++ -*-
2 //=============================================================================
3 /**
4 * @file Supplier_i.h
6 * This class implements a simple CORBA server that keeps
7 * on sending stock values to the Notifier.
9 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
11 //=============================================================================
13 #ifndef SUPPLIER_I_H
14 #define SUPPLIER_I_H
16 #include "orbsvcs/Naming/Naming_Client.h"
17 #include "orbsvcs/CosNamingC.h"
18 #include "ace/Reactor.h"
19 #include "ace/Read_Buffer.h"
20 #include "NotifierC.h"
21 #include "Supplier_Timer_Handler.h"
23 #if !defined (ACE_LACKS_PRAGMA_ONCE)
24 # pragma once
25 #endif /* ACE_LACKS_PRAGMA_ONCE */
27 /**
28 * @class Supplier
30 * @brief Market feed daemon implementation.
32 * This class feeds stock information to the Callback Quoter
33 * notifier.
35 class Supplier_Timer_Handler;
36 class Supplier
38 public:
39 /// Constructor.
40 Supplier ();
42 /// Destructor.
43 ~Supplier ();
45 /// Execute the daemon.
46 int run ();
48 /// Initialize the client communication endpoint with Notifier.
49 int init (int argc, ACE_TCHAR *argv[]);
51 /// Sends the stock name and its value.
52 int send_market_status (const char *stock_name,
53 long value);
55 private:
56 /// The timer handler used to send the market status to the notifier
57 /// periodically.
58 Supplier_Timer_Handler *supplier_timer_handler_ {};
60 /// Remember our orb.
61 CORBA::ORB_var orb_;
63 /// Function to read the Notifier IOR from a file.
64 int read_ior (ACE_TCHAR *filename);
66 /// Parses the arguments passed on the command line.
67 int parse_args ();
69 /// This method initialises the naming service and registers the
70 /// object with the POA.
71 int via_naming_service();
73 /// returns the TAO instance of the singleton Reactor.
74 ACE_Reactor *reactor_used () const;
76 /// This method used for getting stock information from a file.
77 int read_file (ACE_TCHAR *filename);
79 /// # of arguments on the command line.
80 int argc_;
82 /// arguments from command line.
83 ACE_TCHAR **argv_;
85 /// IOR of the obj ref of the Notifier.
86 ACE_TCHAR *ior_;
88 /// An instance of the name client used for resolving the factory
89 /// objects.
90 TAO_Naming_Client naming_services_client_;
92 /// This variable denotes whether the naming service
93 /// is used or not.
94 int use_naming_service_;
96 /// Notifier object reference.
97 Notifier_var notifier_;
99 /// The pointer for accessing the input stream.
100 FILE *f_ptr_;
102 /// Iteration count.
103 int loop_count_;
105 /// Time period between two succesive market feeds to the Notifier.
106 long period_value_;
109 #endif /*SUPPLIER_I_H */