OpenDDS  Snapshot(2023/04/28-20:55)
DataLinkSet.h
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #ifndef OPENDDS_DCPS_TRANSPORT_FRAMEWORK_DATALINKSET_H
9 #define OPENDDS_DCPS_TRANSPORT_FRAMEWORK_DATALINKSET_H
10 
11 #include "dds/DCPS/dcps_export.h"
12 #include "dds/DCPS/RcObject.h"
13 #include "dds/DCPS/PoolAllocator.h"
14 #include "DataLink_rch.h"
15 #include "SendResponseListener.h"
16 #include "TransportDefs.h"
18 #include "ace/Synch_Traits.h"
19 
21 
22 namespace OpenDDS {
23 namespace DCPS {
24 
25 class TransportSendListener;
26 class DataSampleElement;
29 
30 class OpenDDS_Dcps_Export DataLinkSet : public virtual RcObject {
31 public:
32 
33  DataLinkSet();
34  virtual ~DataLinkSet();
35 
36  // Returns 0 for success, -1 for failure, and 1 for failure due
37  // to duplicate entry (link is already a member of the set).
38  int insert_link(const DataLink_rch& link);
39 
40  void remove_link(const DataLink_rch& link);
41 
42  /// Send to each DataLink in the set.
43  void send(DataSampleElement* sample);
44 
45  /// Send a control message that is wrapped in a DataSampleElement
46  void send_control(DataSampleElement* sample);
47 
48  /// Send control message to each DataLink in the set.
49  SendControlStatus send_control(GUID_t pub_id,
50  const TransportSendListener_rch& listener,
51  const DataSampleHeader& header,
52  Message_Block_Ptr msg);
53 
54  void send_response(GUID_t sub_id,
55  const DataSampleHeader& header,
56  Message_Block_Ptr response);
57 
58  bool remove_sample(const DataSampleElement* sample);
59 
60  bool remove_all_msgs(const GUID_t& pub_id);
61 
62  /// Calls send_start() on the links in link_set and also adds
63  /// the links from link_set to *this.
64  void send_start(DataLinkSet* link_set);
65 
66  /// Calls send_stop() on the links with ID repoId and then
67  /// clears the set.
68  void send_stop(GUID_t repoId);
69 
70  DataLinkSet_rch select_links(const GUID_t* remoteIds,
71  const CORBA::ULong num_targets);
72 
73  bool empty();
74 
75  void send_final_acks(const GUID_t& readerid);
76 
79 
80  typedef OPENDDS_MAP(DataLinkIdType, DataLink_rch) MapType;
81 
82  //{@
83  /// Accessors for external iteration
84  LockType& lock() { return lock_; }
85  MapType& map() { return map_; }
86  //@}
87 
88  void terminate_send_if_suspended();
89 
90  bool is_leading(const GUID_t& writer_id,
91  const GUID_t& reader_id) const;
92 
93 private:
94 
95  /// Hash map for DataLinks.
96  MapType map_;
97 
98  /// This lock will protect critical sections of code that play a
99  /// role in the sending of data.
100  mutable LockType lock_;
101 
102  /// Listener for TransportSendControlElements created in send_response
104 
105  /// lock and copy map for lock-free access
106  void copy_map_to(MapType& target);
107 };
108 
109 } // namespace DCPS
110 } // namespace OpenDDS
111 
113 
114 #if defined (__ACE_INLINE__)
115 #include "DataLinkSet.inl"
116 #endif /* __ACE_INLINE__ */
117 
118 #endif /* OPENDDS_DCPS_DATALINKSET_H */
ACE_SYNCH_MUTEX LockType
Definition: DataLinkSet.h:77
#define ACE_SYNCH_MUTEX
MapType map_
Hash map for DataLinks.
Definition: DataLinkSet.h:96
#define OpenDDS_Dcps_Export
Definition: dcps_export.h:24
ssize_t send(ACE_HANDLE handle, const void *buf, size_t len, int flags, const ACE_Time_Value *timeout=0)
ACE_Guard< ACE_Thread_Mutex > lock_
ACE_UINT64 DataLinkIdType
Identifier type for DataLink objects.
ACE_CDR::ULong ULong
RcHandle< DataLinkSet > DataLinkSet_rch
The type definition for the smart-pointer to the underlying type.
Definition: DataLinkSet.h:27
Christopher Diggins *renamed files *fixing compilation errors *adding Visual C project file *removed make Max Lybbert *removed references to missing and unused header
Definition: CHANGELOG.txt:8
ACE_Guard< LockType > GuardType
Definition: DataLinkSet.h:78
Simple listener to discard response samples.
LockType & lock()
Accessors for external iteration.
Definition: DataLinkSet.h:84
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
typedef OPENDDS_MAP(OPENDDS_STRING, OPENDDS_STRING) ValueMap
Helper types and functions for config file parsing.
SendResponseListener send_response_listener_
Listener for TransportSendControlElements created in send_response.
Definition: DataLinkSet.h:103
SendControlStatus
Return code type for send_control() operations.