Go to the documentation of this file.00001
00002
00003 #ifndef TAO_Notify_EVENT_MAP_T_CPP
00004 #define TAO_Notify_EVENT_MAP_T_CPP
00005
00006 #include "orbsvcs/Notify/Event_Map_T.h"
00007 #include "orbsvcs/ESF/ESF_Proxy_Collection.h"
00008 #include "orbsvcs/Notify/Event_Map_Entry_T.h"
00009 #include "orbsvcs/Notify/Properties.h"
00010 #include "orbsvcs/Notify/Factory.h"
00011
00012 #if ! defined (__ACE_INLINE__)
00013 #include "orbsvcs/Notify/Event_Map_T.inl"
00014 #endif
00015
00016 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00017
00018 template <class PROXY, class ACE_LOCK>
00019 TAO_Notify_Event_Map_T<PROXY, ACE_LOCK>::TAO_Notify_Event_Map_T (void)
00020 :proxy_count_ (0)
00021 {
00022
00023 }
00024
00025 template <class PROXY, class ACE_LOCK>
00026 TAO_Notify_Event_Map_T<PROXY, ACE_LOCK>::~TAO_Notify_Event_Map_T ()
00027 {
00028 }
00029
00030 template <class PROXY, class ACE_LOCK> void
00031 TAO_Notify_Event_Map_T<PROXY, ACE_LOCK>::init (void)
00032 {
00033 this->broadcast_entry_.init ();
00034
00035 this->updates_entry_.init ();
00036 }
00037
00038 template <class PROXY, class ACE_LOCK> void
00039 TAO_Notify_Event_Map_T<PROXY, ACE_LOCK>::connect (PROXY* proxy)
00040 {
00041 this->updates_entry_.connected (proxy);
00042
00043 ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_);
00044 ++this->proxy_count_;
00045 }
00046
00047 template <class PROXY, class ACE_LOCK> void
00048 TAO_Notify_Event_Map_T<PROXY, ACE_LOCK>::disconnect (PROXY* proxy)
00049 {
00050 this->updates_entry_.disconnected (proxy);
00051
00052 ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_);
00053 --this->proxy_count_;
00054 }
00055
00056 template <class PROXY, class ACE_LOCK> int
00057 TAO_Notify_Event_Map_T<PROXY, ACE_LOCK>::insert (PROXY* proxy, const TAO_Notify_EventType& event_type)
00058 {
00059 ENTRY* entry = 0;
00060
00061 int result = -1;
00062
00063 if (event_type.is_special () == 1)
00064 {
00065 entry = &this->broadcast_entry_;
00066
00067 result = 0;
00068 }
00069 else
00070 {
00071 ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00072
00073 result = this->map_.find (event_type, entry);
00074 }
00075
00076 if (result == -1)
00077 {
00078 ACE_NEW_THROW_EX (entry,
00079 ENTRY (),
00080 CORBA::NO_MEMORY ());
00081
00082 entry->init ();
00083
00084 entry->connected (proxy);
00085
00086 ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00087
00088 if (map_.bind (event_type, entry) == -1)
00089 throw CORBA::NO_MEMORY ();
00090
00091 if (this->event_types_.insert (event_type) == -1)
00092 return -1;
00093
00094 return 1;
00095 }
00096 else
00097 {
00098 entry->connected (proxy);
00099 }
00100
00101 return 0;
00102 }
00103
00104 template <class PROXY, class ACE_LOCK> int
00105 TAO_Notify_Event_Map_T<PROXY, ACE_LOCK>::remove (PROXY* proxy, const TAO_Notify_EventType& event_type)
00106 {
00107 ENTRY* entry = 0;
00108
00109 if (event_type.is_special () == 1)
00110 {
00111 entry = &this->broadcast_entry_;
00112
00113 entry->disconnected (proxy);
00114 }
00115 else
00116 {
00117 int result = -1;
00118
00119 {
00120 ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00121
00122 result = this->map_.find (event_type, entry);
00123 }
00124
00125 if (result == 0)
00126 {
00127 entry->disconnected (proxy);
00128
00129 if (entry->count () == 0)
00130 {
00131
00132
00133
00134
00135
00136
00137 ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00138
00139 this->map_.unbind (event_type);
00140
00141 if (entry->_decr_refcnt () == 0)
00142 delete entry;
00143
00144 if (this->event_types_.remove (event_type) == -1)
00145 return -1;
00146
00147 return 1;
00148 }
00149 }
00150 }
00151
00152 return 0;
00153 }
00154
00155 TAO_END_VERSIONED_NAMESPACE_DECL
00156
00157 #endif