OpenDDS  Snapshot(2023/04/28-20:55)
QueueRemoveVisitor.cpp
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 #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/
9 #include "QueueRemoveVisitor.h"
10 #include "TransportQueueElement.h"
11 
12 #if !defined (__ACE_INLINE__)
13 #include "QueueRemoveVisitor.inl"
14 #endif /* __ACE_INLINE__ */
15 
17 
18 namespace OpenDDS {
19 namespace DCPS {
20 
22 {
23  DBG_ENTRY_LVL("QueueRemoveVisitor", "~QueueRemoveVisitor", 6);
24 }
25 
26 int
28  int& remove)
29 {
30  DBG_ENTRY_LVL("QueueRemoveVisitor", "visit_element_remove", 6);
31 
32  if (this->mc_.matches(*element)) {
33  // We are visiting the element that we want to remove, since the
34  // element "matches" our sample_.
35 
36  // In order to have the BasicQueue<T> remove the element that we
37  // are currently visiting, set the remove flag to true (1). The
38  // BasicQueue<T> will perform the actual removal once we return
39  // from this method.
40  remove = 1;
41 
42  // Add the total_length() of the element->msg() chain to our
43  // removed_bytes_ (running) total.
44  this->removed_bytes_ += element->msg()->total_length();
45 
46  // Inform the element that we've made a decision - and it is
47  // data_dropped() by transport.
48  // This visitor is used in TransportSendStrategy::do_remove_sample
49  // The dropped_by_transport flag should be false(default) as the
50  // data_dropped is resulted from writer's remove_sample call.
51  const bool released = element->data_dropped();
52 
53  // Adjust our status_ to indicate that we actually found (and removed)
54  // the sample.
55  this->status_ = released ? REMOVE_RELEASED : REMOVE_FOUND;
56 
57  if ((!remove_all_ && released) || this->mc_.unique()) {
58  // Stop visitation since we've handled the element that matched
59  // our sample_.
60  // N.B. This unique() test means that if we are comparing by sample, we
61  // remove just the single element matching the sample, but if
62  // we are comparing by publication Id value, we visit the
63  // entire chain and remove all samples originating from that
64  // publication Id.
65  return 0;
66  }
67  }
68 
69  // Continue visitation.
70  return 1;
71 }
72 
73 }
74 }
75 
bool data_dropped(bool dropped_by_transport=false)
virtual bool matches(const TransportQueueElement &candidate) const =0
virtual int visit_element_remove(TransportQueueElement *element, int &remove)
size_t total_length(void) const
RemoveResult status_
Holds the status of our visit.
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
const TransportQueueElement::MatchCriteria & mc_
Criteria object describing the Queue Element that needs to be removed.
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
Base wrapper class around a data/control sample to be sent.
virtual const ACE_Message_Block * msg() const =0
The marshalled sample (sample header + sample data)