ReceiveListenerSet.inl

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #include "TransportReceiveListener.h"
00009 #include "ReceivedDataSample.h"
00010 #include "EntryExit.h"
00011 #include "dds/DCPS/Util.h"
00012 #include "dds/DCPS/GuidConverter.h"
00013 
00014 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00015 
00016 namespace OpenDDS {
00017 namespace DCPS {
00018 
00019 ACE_INLINE
00020 ReceiveListenerSet::ReceiveListenerSet()
00021 {
00022   DBG_ENTRY_LVL("ReceiveListenerSet", "ReceiveListenerSet", 6);
00023 }
00024 
00025 ACE_INLINE
00026 ReceiveListenerSet::ReceiveListenerSet(const ReceiveListenerSet& rhs)
00027   : RcObject()
00028   , lock_()
00029   , map_(rhs.map_)
00030 {
00031   DBG_ENTRY_LVL("ReceiveListenerSet", "ReceiveListenerSet(rhs)", 6);
00032 }
00033 
00034 ACE_INLINE ReceiveListenerSet&
00035 ReceiveListenerSet::operator=(const ReceiveListenerSet& rhs)
00036 {
00037   DBG_ENTRY_LVL("ReceiveListenerSet", "operator=", 6);
00038   map_ = rhs.map_;
00039   return *this;
00040 }
00041 
00042 
00043 ACE_INLINE int
00044 ReceiveListenerSet::insert(RepoId subscriber_id,
00045                            const TransportReceiveListener_wrch& listener)
00046 {
00047   DBG_ENTRY_LVL("ReceiveListenerSet", "insert", 6);
00048   GuardType guard(this->lock_);
00049 
00050   std::pair<MapType::iterator,bool> r = map_.insert(std::make_pair(subscriber_id,listener));
00051   if (!r.second) {
00052     // subscriber_id is already in the map
00053     if (!r.first->second) {
00054       // subscriber_id is in the map with a null listener, update it.
00055       r.first->second = listener;
00056     }
00057     return 1; // 1 ==> key already existed in map
00058   }
00059   return 0;
00060 }
00061 
00062 
00063 ACE_INLINE int
00064 ReceiveListenerSet::remove(RepoId subscriber_id)
00065 {
00066   DBG_ENTRY_LVL("ReceiveListenerSet", "remove", 6);
00067   GuardType guard(this->lock_);
00068 
00069   if (unbind(map_, subscriber_id) != 0) {
00070     ACE_ERROR_RETURN((LM_DEBUG,
00071                       "(%P|%t) subscriber_id (%C) not found in map_.\n",
00072                       LogGuid(subscriber_id).c_str()),
00073                      -1);
00074   }
00075 
00076   return 0;
00077 }
00078 
00079 ACE_INLINE void
00080 ReceiveListenerSet::remove_all(const GUIDSeq& to_remove)
00081 {
00082   DBG_ENTRY_LVL("ReceiveListenerSet", "remove_all", 6);
00083   GuardType guard(this->lock_);
00084   const CORBA::ULong len = to_remove.length();
00085   for (CORBA::ULong i(0); i < len; ++i) {
00086     unbind(map_, to_remove[i]);
00087   }
00088 }
00089 
00090 ACE_INLINE ssize_t
00091 ReceiveListenerSet::size() const
00092 {
00093   DBG_ENTRY_LVL("ReceiveListenerSet", "size", 6);
00094   GuardType guard(this->lock_);
00095   return map_.size();
00096 }
00097 
00098 ACE_INLINE ReceiveListenerSet::MapType&
00099 ReceiveListenerSet::map()
00100 {
00101   return this->map_;
00102 }
00103 
00104 ACE_INLINE const ReceiveListenerSet::MapType&
00105 ReceiveListenerSet::map() const
00106 {
00107   return this->map_;
00108 }
00109 
00110 } // namespace DCPS
00111 } // namespace OpenDDS
00112 
00113 OPENDDS_END_VERSIONED_NAMESPACE_DECL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1