3 //=============================================================================
7 * Defines the implementation header for the Supplier interface.
9 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
11 //=============================================================================
17 #include "NotifierS.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ConsumerC.h"
24 #include "ace/Hash_Map_Manager.h"
25 #include "ace/Containers.h"
26 #include "ace/SString.h"
27 #include "ace/Null_Mutex.h"
32 * @brief Notifier servant class.
34 * The implementation of the Notifier class, which is the servant
35 * object for the callback quoter server.
37 class Notifier_i
: public POA_Notifier
41 Notifier_i () = default;
44 ~Notifier_i () = default;
46 /// Register a distributed callback handler that is invoked when the
47 /// given stock reaches the desired threshold value.
48 void register_callback (const char *stock_name
,
49 CORBA::Long threshold_value
,
50 Callback_Quoter::Consumer_ptr consumer_handler
) override
;
52 /// Remove the consumer object.
53 void unregister_callback (Callback_Quoter::Consumer_ptr consumer_handler
) override
;
56 /// Get the market status.
57 void market_status (const char *stock_name
, CORBA::Long stock_value
) override
;
59 /// Get the orb pointer.
60 void orb (CORBA::ORB_ptr orb
);
62 /// Shutdown the Notifier.
63 void shutdown () override
;
70 * @class Consumer_Data
72 * @brief Saves the Consumer_var and the threshold stock value.
77 /// Comparison operator.
78 bool operator== (const Consumer_Data
&rhs
) const;
80 /// Stores the consumer object reference.
81 Callback_Quoter::Consumer_var consumer_
;
83 /// Stores the stock threshold value.
84 CORBA::Long desired_value_
;
87 typedef ACE_Unbounded_Set
<Consumer_Data
> CONSUMERS
;
89 typedef ACE_Hash_Map_Manager
<ACE_CString
, CONSUMERS
*, ACE_Null_Mutex
> CONSUMER_MAP
;
91 /// This is the hash map with each hash_entry consisting of the stockname
92 /// and an unbounded set of consumer object pointer and the desired stockvalue.
93 CONSUMER_MAP consumer_map_
;
95 ///This marks the exit of the notifier. This should be taken care of
96 /// before the consumer tries to unregister after the notifier quits.
97 int notifier_exited_
{0};
100 #endif /* NOTIFIER_I_H */