Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / examples / Callback_Quoter / Notifier_i.h
blob283c6611f9a3fecfd0954b7455273a7c6ab91c28
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Notifier_i.h
7 * Defines the implementation header for the Supplier interface.
9 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
11 //=============================================================================
14 #ifndef NOTIFIER_I_H
15 #define NOTIFIER_I_H
17 #include "NotifierS.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # 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"
29 /**
30 * @class Notifier_i
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
39 public:
40 /// Constructor.
41 Notifier_i () = default;
43 /// Destructor.
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;
65 public:
66 /// The ORB manager.
67 CORBA::ORB_var orb_;
69 /**
70 * @class Consumer_Data
72 * @brief Saves the Consumer_var and the threshold stock value.
74 class Consumer_Data
76 public:
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 */