#include <QueueRemoveVisitor.h>
Public Member Functions | |
QueueRemoveVisitor (const TransportQueueElement::MatchCriteria &mc) | |
virtual | ~QueueRemoveVisitor () |
virtual int | visit_element_remove (TransportQueueElement *element, int &remove) |
RemoveResult | status () const |
int | removed_bytes () const |
Private Attributes | |
const TransportQueueElement::MatchCriteria & | mc_ |
Criteria object describing the Queue Element that needs to be removed. | |
RemoveResult | status_ |
Holds the status of our visit. | |
size_t | removed_bytes_ |
Definition at line 26 of file QueueRemoveVisitor.h.
ACE_INLINE OpenDDS::DCPS::QueueRemoveVisitor::QueueRemoveVisitor | ( | const TransportQueueElement::MatchCriteria & | mc | ) | [explicit] |
Definition at line 16 of file QueueRemoveVisitor.inl.
References DBG_ENTRY_LVL.
00018 : mc_(mc) 00019 , status_(REMOVE_NOT_FOUND) 00020 , removed_bytes_(0) 00021 { 00022 DBG_ENTRY_LVL("QueueRemoveVisitor", "QueueRemoveVisitor", 6); 00023 }
OpenDDS::DCPS::QueueRemoveVisitor::~QueueRemoveVisitor | ( | ) | [virtual] |
Definition at line 21 of file QueueRemoveVisitor.cpp.
References DBG_ENTRY_LVL.
00022 { 00023 DBG_ENTRY_LVL("QueueRemoveVisitor", "~QueueRemoveVisitor", 6); 00024 }
ACE_INLINE int OpenDDS::DCPS::QueueRemoveVisitor::removed_bytes | ( | ) | const |
Definition at line 33 of file QueueRemoveVisitor.inl.
References DBG_ENTRY_LVL, and removed_bytes_.
Referenced by OpenDDS::DCPS::TransportSendStrategy::do_remove_sample().
00034 { 00035 DBG_ENTRY_LVL("QueueRemoveVisitor", "removed_bytes", 6); 00036 return static_cast<int>(this->removed_bytes_); 00037 }
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 26 of file QueueRemoveVisitor.inl.
References DBG_ENTRY_LVL, and status_.
Referenced by OpenDDS::DCPS::TransportSendStrategy::do_remove_sample().
00027 { 00028 DBG_ENTRY_LVL("QueueRemoveVisitor", "status", 6); 00029 return this->status_; 00030 }
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::DCPS::REMOVE_FOUND, OpenDDS::DCPS::REMOVE_RELEASED, removed_bytes_, status_, ACE_Message_Block::total_length(), and OpenDDS::DCPS::TransportQueueElement::MatchCriteria::unique().
00029 { 00030 DBG_ENTRY_LVL("QueueRemoveVisitor", "visit_element_remove", 6); 00031 00032 if (this->mc_.matches(*element)) { 00033 // We are visiting the element that we want to remove, since the 00034 // element "matches" our sample_. 00035 00036 // In order to have the BasicQueue<T> remove the element that we 00037 // are currently visiting, set the remove flag to true (1). The 00038 // BasicQueue<T> will perform the actual removal once we return 00039 // from this method. 00040 remove = 1; 00041 00042 // Add the total_length() of the element->msg() chain to our 00043 // removed_bytes_ (running) total. 00044 this->removed_bytes_ += element->msg()->total_length(); 00045 00046 // Inform the element that we've made a decision - and it is 00047 // data_dropped() by transport. 00048 // This visitor is used in TransportSendStrategy::do_remove_sample 00049 // The dropped_by_transport flag should be false(default) as the 00050 // data_dropped is resulted from writer's remove_sample call. 00051 const bool released = element->data_dropped(); 00052 00053 // Adjust our status_ to indicate that we actually found (and removed) 00054 // the sample. 00055 this->status_ = released ? REMOVE_RELEASED : REMOVE_FOUND; 00056 00057 if (released || this->mc_.unique()) { 00058 // Stop visitation since we've handled the element that matched 00059 // our sample_. 00060 // N.B. This unique() test means that if we are comparing by sample, we 00061 // remove just the single element matching the sample, but if 00062 // we are comparing by publication Id value, we visit the 00063 // entire chain and remove all samples originating from that 00064 // publication Id. 00065 return 0; 00066 } 00067 } 00068 00069 // Continue visitation. 00070 return 1; 00071 }
Criteria object describing the Queue Element that needs to be removed.
Definition at line 48 of file QueueRemoveVisitor.h.
Referenced by visit_element_remove().
Definition at line 53 of file QueueRemoveVisitor.h.
Referenced by removed_bytes(), and visit_element_remove().
Holds the status of our visit.
Definition at line 51 of file QueueRemoveVisitor.h.
Referenced by status(), and visit_element_remove().