OpenDDS  Snapshot(2023/04/07-19:43)
Public Member Functions | Private Attributes | List of all members
OpenDDS::DCPS::QueueRemoveVisitor Class Reference

#include <QueueRemoveVisitor.h>

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

Public Member Functions

 QueueRemoveVisitor (const TransportQueueElement::MatchCriteria &mc, bool remove_all=false)
 
virtual ~QueueRemoveVisitor ()
 
virtual int visit_element_remove (TransportQueueElement *element, int &remove)
 
RemoveResult status () const
 
int removed_bytes () const
 
- Public Member Functions inherited from OpenDDS::DCPS::BasicQueueVisitor< TransportQueueElement >
 BasicQueueVisitor ()
 
virtual ~BasicQueueVisitor ()
 
virtual int visit_element (TransportQueueElement *element)
 
virtual int visit_element_ref (TransportQueueElement *&element)
 

Private Attributes

const TransportQueueElement::MatchCriteriamc_
 Criteria object describing the Queue Element that needs to be removed. More...
 
RemoveResult status_
 Holds the status of our visit. More...
 
size_t removed_bytes_
 
bool remove_all_
 

Detailed Description

Definition at line 26 of file QueueRemoveVisitor.h.

Constructor & Destructor Documentation

◆ QueueRemoveVisitor()

ACE_INLINE OpenDDS::DCPS::QueueRemoveVisitor::QueueRemoveVisitor ( const TransportQueueElement::MatchCriteria mc,
bool  remove_all = false 
)
explicit

Definition at line 16 of file QueueRemoveVisitor.inl.

References ACE_INLINE, and DBG_ENTRY_LVL.

19  : mc_(mc)
21  , removed_bytes_(0)
22  , remove_all_(remove_all)
23 {
24  DBG_ENTRY_LVL("QueueRemoveVisitor", "QueueRemoveVisitor", 6);
25 }
const TransportQueueElement::MatchCriteria & mc_
Criteria object describing the Queue Element that needs to be removed.
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68
RemoveResult status_
Holds the status of our visit.

◆ ~QueueRemoveVisitor()

OpenDDS::DCPS::QueueRemoveVisitor::~QueueRemoveVisitor ( )
virtual

Definition at line 21 of file QueueRemoveVisitor.cpp.

References DBG_ENTRY_LVL.

22 {
23  DBG_ENTRY_LVL("QueueRemoveVisitor", "~QueueRemoveVisitor", 6);
24 }
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68

Member Function Documentation

◆ removed_bytes()

ACE_INLINE int OpenDDS::DCPS::QueueRemoveVisitor::removed_bytes ( ) const

Definition at line 35 of file QueueRemoveVisitor.inl.

References DBG_ENTRY_LVL, OPENDDS_END_VERSIONED_NAMESPACE_DECL, and removed_bytes_.

Referenced by OpenDDS::DCPS::TransportSendStrategy::do_remove_sample().

36 {
37  DBG_ENTRY_LVL("QueueRemoveVisitor", "removed_bytes", 6);
38  return static_cast<int>(this->removed_bytes_);
39 }
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68

◆ status()

ACE_INLINE RemoveResult OpenDDS::DCPS::QueueRemoveVisitor::status ( void  ) const

Accessor for the status. Called after this visitor object has been passed to BasicQueue<T>::accept_remove_visitor().

Definition at line 28 of file QueueRemoveVisitor.inl.

References ACE_INLINE, DBG_ENTRY_LVL, and status_.

Referenced by OpenDDS::DCPS::TransportSendStrategy::do_remove_sample().

29 {
30  DBG_ENTRY_LVL("QueueRemoveVisitor", "status", 6);
31  return this->status_;
32 }
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68
RemoveResult status_
Holds the status of our visit.

◆ visit_element_remove()

int OpenDDS::DCPS::QueueRemoveVisitor::visit_element_remove ( TransportQueueElement element,
int &  remove 
)
virtual

The BasicQueue<T>::accept_remove_visitor() method will call this visit_element_remove() method for each element in the queue.

Reimplemented from OpenDDS::DCPS::BasicQueueVisitor< TransportQueueElement >.

Definition at line 27 of file QueueRemoveVisitor.cpp.

References OpenDDS::DCPS::TransportQueueElement::data_dropped(), DBG_ENTRY_LVL, OpenDDS::DCPS::TransportQueueElement::MatchCriteria::matches(), mc_, OpenDDS::DCPS::TransportQueueElement::msg(), OPENDDS_END_VERSIONED_NAMESPACE_DECL, remove_all_, OpenDDS::DCPS::REMOVE_FOUND, OpenDDS::DCPS::REMOVE_RELEASED, removed_bytes_, status_, ACE_Message_Block::total_length(), and OpenDDS::DCPS::TransportQueueElement::MatchCriteria::unique().

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 }
const TransportQueueElement::MatchCriteria & mc_
Criteria object describing the Queue Element that needs to be removed.
virtual bool matches(const TransportQueueElement &candidate) const =0
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
Definition: EntryExit.h:68
RemoveResult status_
Holds the status of our visit.

Member Data Documentation

◆ mc_

const TransportQueueElement::MatchCriteria& OpenDDS::DCPS::QueueRemoveVisitor::mc_
private

Criteria object describing the Queue Element that needs to be removed.

Definition at line 48 of file QueueRemoveVisitor.h.

Referenced by visit_element_remove().

◆ remove_all_

bool OpenDDS::DCPS::QueueRemoveVisitor::remove_all_
private

Definition at line 55 of file QueueRemoveVisitor.h.

Referenced by visit_element_remove().

◆ removed_bytes_

size_t OpenDDS::DCPS::QueueRemoveVisitor::removed_bytes_
private

Definition at line 53 of file QueueRemoveVisitor.h.

Referenced by removed_bytes(), and visit_element_remove().

◆ status_

RemoveResult OpenDDS::DCPS::QueueRemoveVisitor::status_
private

Holds the status of our visit.

Definition at line 51 of file QueueRemoveVisitor.h.

Referenced by status(), and visit_element_remove().


The documentation for this class was generated from the following files: