00001 /* 00002 * 00003 * 00004 * Distributed under the OpenDDS License. 00005 * See: http://www.opendds.org/license.html 00006 */ 00007 00008 #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/ 00009 #include "QueueRemoveVisitor.h" 00010 #include "TransportQueueElement.h" 00011 00012 #if !defined (__ACE_INLINE__) 00013 #include "QueueRemoveVisitor.inl" 00014 #endif /* __ACE_INLINE__ */ 00015 00016 namespace OpenDDS { 00017 namespace DCPS { 00018 00019 QueueRemoveVisitor::~QueueRemoveVisitor() 00020 { 00021 DBG_ENTRY_LVL("QueueRemoveVisitor", "~QueueRemoveVisitor", 6); 00022 } 00023 00024 int 00025 QueueRemoveVisitor::visit_element_remove(TransportQueueElement* element, 00026 int& remove) 00027 { 00028 DBG_ENTRY_LVL("QueueRemoveVisitor", "visit_element_remove", 6); 00029 00030 if (this->mc_.matches(*element)) { 00031 // We are visiting the element that we want to remove, since the 00032 // element "matches" our sample_. 00033 00034 // In order to have the BasicQueue<T> remove the element that we 00035 // are currently visiting, set the remove flag to true (1). The 00036 // BasicQueue<T> will perform the actual removal once we return 00037 // from this method. 00038 remove = 1; 00039 00040 // Add the total_length() of the element->msg() chain to our 00041 // removed_bytes_ (running) total. 00042 this->removed_bytes_ += element->msg()->total_length(); 00043 00044 // Inform the element that we've made a decision - and it is 00045 // data_dropped() by transport. 00046 // This visitor is used in TransportSendStrategy::do_remove_sample 00047 // The dropped_by_transport flag should be false(default) as the 00048 // data_dropped is resulted from writer's remove_sample call. 00049 const bool released = element->data_dropped(); 00050 00051 // Adjust our status_ to indicate that we actually found (and removed) 00052 // the sample. 00053 this->status_ = released ? REMOVE_RELEASED : REMOVE_FOUND; 00054 00055 if (released || this->mc_.unique()) { 00056 // Stop visitation since we've handled the element that matched 00057 // our sample_. 00058 // N.B. This unique() test means that if we are comparing by sample, we 00059 // remove just the single element matching the sample, but if 00060 // we are comparing by publication Id value, we visit the 00061 // entire chain and remove all samples originating from that 00062 // publication Id. 00063 return 0; 00064 } 00065 } 00066 00067 // Continue visitation. 00068 return 1; 00069 } 00070 00071 } 00072 }