TAO_Notify_Event_Map_T< PROXY, ACE_LOCK > Class Template Reference

Template class for storing the collection of Proxys. More...

#include <Event_Map_T.h>

Collaboration diagram for TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef TAO_Notify_Event_Map_Entry_T<
PROXY > 
ENTRY

Public Member Functions

 TAO_Notify_Event_Map_T (void)
 Constuctor.

 ~TAO_Notify_Event_Map_T ()
 Destructor.

void init ()
 Init.

void connect (PROXY *proxy)
 Connect a PROXY.

void disconnect (PROXY *proxy)
 Disconnect a PROXY.

int insert (PROXY *proxy, const TAO_Notify_EventType &event_type)
int remove (PROXY *proxy, const TAO_Notify_EventType &event_type)
ENTRYfind (const TAO_Notify_EventType &event_type)
ACE_TYPENAME ENTRY::COLLECTION * broadcast_collection (void)
 Find the default broadcast list.

ACE_TYPENAME ENTRY::COLLECTION * updates_collection (void)
 Find the update list. This is all the PROXYS connected to this Map.

void release (ENTRY *entry)
 Release the usage count on this entry.

const TAO_Notify_EventTypeSeqevent_types (void)
 Access all the event types available.

int proxy_count (void)
 Access number of proxys connected in all.


Protected Attributes

ACE_Hash_Map_Manager< TAO_Notify_EventType,
ENTRY *, ACE_SYNCH_NULL_MUTEX
map_
 The Map that stores eventtype to entry mapping.

ACE_LOCK lock_
 The lock to use.

int proxy_count_
 Count of proxys connected.

ENTRY broadcast_entry_
 The default broadcast list for EventType::special.

ENTRY updates_entry_
 Update Entry - Keeps a list of all PROXY's connected to this Map. Updates are send to this list.

TAO_Notify_EventTypeSeq event_types_
 The event types that are available in this map.


Detailed Description

template<class PROXY, class ACE_LOCK>
class TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >

Template class for storing the collection of Proxys.

Definition at line 38 of file Event_Map_T.h.


Member Typedef Documentation

template<class PROXY, class ACE_LOCK>
typedef TAO_Notify_Event_Map_Entry_T<PROXY> TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::ENTRY
 

Definition at line 42 of file Event_Map_T.h.


Constructor & Destructor Documentation

template<class PROXY, class ACE_LOCK>
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::TAO_Notify_Event_Map_T void   ) 
 

Constuctor.

Definition at line 19 of file Event_Map_T.cpp.

00020   :proxy_count_ (0)
00021 {
00022 
00023 }

template<class PROXY, class ACE_LOCK>
TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::~TAO_Notify_Event_Map_T  ) 
 

Destructor.

Definition at line 26 of file Event_Map_T.cpp.

00027 {
00028 }


Member Function Documentation

template<class PROXY, class ACE_LOCK>
ACE_INLINE ACE_TYPENAME TAO_Notify_Event_Map_Entry_T< PROXY >::COLLECTION * TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::broadcast_collection void   ) 
 

Find the default broadcast list.

Definition at line 33 of file Event_Map_T.inl.

References TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::broadcast_entry_.

00034 {
00035   return this->broadcast_entry_.collection ();
00036 }

template<class PROXY, class ACE_LOCK>
void TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::connect PROXY *  proxy  ) 
 

Connect a PROXY.

Definition at line 40 of file Event_Map_T.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_WRITE_GUARD, TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::proxy_count_, and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_entry_.

Referenced by TAO_Notify_Event_Manager::connect().

00041 {
00042   this->updates_entry_.connected (proxy ACE_ENV_ARG_PARAMETER);
00043   ACE_CHECK;
00044 
00045   ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_);
00046   ++this->proxy_count_;
00047 }

template<class PROXY, class ACE_LOCK>
void TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::disconnect PROXY *  proxy  ) 
 

Disconnect a PROXY.

Definition at line 50 of file Event_Map_T.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_WRITE_GUARD, TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::proxy_count_, and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_entry_.

Referenced by TAO_Notify_Event_Manager::disconnect().

00051 {
00052   this->updates_entry_.disconnected (proxy ACE_ENV_ARG_PARAMETER);
00053   ACE_CHECK;
00054 
00055   ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_);
00056   --this->proxy_count_;
00057 }

template<class PROXY, class ACE_LOCK>
ACE_INLINE const TAO_Notify_EventTypeSeq & TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::event_types void   ) 
 

Access all the event types available.

Definition at line 51 of file Event_Map_T.inl.

References TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::event_types_.

00052 {
00053   return this->event_types_;
00054 }

template<class PROXY, class ACE_LOCK>
ENTRY* TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::find const TAO_Notify_EventType event_type  ) 
 

Find the collection mapped to the The usage_count on the entry returned is incremented.

template<class PROXY, class ACE_LOCK>
void TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::init  ) 
 

Init.

Definition at line 31 of file Event_Map_T.cpp.

References ACE_CHECK, ACE_ENV_SINGLE_ARG_PARAMETER, TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::broadcast_entry_, and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_entry_.

00032 {
00033   this->broadcast_entry_.init (ACE_ENV_SINGLE_ARG_PARAMETER);
00034   ACE_CHECK;
00035 
00036   this->updates_entry_.init (ACE_ENV_SINGLE_ARG_PARAMETER);
00037 }

template<class PROXY, class ACE_LOCK>
int TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::insert PROXY *  proxy,
const TAO_Notify_EventType event_type
 

Associate PROXY and event_type. Returns 1 if is being seem for the 1st time otherwise returns 0. Returns -1 on error.

Definition at line 60 of file Event_Map_T.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_NEW_THROW_EX, ACE_READ_GUARD_RETURN, ACE_THROW_RETURN, ACE_WRITE_GUARD_RETURN, ACE_Hash_Map_Manager_Ex< TAO_Notify_EventType, ENTRY *, ACE_Hash< TAO_Notify_EventType >, ACE_Equal_To< TAO_Notify_EventType >, ACE_SYNCH_NULL_MUTEX >::bind(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::broadcast_entry_, TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::event_types_, ACE_Hash_Map_Manager_Ex< TAO_Notify_EventType, ENTRY *, ACE_Hash< TAO_Notify_EventType >, ACE_Equal_To< TAO_Notify_EventType >, ACE_SYNCH_NULL_MUTEX >::find(), and ACE_Unbounded_Set< TAO_Notify_EventType >::insert().

Referenced by TAO_Notify_Event_Manager::publish().

00061 {
00062   ENTRY* entry;
00063 
00064   int result = -1;
00065 
00066   if (event_type.is_special () == 1)
00067     {
00068       entry = &this->broadcast_entry_;
00069 
00070       result = 0;
00071     }
00072   else
00073     {
00074       ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00075 
00076       result = this->map_.find (event_type, entry);
00077     }
00078 
00079   if (result == -1) // This type is being seen for the first time.
00080   {
00081     ACE_NEW_THROW_EX (entry,
00082                       ENTRY (),
00083                       CORBA::NO_MEMORY ());
00084     ACE_CHECK_RETURN (-1);
00085 
00086     entry->init (ACE_ENV_SINGLE_ARG_PARAMETER);
00087     ACE_CHECK_RETURN (-1);
00088 
00089     entry->connected (proxy ACE_ENV_ARG_PARAMETER);
00090     ACE_CHECK_RETURN (-1);
00091 
00092     ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00093 
00094     if (map_.bind (event_type, entry) == -1)
00095       ACE_THROW_RETURN (CORBA::NO_MEMORY (), -1);
00096 
00097     if (this->event_types_.insert (event_type) == -1)
00098       return -1;
00099 
00100     return 1;
00101   }
00102   else // Add to existing entry or the broadcast entry.
00103     {
00104       entry->connected (proxy ACE_ENV_ARG_PARAMETER);
00105       ACE_CHECK_RETURN (-1);
00106     }
00107 
00108   return 0;
00109 }

template<class PROXY, class ACE_LOCK>
ACE_INLINE int TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::proxy_count void   ) 
 

Access number of proxys connected in all.

Definition at line 45 of file Event_Map_T.inl.

References TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::proxy_count_.

Referenced by TAO_Notify_Event_Manager::~TAO_Notify_Event_Manager().

00046 {
00047   return this->proxy_count_;
00048 }

template<class PROXY, class ACE_LOCK>
ACE_INLINE void TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::release ENTRY entry  ) 
 

Release the usage count on this entry.

Definition at line 24 of file Event_Map_T.inl.

References ACE_WRITE_GUARD.

00025 {
00026   ACE_WRITE_GUARD (ACE_LOCK, ace_mon, this->lock_);
00027 
00028   if (entry->_decr_refcnt () == 0)
00029     delete entry;
00030 }

template<class PROXY, class ACE_LOCK>
int TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::remove PROXY *  proxy,
const TAO_Notify_EventType event_type
 

Remove association of PROXY and event_type. Returns 1 if is being seem for the last time otherwise returns 0. Returns -1 on error.

Exec a strategy for removing entries. Strategy 1: remove_immediately Strategy 2: remove a bunch_after crossing a threshold Strategy 3: use cached allocator and 1

Definition at line 112 of file Event_Map_T.cpp.

References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_READ_GUARD_RETURN, ACE_WRITE_GUARD_RETURN, TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::broadcast_entry_, TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::event_types_, ACE_Hash_Map_Manager_Ex< TAO_Notify_EventType, ENTRY *, ACE_Hash< TAO_Notify_EventType >, ACE_Equal_To< TAO_Notify_EventType >, ACE_SYNCH_NULL_MUTEX >::find(), ACE_Unbounded_Set< TAO_Notify_EventType >::remove(), and ACE_Hash_Map_Manager_Ex< TAO_Notify_EventType, ENTRY *, ACE_Hash< TAO_Notify_EventType >, ACE_Equal_To< TAO_Notify_EventType >, ACE_SYNCH_NULL_MUTEX >::unbind().

Referenced by TAO_Notify_Event_Manager::un_publish().

00113 {
00114   ENTRY* entry = 0;
00115 
00116   if (event_type.is_special () == 1)
00117     {
00118       entry = &this->broadcast_entry_;
00119 
00120       entry->disconnected (proxy ACE_ENV_ARG_PARAMETER);
00121       ACE_CHECK_RETURN (-1);
00122     }
00123   else
00124     {
00125       int result = -1;
00126 
00127       {
00128         ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00129 
00130         result = this->map_.find (event_type, entry);
00131       }
00132 
00133       if (result == 0)
00134         {
00135           entry->disconnected (proxy ACE_ENV_ARG_PARAMETER);
00136           ACE_CHECK_RETURN (-1);
00137 
00138           if (entry->count () == 0)
00139             {
00140               /// Exec a strategy for removing entries.
00141               /// Strategy 1: remove_immediately
00142               /// Strategy 2: remove a bunch_after crossing a threshold
00143               /// Strategy 3: use cached allocator and 1
00144 
00145               // Strategy 1:
00146               ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
00147 
00148               this->map_.unbind (event_type);
00149 
00150               if (entry->_decr_refcnt () == 0)
00151                 delete entry;
00152 
00153               if (this->event_types_.remove (event_type) == -1)
00154                 return -1;
00155 
00156               return 1;
00157             }
00158         }
00159     }
00160 
00161   return 0;
00162 }

template<class PROXY, class ACE_LOCK>
ACE_INLINE ACE_TYPENAME TAO_Notify_Event_Map_Entry_T< PROXY >::COLLECTION * TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_collection void   ) 
 

Find the update list. This is all the PROXYS connected to this Map.

Definition at line 39 of file Event_Map_T.inl.

References TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_entry_.

Referenced by TAO_Notify_Event_Manager::subscription_change().

00040 {
00041   return this->updates_entry_.collection ();
00042 }


Member Data Documentation

template<class PROXY, class ACE_LOCK>
ENTRY TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::broadcast_entry_ [protected]
 

The default broadcast list for EventType::special.

Definition at line 99 of file Event_Map_T.h.

Referenced by TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::broadcast_collection(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::init(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::insert(), and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::remove().

template<class PROXY, class ACE_LOCK>
TAO_Notify_EventTypeSeq TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::event_types_ [protected]
 

The event types that are available in this map.

Definition at line 105 of file Event_Map_T.h.

Referenced by TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::event_types(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::insert(), and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::remove().

template<class PROXY, class ACE_LOCK>
ACE_LOCK TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::lock_ [protected]
 

The lock to use.

Definition at line 93 of file Event_Map_T.h.

template<class PROXY, class ACE_LOCK>
ACE_Hash_Map_Manager<TAO_Notify_EventType, ENTRY*, ACE_SYNCH_NULL_MUTEX> TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::map_ [protected]
 

The Map that stores eventtype to entry mapping.

Definition at line 90 of file Event_Map_T.h.

template<class PROXY, class ACE_LOCK>
int TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::proxy_count_ [protected]
 

Count of proxys connected.

Definition at line 96 of file Event_Map_T.h.

Referenced by TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::connect(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::disconnect(), and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::proxy_count().

template<class PROXY, class ACE_LOCK>
ENTRY TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_entry_ [protected]
 

Update Entry - Keeps a list of all PROXY's connected to this Map. Updates are send to this list.

Definition at line 102 of file Event_Map_T.h.

Referenced by TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::connect(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::disconnect(), TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::init(), and TAO_Notify_Event_Map_T< PROXY, ACE_LOCK >::updates_collection().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:31:57 2006 for TAO_CosNotification by doxygen 1.3.6