00001 /* 00002 * 00003 * 00004 * Distributed under the OpenDDS License. 00005 * See: http://www.opendds.org/license.html 00006 */ 00007 00008 #ifndef OPENDDS_DCPS_RECEIVELISTENERSET_H 00009 #define OPENDDS_DCPS_RECEIVELISTENERSET_H 00010 00011 #include "dds/DCPS/RcObject.h" 00012 #include "dds/DdsDcpsInfoUtilsC.h" 00013 #include "dds/DCPS/GuidUtils.h" 00014 #include "dds/DCPS/PoolAllocator.h" 00015 #include "ace/Synch_Traits.h" 00016 #include "ace/Mutex.h" 00017 00018 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 00019 00020 namespace OpenDDS { 00021 namespace DCPS { 00022 00023 class TransportReceiveListener; 00024 class ReceivedDataSample; 00025 typedef WeakRcHandle<TransportReceiveListener> TransportReceiveListener_wrch; 00026 00027 class OpenDDS_Dcps_Export ReceiveListenerSet : 00028 public RcObject { 00029 public: 00030 00031 enum ConstrainReceiveSet { 00032 SET_EXCLUDED, 00033 SET_INCLUDED 00034 }; 00035 00036 typedef OPENDDS_MAP_CMP(RepoId, TransportReceiveListener_wrch, GUID_tKeyLessThan) MapType; 00037 00038 ReceiveListenerSet(); 00039 ReceiveListenerSet(const ReceiveListenerSet&); 00040 ReceiveListenerSet& operator=(const ReceiveListenerSet&); 00041 virtual ~ReceiveListenerSet(); 00042 00043 int insert(RepoId subscriber_id, 00044 const TransportReceiveListener_wrch& listener); 00045 int remove(RepoId subscriber_id); 00046 void remove_all(const GUIDSeq& to_remove); 00047 00048 ssize_t size() const; 00049 00050 void data_received(const ReceivedDataSample& sample, 00051 const RepoIdSet& incl_excl, 00052 ConstrainReceiveSet constrain); 00053 void data_received(const ReceivedDataSample& sample, const RepoId& readerId); 00054 00055 /// Give access to the underlying map for iteration purposes. 00056 MapType& map(); 00057 const MapType& map() const; 00058 00059 /// Check if the key is in the map and if it's the only left entry 00060 /// in the map. 00061 bool exist(const RepoId& key, bool& last); 00062 bool exist(const RepoId& local_id); 00063 00064 void get_keys(ReaderIdSeq & ids); 00065 00066 void clear(); 00067 00068 private: 00069 00070 typedef ACE_SYNCH_MUTEX LockType; 00071 typedef ACE_Guard<LockType> GuardType; 00072 00073 /// This lock will protect the map. 00074 mutable LockType lock_; 00075 00076 MapType map_; 00077 }; 00078 00079 } // namespace DCPS 00080 } // namespace OpenDDS 00081 00082 OPENDDS_END_VERSIONED_NAMESPACE_DECL 00083 00084 #if defined (__ACE_INLINE__) 00085 #include "ReceiveListenerSet.inl" 00086 #endif /* __ACE_INLINE__ */ 00087 00088 #endif /* OPENDDS_DCPS_RECEIVELISTENERSET_H */