00001
00002
00003
00004
00005
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 namespace OpenDDS {
00015 namespace DCPS {
00016
00017 ACE_INLINE
00018 ReceiveListenerSet::ReceiveListenerSet()
00019 {
00020 DBG_ENTRY_LVL("ReceiveListenerSet", "ReceiveListenerSet", 6);
00021 }
00022
00023 ACE_INLINE
00024 ReceiveListenerSet::ReceiveListenerSet(const ReceiveListenerSet& rhs)
00025 : RcObject<ACE_SYNCH_MUTEX>()
00026 , lock_()
00027 , map_(rhs.map_)
00028 {
00029 DBG_ENTRY_LVL("ReceiveListenerSet", "ReceiveListenerSet(rhs)", 6);
00030 }
00031
00032 ACE_INLINE ReceiveListenerSet&
00033 ReceiveListenerSet::operator=(const ReceiveListenerSet& rhs)
00034 {
00035 DBG_ENTRY_LVL("ReceiveListenerSet", "operator=", 6);
00036 map_ = rhs.map_;
00037 return *this;
00038 }
00039
00040 ACE_INLINE int
00041 ReceiveListenerSet::insert(RepoId subscriber_id,
00042 TransportReceiveListener* listener)
00043 {
00044 DBG_ENTRY_LVL("ReceiveListenerSet", "insert", 6);
00045 GuardType guard(this->lock_);
00046 MapType::iterator iter = map_.find(subscriber_id);
00047 if (iter != map_.end()) {
00048 if (!listener && iter->second) {
00049
00050
00051 return 1;
00052 } else if (listener && !iter->second) {
00053
00054 iter->second = listener;
00055 return 1;
00056 }
00057 }
00058 return OpenDDS::DCPS::bind(map_, subscriber_id, listener);
00059 }
00060
00061 ACE_INLINE int
00062 ReceiveListenerSet::remove(RepoId subscriber_id)
00063 {
00064 DBG_ENTRY_LVL("ReceiveListenerSet", "remove", 6);
00065 GuardType guard(this->lock_);
00066
00067 if (unbind(map_, subscriber_id) != 0) {
00068 ACE_ERROR_RETURN((LM_DEBUG,
00069 "(%P|%t) subscriber_id (%C) not found in map_.\n",
00070 LogGuid(subscriber_id).c_str()),
00071 -1);
00072 }
00073
00074 return 0;
00075 }
00076
00077 ACE_INLINE void
00078 ReceiveListenerSet::remove_all(const GUIDSeq& to_remove)
00079 {
00080 DBG_ENTRY_LVL("ReceiveListenerSet", "remove_all", 6);
00081 GuardType guard(this->lock_);
00082 const CORBA::ULong len = to_remove.length();
00083 for (CORBA::ULong i(0); i < len; ++i) {
00084 unbind(map_, to_remove[i]);
00085 }
00086 }
00087
00088 ACE_INLINE ssize_t
00089 ReceiveListenerSet::size() const
00090 {
00091 DBG_ENTRY_LVL("ReceiveListenerSet", "size", 6);
00092 GuardType guard(this->lock_);
00093 return map_.size();
00094 }
00095
00096 ACE_INLINE ReceiveListenerSet::MapType&
00097 ReceiveListenerSet::map()
00098 {
00099 return this->map_;
00100 }
00101
00102 ACE_INLINE const ReceiveListenerSet::MapType&
00103 ReceiveListenerSet::map() const
00104 {
00105 return this->map_;
00106 }
00107
00108 }
00109 }