Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / examples / Callback_Quoter / Notifier_i.h
blob23a283c28c775b5c3c878d455e1dc03249993dee
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 (void);
43 /// Destructor.
44 ~Notifier_i (void);
46 /// Register a distributed callback handler that is invoked when the
47 /// given stock reaches the desired threshold value.
48 virtual void register_callback (const char *stock_name,
49 CORBA::Long threshold_value,
50 Callback_Quoter::Consumer_ptr consumer_handler);
52 /// Remove the consumer object.
53 virtual void unregister_callback (Callback_Quoter::Consumer_ptr consumer_handler);
55 /// Get the market status.
56 virtual void market_status (const char *stock_name,
57 CORBA::Long stock_value);
59 /// Get the orb pointer.
60 void orb (CORBA::ORB_ptr orb);
62 /// Shutdown the Notifier.
63 virtual void shutdown (void);
65 // CONSUMER_MAP* get_consumer_map_ptr ();
66 // Returns the consumer map ptr.
68 //private:
69 public:
70 /// The ORB manager.
71 CORBA::ORB_var orb_;
73 /**
74 * @class Consumer_Data
76 * @brief Saves the Consumer_var and the threshold stock value.
78 class Consumer_Data
80 public:
81 /// Comparison operator.
82 bool operator== (const Consumer_Data &rhs) const;
84 /// Stores the consumer object reference.
85 Callback_Quoter::Consumer_var consumer_;
87 /// Stores the stock threshold value.
88 CORBA::Long desired_value_;
91 typedef ACE_Unbounded_Set<Consumer_Data>
92 CONSUMERS;
94 typedef ACE_Hash_Map_Manager<ACE_CString, CONSUMERS *, ACE_Null_Mutex>
95 CONSUMER_MAP;
97 /// This is the hash map with each hash_entry consisting of the stockname
98 /// and an unbounded set of consumer object pointer and the desired stockvalue.
99 CONSUMER_MAP consumer_map_;
101 ///This marks the exit of the notifier. This should be taken care of
102 /// before the consumer tries to unregister after the notifier quits.
103 int notifier_exited_;
108 #endif /* NOTIFIER_I_H */