OpenDDS::DCPS::ReceiveListenerSet Class Reference

#include <ReceiveListenerSet.h>

Inheritance diagram for OpenDDS::DCPS::ReceiveListenerSet:

Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::ReceiveListenerSet:

Collaboration graph
[legend]
List of all members.

Public Types

 SET_EXCLUDED
 SET_INCLUDED
enum  ConstrainReceiveSet { SET_EXCLUDED, SET_INCLUDED }

Public Member Functions

typedef OPENDDS_MAP_CMP (RepoId, TransportReceiveListener *, GUID_tKeyLessThan) MapType
 ReceiveListenerSet ()
 ReceiveListenerSet (const ReceiveListenerSet &)
ReceiveListenerSetoperator= (const ReceiveListenerSet &)
virtual ~ReceiveListenerSet ()
int insert (RepoId subscriber_id, TransportReceiveListener *listener)
int remove (RepoId subscriber_id)
void remove_all (const GUIDSeq &to_remove)
ssize_t size () const
void data_received (const ReceivedDataSample &sample, const RepoIdSet &incl_excl, ConstrainReceiveSet constrain)
void data_received (const ReceivedDataSample &sample, const RepoId &readerId)
MapType & map ()
 Give access to the underlying map for iteration purposes.
const MapType & map () const
bool exist (const RepoId &key, bool &last)
bool exist (const RepoId &local_id)
void get_keys (ReaderIdSeq &ids)
void clear ()

Private Types

typedef ACE_SYNCH_MUTEX LockType
typedef ACE_Guard< LockTypeGuardType

Private Attributes

LockType lock_
 This lock will protect the map.
MapType map_

Detailed Description

Definition at line 24 of file ReceiveListenerSet.h.


Member Typedef Documentation

typedef ACE_Guard<LockType> OpenDDS::DCPS::ReceiveListenerSet::GuardType [private]

Definition at line 68 of file ReceiveListenerSet.h.

typedef ACE_SYNCH_MUTEX OpenDDS::DCPS::ReceiveListenerSet::LockType [private]

Definition at line 67 of file ReceiveListenerSet.h.


Member Enumeration Documentation

enum OpenDDS::DCPS::ReceiveListenerSet::ConstrainReceiveSet

Enumerator:
SET_EXCLUDED 
SET_INCLUDED 

Definition at line 28 of file ReceiveListenerSet.h.

00028                            {
00029     SET_EXCLUDED,
00030     SET_INCLUDED
00031   };


Constructor & Destructor Documentation

ACE_INLINE OpenDDS::DCPS::ReceiveListenerSet::ReceiveListenerSet (  ) 

Definition at line 18 of file ReceiveListenerSet.inl.

References DBG_ENTRY_LVL.

00019 {
00020   DBG_ENTRY_LVL("ReceiveListenerSet", "ReceiveListenerSet", 6);
00021 }

ACE_INLINE OpenDDS::DCPS::ReceiveListenerSet::ReceiveListenerSet ( const ReceiveListenerSet  ) 

Definition at line 24 of file ReceiveListenerSet.inl.

References DBG_ENTRY_LVL.

00025   : RcObject<ACE_SYNCH_MUTEX>()
00026   , lock_()
00027   , map_(rhs.map_)
00028 {
00029   DBG_ENTRY_LVL("ReceiveListenerSet", "ReceiveListenerSet(rhs)", 6);
00030 }

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

Definition at line 75 of file ReceiveListenerSet.cpp.

References DBG_ENTRY_LVL.

00076 {
00077   DBG_ENTRY_LVL("ReceiveListenerSet","~ReceiveListenerSet",6);
00078 }


Member Function Documentation

void OpenDDS::DCPS::ReceiveListenerSet::clear (  ) 

Definition at line 134 of file ReceiveListenerSet.cpp.

References map_.

00135 {
00136   GuardType guard(this->lock_);
00137   this->map_.clear();
00138 }

void OpenDDS::DCPS::ReceiveListenerSet::data_received ( const ReceivedDataSample sample,
const RepoId readerId 
)

Definition at line 177 of file ReceiveListenerSet.cpp.

References DBG_ENTRY_LVL, and map_.

00179 {
00180   DBG_ENTRY_LVL("ReceiveListenerSet", "data_received(sample, readerId)", 6);
00181   ReceiveListenerHandle h(0);
00182   {
00183     GuardType guard(this->lock_);
00184     MapType::iterator itr = map_.find(readerId);
00185     if (itr != map_.end() && itr->second) {
00186       h = ReceiveListenerHandle(itr->second);
00187     }
00188   }
00189   if (h) h->data_received(sample);
00190 }

void OpenDDS::DCPS::ReceiveListenerSet::data_received ( const ReceivedDataSample sample,
const RepoIdSet &  incl_excl,
ConstrainReceiveSet  constrain 
)

Definition at line 141 of file ReceiveListenerSet.cpp.

References DBG_ENTRY_LVL, map_, OpenDDS::DCPS::OPENDDS_VECTOR(), OpenDDS::DCPS::ReceivedDataSample::sample_, SET_EXCLUDED, and SET_INCLUDED.

00144 {
00145   DBG_ENTRY_LVL("ReceiveListenerSet", "data_received", 6);
00146   OPENDDS_VECTOR(ReceiveListenerHandle) handles;
00147   {
00148     GuardType guard(this->lock_);
00149     for (MapType::iterator itr = map_.begin(); itr != map_.end(); ++itr) {
00150       if (constrain == ReceiveListenerSet::SET_EXCLUDED) {
00151         if (itr->second && incl_excl.count(itr->first) == 0) {
00152           handles.push_back(ReceiveListenerHandle(itr->second));
00153         }
00154       } else if (constrain == ReceiveListenerSet::SET_INCLUDED) { //SET_INCLUDED
00155         if (itr->second && incl_excl.count(itr->first) != 0) {
00156           handles.push_back(ReceiveListenerHandle(itr->second));
00157         }
00158       } else {
00159         ACE_DEBUG((LM_ERROR, "(%P|%t) ERROR: ReceiveListenerSet::data_received - NOTHING\n"));
00160       }
00161     }
00162   }
00163 
00164   for (size_t i = 0; i < handles.size(); ++i) {
00165     if (i < handles.size() - 1 && sample.sample_) {
00166       // demarshal (in data_received()) updates the rd_ptr() of any of
00167       // the message blocks in the chain, so give it a duplicated chain.
00168       ReceivedDataSample rds(sample);
00169       handles[i]->data_received(rds);
00170     } else {
00171       handles[i]->data_received(sample);
00172     }
00173   }
00174 }

bool OpenDDS::DCPS::ReceiveListenerSet::exist ( const RepoId local_id  ) 

Definition at line 125 of file ReceiveListenerSet.cpp.

References OpenDDS::DCPS::find(), and map_.

00126 {
00127   GuardType guard(this->lock_);
00128 
00129   TransportReceiveListener* listener = 0;
00130   return (find(map_, local_id, listener) == -1 ? false : true);
00131 }

bool OpenDDS::DCPS::ReceiveListenerSet::exist ( const RepoId key,
bool &  last 
)

Check if the key is in the map and if it's the only left entry in the map.

Definition at line 81 of file ReceiveListenerSet.cpp.

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

00082 {
00083   GuardType guard(this->lock_);
00084 
00085   last = true;
00086 
00087   TransportReceiveListener* listener = 0;
00088 
00089   if (find(map_, local_id, listener) == -1) {
00090     GuidConverter converter(local_id);
00091     ACE_ERROR((LM_ERROR,
00092                ACE_TEXT("(%P|%t) ReceiveListenerSet::exist: ")
00093                ACE_TEXT("could not find local %C.\n"),
00094                OPENDDS_STRING(converter).c_str()));
00095 
00096     return false;
00097   }
00098 
00099   if (listener == 0) {
00100     GuidConverter converter(local_id);
00101     ACE_ERROR((LM_ERROR,
00102                ACE_TEXT("(%P|%t) ReceiveListenerSet::exist: ")
00103                ACE_TEXT("listener for local %C is nil.\n"),
00104                OPENDDS_STRING(converter).c_str()));
00105 
00106     return false;
00107   }
00108 
00109   last = map_.size() == 1;
00110   return true;
00111 }

void OpenDDS::DCPS::ReceiveListenerSet::get_keys ( ReaderIdSeq ids  ) 

Definition at line 114 of file ReceiveListenerSet.cpp.

References map_, and OpenDDS::DCPS::push_back().

00115 {
00116   GuardType guard(this->lock_);
00117 
00118   for (MapType::iterator iter = map_.begin();
00119        iter != map_.end(); ++ iter) {
00120     push_back(ids, iter->first);
00121   }
00122 }

ACE_INLINE int OpenDDS::DCPS::ReceiveListenerSet::insert ( RepoId  subscriber_id,
TransportReceiveListener listener 
)

Definition at line 41 of file ReceiveListenerSet.inl.

References OpenDDS::DCPS::bind(), DBG_ENTRY_LVL, and map_.

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       // subscriber_id is already in the map with a non-null listener,
00050       // and this call to insert() is trying to make it null.
00051       return 1; // 1 ==> key already existed in map
00052     } else if (listener && !iter->second) {
00053       // subscriber_id is in the map with a null listener, update it.
00054       iter->second = listener;
00055       return 1;
00056     }
00057   }
00058   return OpenDDS::DCPS::bind(map_, subscriber_id, listener);
00059 }

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

Definition at line 103 of file ReceiveListenerSet.inl.

References map_.

00104 {
00105   return this->map_;
00106 }

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

Give access to the underlying map for iteration purposes.

Definition at line 97 of file ReceiveListenerSet.inl.

References map_.

00098 {
00099   return this->map_;
00100 }

typedef OpenDDS::DCPS::ReceiveListenerSet::OPENDDS_MAP_CMP ( RepoId  ,
TransportReceiveListener ,
GUID_tKeyLessThan   
)

ACE_INLINE ReceiveListenerSet & OpenDDS::DCPS::ReceiveListenerSet::operator= ( const ReceiveListenerSet  ) 

Definition at line 33 of file ReceiveListenerSet.inl.

References DBG_ENTRY_LVL, and map_.

00034 {
00035   DBG_ENTRY_LVL("ReceiveListenerSet", "operator=", 6);
00036   map_ = rhs.map_;
00037   return *this;
00038 }

ACE_INLINE int OpenDDS::DCPS::ReceiveListenerSet::remove ( RepoId  subscriber_id  ) 

Definition at line 62 of file ReceiveListenerSet.inl.

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

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 }

ACE_INLINE void OpenDDS::DCPS::ReceiveListenerSet::remove_all ( const GUIDSeq to_remove  ) 

Definition at line 78 of file ReceiveListenerSet.inl.

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

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 }

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

Definition at line 89 of file ReceiveListenerSet.inl.

References DBG_ENTRY_LVL, and map_.

00090 {
00091   DBG_ENTRY_LVL("ReceiveListenerSet", "size", 6);
00092   GuardType guard(this->lock_);
00093   return map_.size();
00094 }


Member Data Documentation

LockType OpenDDS::DCPS::ReceiveListenerSet::lock_ [mutable, private]

This lock will protect the map.

Definition at line 71 of file ReceiveListenerSet.h.

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

Definition at line 73 of file ReceiveListenerSet.h.

Referenced by clear(), data_received(), exist(), get_keys(), insert(), map(), operator=(), remove(), remove_all(), 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