OpenDDS::DCPS::ReceiveListenerSetMap Class Reference

#include <ReceiveListenerSetMap.h>

List of all members.

Public Member Functions

typedef OPENDDS_MAP_CMP (RepoId, ReceiveListenerSet_rch, GUID_tKeyLessThan) MapType
 ReceiveListenerSetMap ()
virtual ~ReceiveListenerSetMap ()
int insert (RepoId publisher_id, RepoId subscriber_id, TransportReceiveListener *receive_listener)
ReceiveListenerSetfind (RepoId publisher_id) const
int remove (RepoId publisher_id, RepoId subscriber_id)
int release_subscriber (RepoId publisher_id, RepoId subscriber_id)
ReceiveListenerSetremove_set (RepoId publisher_id)
ssize_t size () const
MapType & map ()
 Give access to the underlying map for iteration purposes.
const MapType & map () const
void operator= (const ReceiveListenerSetMap &rh)
void clear ()

Private Member Functions

ReceiveListenerSetfind_or_create (RepoId publisher_id)

Private Attributes

MapType map_


Detailed Description

Definition at line 24 of file ReceiveListenerSetMap.h.


Constructor & Destructor Documentation

ACE_INLINE OpenDDS::DCPS::ReceiveListenerSetMap::ReceiveListenerSetMap (  ) 

Definition at line 14 of file ReceiveListenerSetMap.inl.

References DBG_ENTRY_LVL.

00015 {
00016   DBG_ENTRY_LVL("ReceiveListenerSetMap","ReceiveListenerSetMap",6);
00017 }

OpenDDS::DCPS::ReceiveListenerSetMap::~ReceiveListenerSetMap (  )  [virtual]

Definition at line 17 of file ReceiveListenerSetMap.cpp.

References DBG_ENTRY_LVL.

00018 {
00019   DBG_ENTRY_LVL("ReceiveListenerSetMap","~ReceiveListenerSetMap",6);
00020 }


Member Function Documentation

void OpenDDS::DCPS::ReceiveListenerSetMap::clear (  ) 

Definition at line 182 of file ReceiveListenerSetMap.cpp.

References DBG_ENTRY_LVL, and map_.

00183 {
00184   DBG_ENTRY_LVL("ReceiveListenerSetMap","clear",6);
00185 
00186   for (MapType::iterator itr = this->map_.begin();
00187        itr != this->map_.end();
00188        ++itr) {
00189     itr->second->clear();
00190   }
00191 
00192   this->map_.clear();
00193 }

ACE_INLINE OpenDDS::DCPS::ReceiveListenerSet * OpenDDS::DCPS::ReceiveListenerSetMap::find ( RepoId  publisher_id  )  const

Definition at line 20 of file ReceiveListenerSetMap.inl.

References OpenDDS::DCPS::RcHandle< T >::_retn(), DBG_ENTRY_LVL, OpenDDS::DCPS::find(), and map_.

00021 {
00022   DBG_ENTRY_LVL("ReceiveListenerSetMap","find",6);
00023   ReceiveListenerSet_rch listener_set;
00024 
00025   if (OpenDDS::DCPS::find(map_, publisher_id, listener_set) != 0) {
00026     return 0;
00027   }
00028 
00029   return listener_set._retn();
00030 }

ACE_INLINE OpenDDS::DCPS::ReceiveListenerSet * OpenDDS::DCPS::ReceiveListenerSetMap::find_or_create ( RepoId  publisher_id  )  [private]

Definition at line 33 of file ReceiveListenerSetMap.inl.

References OpenDDS::DCPS::RcHandle< T >::_retn(), OpenDDS::DCPS::bind(), DBG_ENTRY_LVL, OpenDDS::DCPS::find(), and map_.

00034 {
00035   DBG_ENTRY_LVL("ReceiveListenerSetMap","find_or_create",6);
00036   ReceiveListenerSet_rch listener_set;
00037 
00038   if (OpenDDS::DCPS::find(map_, publisher_id, listener_set) != 0) {
00039     // It wasn't found.  Create one and insert it.
00040     listener_set = new ReceiveListenerSet();
00041 
00042     if (OpenDDS::DCPS::bind(map_, publisher_id, listener_set) != 0) {
00043       ACE_ERROR((LM_ERROR,
00044                  "(%P|%t) ERROR: Unable to insert ReceiveListenerSet into the "
00045                  "ReceiveListenerSetMap for publisher_id %C.\n",
00046                  LogGuid(publisher_id).c_str()));
00047       // Return a 'nil' ReceiveListenerSet*
00048       return 0;
00049     }
00050   }
00051 
00052   return listener_set._retn();
00053 }

int OpenDDS::DCPS::ReceiveListenerSetMap::insert ( RepoId  publisher_id,
RepoId  subscriber_id,
TransportReceiveListener receive_listener 
)

Definition at line 24 of file ReceiveListenerSetMap.cpp.

References DBG_ENTRY_LVL, OpenDDS::DCPS::RcHandle< T >::is_nil(), and OPENDDS_STRING.

00027 {
00028   DBG_ENTRY_LVL("ReceiveListenerSetMap","insert",6);
00029   ReceiveListenerSet_rch listener_set = this->find_or_create(publisher_id);
00030 
00031   if (listener_set.is_nil()) {
00032     // find_or_create failure
00033     GuidConverter converter(publisher_id);
00034     ACE_ERROR_RETURN((LM_ERROR,
00035                       ACE_TEXT("(%P|%t) ERROR: ReceiveListenerSetMap::insert: ")
00036                       ACE_TEXT("failed to find_or_create entry for ")
00037                       ACE_TEXT("publisher %C.\n"),
00038                       OPENDDS_STRING(converter).c_str()), -1);
00039   }
00040 
00041   int result = listener_set->insert(subscriber_id, receive_listener);
00042 
00043   if (result == 0 || result == 1) {
00044     return 0;
00045   }
00046 
00047   GuidConverter sub_converter(subscriber_id);
00048   GuidConverter pub_converter(publisher_id);
00049   ACE_ERROR((LM_ERROR,
00050              ACE_TEXT("(%P|%t) ERROR: ReceiveListenerSetMap::insert: ")
00051              ACE_TEXT("failed to insert subscriber %C for ")
00052              ACE_TEXT("publisher %C.\n"),
00053              OPENDDS_STRING(sub_converter).c_str(),
00054              OPENDDS_STRING(pub_converter).c_str()));
00055 
00056   // Deal with possibility that the listener_set just got
00057   // created - and just for us.  This is to make sure we don't leave any
00058   // empty ReceiveListenerSets in our map_.
00059   if (listener_set->size() == 0) {
00060     listener_set = this->remove_set(publisher_id);
00061 
00062     if (listener_set.is_nil()) {
00063       ACE_ERROR((LM_ERROR,
00064                  ACE_TEXT("(%P|%t) ERROR: ReceiveListenerSetMap::insert: ")
00065                  ACE_TEXT("failed to remove (undo create) ReceiveListenerSet ")
00066                  ACE_TEXT("for publisher %C.\n"),
00067                  OPENDDS_STRING(pub_converter).c_str()));
00068     }
00069   }
00070 
00071   return -1;
00072 }

ACE_INLINE const OpenDDS::DCPS::ReceiveListenerSetMap::MapType & OpenDDS::DCPS::ReceiveListenerSetMap::map (  )  const

Definition at line 88 of file ReceiveListenerSetMap.inl.

References DBG_ENTRY_LVL, and map_.

00089 {
00090   DBG_ENTRY_LVL("ReceiveListenerSetMap","map",6);
00091   return map_;
00092 }

ACE_INLINE OpenDDS::DCPS::ReceiveListenerSetMap::MapType & OpenDDS::DCPS::ReceiveListenerSetMap::map (  ) 

Give access to the underlying map for iteration purposes.

Definition at line 81 of file ReceiveListenerSetMap.inl.

References DBG_ENTRY_LVL, and map_.

Referenced by operator=().

00082 {
00083   DBG_ENTRY_LVL("ReceiveListenerSetMap","map",6);
00084   return map_;
00085 }

typedef OpenDDS::DCPS::ReceiveListenerSetMap::OPENDDS_MAP_CMP ( RepoId  ,
ReceiveListenerSet_rch  ,
GUID_tKeyLessThan   
)

void OpenDDS::DCPS::ReceiveListenerSetMap::operator= ( const ReceiveListenerSetMap rh  ) 

Definition at line 162 of file ReceiveListenerSetMap.cpp.

References DBG_ENTRY_LVL, and map().

00163 {
00164   DBG_ENTRY_LVL("ReceiveListenerSetMap","operator=",6);
00165   const MapType& map = rh.map();
00166 
00167   for (MapType::const_iterator itr = map.begin();
00168        itr != map.end();
00169        ++itr) {
00170     ReceiveListenerSet_rch set = itr->second;
00171     ReceiveListenerSet::MapType& smap = set->map();
00172 
00173     for (ReceiveListenerSet::MapType::iterator sitr = smap.begin();
00174          sitr != smap.end();
00175          ++sitr) {
00176       this->insert(itr->first, sitr->first, sitr->second);
00177     }
00178   }
00179 }

int OpenDDS::DCPS::ReceiveListenerSetMap::release_subscriber ( RepoId  publisher_id,
RepoId  subscriber_id 
)

This method is called when the (remote) subscriber is being released. This method will return a 0 if the subscriber_id is successfully disassociated with the publisher_id *and* there are still other subscribers associated with the publisher_id. This method will return 1 if, after the disassociation, the publisher_id is no longer associated with any subscribers (which also means it's element was removed from our map_).

Definition at line 119 of file ReceiveListenerSetMap.cpp.

References DBG_ENTRY_LVL, OpenDDS::DCPS::find(), map_, OPENDDS_STRING, and OpenDDS::DCPS::unbind().

00121 {
00122   DBG_ENTRY_LVL("ReceiveListenerSetMap","release_subscriber",6);
00123   ReceiveListenerSet_rch listener_set;
00124 
00125   if (OpenDDS::DCPS::find(map_, publisher_id, listener_set) != 0) {
00126     GuidConverter converter(publisher_id);
00127     ACE_ERROR((LM_ERROR,
00128                ACE_TEXT("(%P|%t) ERROR: ReciveListenerSetMap::release_subscriber: ")
00129                ACE_TEXT("publisher %C not found in map_.\n"),
00130                OPENDDS_STRING(converter).c_str()));
00131     // Return 1 to indicate that the publisher_id is no longer associated
00132     // with any subscribers at all.
00133     return 1;
00134   }
00135 
00136   int result = listener_set->remove(subscriber_id);
00137 
00138   // Ignore the result
00139   ACE_UNUSED_ARG(result);
00140 
00141   if (listener_set->size() == 0) {
00142     if (unbind(map_, publisher_id) != 0) {
00143       GuidConverter converter(publisher_id);
00144       ACE_ERROR((LM_ERROR,
00145                  ACE_TEXT("(%P|%t) ERROR: ReceiveListenerSetMap::release_subscriber: ")
00146                  ACE_TEXT("failed to remove empty ReceiveListenerSet for ")
00147                  ACE_TEXT("publisher %C.\n"),
00148                  OPENDDS_STRING(converter).c_str()));
00149     }
00150 
00151     // We always return 1 if we know the publisher_id is no longer
00152     // associated with any ReceiveListeners.
00153     return 1;
00154   }
00155 
00156   // There are still ReceiveListeners associated with the publisher_id.
00157   // We return a 0 in this case.
00158   return 0;
00159 }

int OpenDDS::DCPS::ReceiveListenerSetMap::remove ( RepoId  publisher_id,
RepoId  subscriber_id 
)

Definition at line 75 of file ReceiveListenerSetMap.cpp.

References DBG_ENTRY_LVL, OpenDDS::DCPS::find(), map_, OPENDDS_STRING, and OpenDDS::DCPS::unbind().

00077 {
00078   DBG_ENTRY_LVL("ReceiveListenerSetMap","remove",6);
00079   ReceiveListenerSet_rch listener_set;
00080 
00081   if (OpenDDS::DCPS::find(map_, publisher_id, listener_set) != 0) {
00082     return 0;
00083   }
00084 
00085   int result = listener_set->remove(subscriber_id);
00086 
00087   // Ignore the result
00088   ACE_UNUSED_ARG(result);
00089 
00090   if (listener_set->size() == 0) {
00091     if (unbind(map_, publisher_id) != 0) {
00092       GuidConverter converter(publisher_id);
00093       ACE_ERROR_RETURN((LM_ERROR,
00094                         ACE_TEXT("(%P|%t) ERROR: ReceiveListenerSetMap::remove: ")
00095                         ACE_TEXT("failed to remove empty ReceiveListenerSet for ")
00096                         ACE_TEXT("publisher %C.\n"),
00097                         OPENDDS_STRING(converter).c_str()), -1);
00098     }
00099   }
00100 
00101   return 0;
00102 }

ACE_INLINE OpenDDS::DCPS::ReceiveListenerSet * OpenDDS::DCPS::ReceiveListenerSetMap::remove_set ( RepoId  publisher_id  ) 

Definition at line 56 of file ReceiveListenerSetMap.inl.

References OpenDDS::DCPS::RcHandle< T >::_retn(), DBG_ENTRY_LVL, map_, OpenDDS::DCPS::unbind(), and VDBG.

00057 {
00058   DBG_ENTRY_LVL("ReceiveListenerSetMap","remove_set",6);
00059   ReceiveListenerSet_rch listener_set;
00060 
00061   if (unbind(map_, publisher_id, listener_set) != 0) {
00062     VDBG((LM_DEBUG,
00063           "(%P|%t) Unable to remove ReceiveListenerSet from the "
00064           "ReceiveListenerSetMap for id %d.\n",
00065           LogGuid(publisher_id).c_str()));
00066     // Return a 'nil' ReceiveListenerSet*
00067     return 0;
00068   }
00069 
00070   return listener_set._retn();
00071 }

ACE_INLINE ssize_t OpenDDS::DCPS::ReceiveListenerSetMap::size (  )  const

Definition at line 74 of file ReceiveListenerSetMap.inl.

References DBG_ENTRY_LVL, and map_.

00075 {
00076   DBG_ENTRY_LVL("ReceiveListenerSetMap","size",6);
00077   return map_.size();
00078 }


Member Data Documentation

MapType OpenDDS::DCPS::ReceiveListenerSetMap::map_ [private]

Definition at line 65 of file ReceiveListenerSetMap.h.

Referenced by clear(), find(), find_or_create(), map(), release_subscriber(), remove(), remove_set(), and size().


The documentation for this class was generated from the following files:
Generated on Fri Feb 12 20:06:28 2016 for OpenDDS by  doxygen 1.4.7