00001 /* -*- C++ -*- */ 00002 /** 00003 * @file Event_Map_T.h 00004 * 00005 * $Id: Event_Map_T.h 81422 2008-04-24 12:33:29Z johnnyw $ 00006 * 00007 * @author Pradeep Gore <pradeep@oomworks.com> 00008 * 00009 * 00010 */ 00011 00012 #ifndef TAO_Notify_EVENT_MAP_T_H 00013 #define TAO_Notify_EVENT_MAP_T_H 00014 #include /**/ "ace/pre.h" 00015 00016 #include "orbsvcs/Notify/notify_serv_export.h" 00017 00018 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00019 # pragma once 00020 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00021 00022 #include "ace/Hash_Map_Manager.h" 00023 #include "ace/CORBA_macros.h" 00024 00025 #include "orbsvcs/Notify/EventType.h" 00026 #include "orbsvcs/Notify/Event_Map_Entry_T.h" 00027 #include "orbsvcs/Notify/EventTypeSeq.h" 00028 00029 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00030 00031 /** 00032 * @class TAO_Notify_Event_Map_T 00033 * 00034 * @brief Template class for storing the collection of Proxys. 00035 * 00036 */ 00037 template <class PROXY, class ACE_LOCK> 00038 class TAO_Notify_Event_Map_T 00039 { 00040 00041 public: 00042 typedef TAO_Notify_Event_Map_Entry_T<PROXY> ENTRY; 00043 00044 /// Constructor 00045 TAO_Notify_Event_Map_T (void); 00046 00047 /// Destructor 00048 ~TAO_Notify_Event_Map_T (); 00049 00050 /// Init 00051 void init (void); 00052 00053 /// Connect a PROXY 00054 void connect (PROXY* proxy); 00055 00056 /// Disconnect a PROXY 00057 void disconnect (PROXY* proxy); 00058 00059 /// Associate PROXY and event_type. 00060 /// Returns 1 if <event_type> is being seem for the 1st time otherwise returns 0. 00061 /// Returns -1 on error. 00062 int insert (PROXY* proxy, const TAO_Notify_EventType& event_type); 00063 00064 /// Remove association of PROXY and event_type. 00065 /// Returns 1 if <event_type> is being seem for the last time otherwise returns 0. 00066 /// Returns -1 on error. 00067 int remove (PROXY* proxy, const TAO_Notify_EventType& event_type); 00068 00069 /// Find the collection mapped to the <event_type> 00070 /// The usage_count on the entry returned is incremented. 00071 ENTRY* find (const TAO_Notify_EventType& event_type); 00072 00073 /// Find the default broadcast list. 00074 typename ENTRY::COLLECTION* broadcast_collection (void); 00075 00076 /// Find the update list. This is all the PROXYS connected to this Map. 00077 typename ENTRY::COLLECTION* updates_collection (void); 00078 00079 /// Release the usage count on this entry. 00080 void release (ENTRY* entry); 00081 00082 /// Access all the event types available 00083 const TAO_Notify_EventTypeSeq& event_types (void); 00084 00085 /// Access number of proxys connected in all. 00086 int proxy_count (void); 00087 00088 protected: 00089 /// The Map that stores eventtype to entry mapping. 00090 ACE_Hash_Map_Manager <TAO_Notify_EventType, ENTRY*, ACE_SYNCH_NULL_MUTEX> map_; 00091 00092 /// The lock to use. 00093 ACE_LOCK lock_; 00094 00095 /// Count of proxys connected. 00096 int proxy_count_; 00097 00098 /// The default broadcast list for EventType::special. 00099 ENTRY broadcast_entry_; 00100 00101 /// Update Entry - Keeps a list of all PROXY's connected to this Map. Updates are send to this list. 00102 ENTRY updates_entry_; 00103 00104 /// The event types that are available in this map. 00105 TAO_Notify_EventTypeSeq event_types_; 00106 }; 00107 00108 TAO_END_VERSIONED_NAMESPACE_DECL 00109 00110 #if defined (__ACE_INLINE__) 00111 #include "orbsvcs/Notify/Event_Map_T.inl" 00112 #endif /* __ACE_INLINE__ */ 00113 00114 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) 00115 #include "orbsvcs/Notify/Event_Map_T.cpp" 00116 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00117 00118 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) 00119 #pragma implementation ("Event_Map_T.cpp") 00120 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ 00121 00122 #include /**/ "ace/post.h" 00123 #endif /* TAO_Notify_EVENT_MAP_T_H */