QueueRemoveVisitor.cpp

Go to the documentation of this file.
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 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00017 
00018 namespace OpenDDS {
00019 namespace DCPS {
00020 
00021 QueueRemoveVisitor::~QueueRemoveVisitor()
00022 {
00023   DBG_ENTRY_LVL("QueueRemoveVisitor", "~QueueRemoveVisitor", 6);
00024 }
00025 
00026 int
00027 QueueRemoveVisitor::visit_element_remove(TransportQueueElement* element,
00028                                          int& remove)
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 }
00072 
00073 }
00074 }
00075 
00076 OPENDDS_END_VERSIONED_NAMESPACE_DECL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1