#include <ReceivedDataElementList.h>
Collaboration diagram for OpenDDS::DCPS::ReceivedDataElementList:
Public Member Functions | |
ReceivedDataElementList (InstanceState *instance_state=0) | |
~ReceivedDataElementList () | |
void | apply_all (ReceivedDataFilter &match, ReceivedDataOperation &func) |
void | add (ReceivedDataElement *data_sample) |
bool | remove (ReceivedDataElement *data_sample) |
bool | remove (ReceivedDataFilter &match, bool eval_all) |
ReceivedDataElement * | remove_head () |
ReceivedDataElement * | remove_tail () |
Public Attributes | |
ReceivedDataElement * | head_ |
The first element of the list. | |
ReceivedDataElement * | tail_ |
The last element of the list. | |
ssize_t | size_ |
Number of elements in the list. | |
Private Attributes | |
InstanceState * | instance_state_ |
Definition at line 137 of file ReceivedDataElementList.h.
OpenDDS::DCPS::ReceivedDataElementList::ReceivedDataElementList | ( | InstanceState * | instance_state = 0 |
) |
Definition at line 35 of file ReceivedDataElementList.cpp.
00036 : head_(0), tail_(0), size_(0), instance_state_(instance_state) 00037 { 00038 }
OpenDDS::DCPS::ReceivedDataElementList::~ReceivedDataElementList | ( | ) |
Definition at line 40 of file ReceivedDataElementList.cpp.
00041 { 00042 // The memory pointed to by instance_state_ is owned by 00043 // another object. 00044 }
ACE_INLINE void OpenDDS::DCPS::ReceivedDataElementList::add | ( | ReceivedDataElement * | data_sample | ) |
Definition at line 13 of file ReceivedDataElementList.inl.
References OpenDDS::DCPS::InstanceState::empty(), head_, instance_state_, OpenDDS::DCPS::ReceivedDataElement::next_data_sample_, OpenDDS::DCPS::ReceivedDataElement::previous_data_sample_, size_, and tail_.
Referenced by OpenDDS::DCPS::SourceDataStrategy::add(), and OpenDDS::DCPS::ReceivedDataStrategy::add().
00014 { 00015 // The default action is to simply add to the 00016 // tail - in the future we may want to add 00017 // to the middle of the list based on sequence 00018 // number and/or source timestamp 00019 00020 data_sample->previous_data_sample_ = 0; 00021 data_sample->next_data_sample_ = 0; 00022 00023 ++size_ ; 00024 00025 if (!head_) { 00026 // First sample in the list. 00027 head_ = tail_ = data_sample ; 00028 00029 } else { 00030 // Add to existing list. 00031 tail_->next_data_sample_ = data_sample ; 00032 data_sample->previous_data_sample_ = tail_; 00033 tail_ = data_sample; 00034 } 00035 00036 if (instance_state_) { 00037 instance_state_->empty(false); 00038 } 00039 }
void OpenDDS::DCPS::ReceivedDataElementList::apply_all | ( | ReceivedDataFilter & | match, | |
ReceivedDataOperation & | func | |||
) |
Definition at line 47 of file ReceivedDataElementList.cpp.
References head_, and OpenDDS::DCPS::ReceivedDataElement::next_data_sample_.
Referenced by OpenDDS::DCPS::ReceivedDataStrategy::accept_coherent().
00050 { 00051 for (ReceivedDataElement* it = head_; 00052 it != 0 ; it = it->next_data_sample_) { 00053 if (match(it)) { 00054 op(it); 00055 } 00056 } 00057 }
bool OpenDDS::DCPS::ReceivedDataElementList::remove | ( | ReceivedDataFilter & | match, | |
bool | eval_all | |||
) |
Definition at line 60 of file ReceivedDataElementList.cpp.
References OpenDDS::DCPS::InstanceState::empty(), head_, instance_state_, OpenDDS::DCPS::ReceivedDataElement::next_data_sample_, OpenDDS::DCPS::ReceivedDataElement::previous_data_sample_, size_, and tail_.
00063 { 00064 if (!head_) { 00065 return false; 00066 } 00067 00068 bool released = false; 00069 00070 for (ReceivedDataElement* item = head_ ; item != 0 ; 00071 item = item->next_data_sample_) { 00072 if (match(item)) { 00073 size_-- ; 00074 00075 if (item == head_) { 00076 if (head_ == tail_) { 00077 head_ = tail_ = 0; 00078 00079 } else { 00080 head_ = item->next_data_sample_ ; 00081 00082 if (head_) { 00083 head_->previous_data_sample_ = 0 ; 00084 } 00085 } 00086 00087 } else if (item == tail_) { 00088 tail_ = item->previous_data_sample_ ; 00089 00090 if (tail_) { 00091 tail_->next_data_sample_ = 0 ; 00092 } 00093 00094 } else { 00095 item->previous_data_sample_->next_data_sample_ = 00096 item->next_data_sample_ ; 00097 item->next_data_sample_->previous_data_sample_ = 00098 item->previous_data_sample_ ; 00099 } 00100 00101 if (instance_state_ && size_ == 0) { 00102 // let the instance know it is empty 00103 released = released || instance_state_->empty(true); 00104 } 00105 00106 if (!eval_all) break; 00107 } 00108 } 00109 00110 return released; 00111 }
bool OpenDDS::DCPS::ReceivedDataElementList::remove | ( | ReceivedDataElement * | data_sample | ) |
Definition at line 114 of file ReceivedDataElementList.cpp.
Referenced by OpenDDS::DCPS::ReceivedDataStrategy::reject_coherent(), remove_head(), remove_tail(), and OpenDDS::DCPS::DataReaderImpl_T< MessageType >::store_instance_data().
00115 { 00116 IdentityFilter match(data_sample); 00117 return remove(match, false); // short-circuit evaluation 00118 }
ACE_INLINE OpenDDS::DCPS::ReceivedDataElement * OpenDDS::DCPS::ReceivedDataElementList::remove_head | ( | ) |
Definition at line 43 of file ReceivedDataElementList.inl.
References head_, remove(), and size_.
Referenced by OpenDDS::DCPS::DataReaderImpl_T< MessageType >::purge_data().
00044 { 00045 if (!size_) { 00046 return 0 ; 00047 } 00048 00049 OpenDDS::DCPS::ReceivedDataElement *ptr = head_ ; 00050 00051 remove(head_) ; 00052 00053 return ptr ; 00054 }
ACE_INLINE OpenDDS::DCPS::ReceivedDataElement * OpenDDS::DCPS::ReceivedDataElementList::remove_tail | ( | ) |
Definition at line 58 of file ReceivedDataElementList.inl.
References remove(), size_, and tail_.
00059 { 00060 if (!size_) { 00061 return 0 ; 00062 } 00063 00064 OpenDDS::DCPS::ReceivedDataElement *ptr = tail_ ; 00065 00066 remove(tail_) ; 00067 00068 return ptr ; 00069 }
The first element of the list.
Definition at line 158 of file ReceivedDataElementList.h.
Referenced by OpenDDS::DCPS::SourceDataStrategy::add(), add(), apply_all(), OpenDDS::DCPS::DataReaderImpl_T< MessageType >::read_instance_i(), remove(), remove_head(), OpenDDS::DCPS::DataReaderImpl_T< MessageType >::store_instance_data(), and OpenDDS::DCPS::DataReaderImpl_T< MessageType >::take_instance_i().
Number of elements in the list.
Definition at line 164 of file ReceivedDataElementList.h.
Referenced by OpenDDS::DCPS::SourceDataStrategy::add(), add(), OpenDDS::DCPS::DataReaderImpl_T< MessageType >::purge_data(), remove(), remove_head(), remove_tail(), and OpenDDS::DCPS::DataReaderImpl_T< MessageType >::store_instance_data().
The last element of the list.
Definition at line 161 of file ReceivedDataElementList.h.
Referenced by add(), remove(), and remove_tail().