00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "ConsumerChain.h"
00032 #include "Bundle.h"
00033 #include "Node.h"
00034
00035 using namespace DTN;
00036
00037 ConsumerChain::~ConsumerChain()
00038 {
00039 ChainType::iterator itr = m_chain.begin();
00040 ChainType::iterator end = m_chain.end();
00041 for ( ; itr != end ; ++itr )
00042 {
00043 if ( 0 != *itr )
00044 {
00045 delete *itr;
00046 }
00047 }
00048 }
00049
00050 void
00051 ConsumerChain::operator()( const Bundle& b )
00052 {
00053 ChainType::iterator itr = m_chain.begin();
00054 ChainType::iterator end = m_chain.end();
00055 for ( ; itr != end ; ++itr )
00056 {
00057 if ( 0 != *itr )
00058 {
00059 (**itr)(b);
00060 }
00061 }
00062 }
00063
00064 void
00065 ConsumerChain::drop( const Bundle& b, const DropCause& c )
00066 {
00067 ChainType::iterator itr = m_chain.begin();
00068 ChainType::iterator end = m_chain.end();
00069 for ( ; itr != end ; ++itr )
00070 {
00071 if ( 0 != *itr )
00072 {
00073 (*itr)->drop(b,c);
00074 }
00075 }
00076 }
00077
00078 void
00079 ConsumerChain::custody( const Bundle& b )
00080 {
00081 ChainType::iterator itr = m_chain.begin();
00082 ChainType::iterator end = m_chain.end();
00083 for ( ; itr != end ; ++itr )
00084 {
00085 if ( 0 != *itr )
00086 {
00087 (*itr)->custody(b);
00088 }
00089 }
00090 }
00091
00092 void
00093 ConsumerChain::persistentStore( const Bundle& b )
00094 {
00095 ChainType::iterator itr = m_chain.begin();
00096 ChainType::iterator end = m_chain.end();
00097 for ( ; itr != end ; ++itr )
00098 {
00099 if ( 0 != *itr )
00100 {
00101 (*itr)->persistentStore(b);
00102 }
00103 }
00104 }
00105
00106 void
00107 ConsumerChain::persistentRemove( const Bundle& b, bool cleanup )
00108 {
00109 ChainType::iterator itr = m_chain.begin();
00110 ChainType::iterator end = m_chain.end();
00111 for ( ; itr != end ; ++itr )
00112 {
00113 if ( 0 != *itr )
00114 {
00115 (*itr)->persistentRemove(b,cleanup);
00116 }
00117 }
00118 }
00119
00120 void
00121 ConsumerChain::send( const Bundle& b )
00122 {
00123 ChainType::iterator itr = m_chain.begin();
00124 ChainType::iterator end = m_chain.end();
00125 for ( ; itr != end ; ++itr )
00126 {
00127 if ( 0 != *itr )
00128 {
00129 (*itr)->send(b);
00130 }
00131 }
00132 }
00133
00134 void
00135 ConsumerChain::recv( const Bundle& b )
00136 {
00137 ChainType::iterator itr = m_chain.begin();
00138 ChainType::iterator end = m_chain.end();
00139 for ( ; itr != end ; ++itr )
00140 {
00141 if ( 0 != *itr )
00142 {
00143 (*itr)->recv(b);
00144 }
00145 }
00146 }
00147
00148 void
00149 ConsumerChain::exhausted( const Bundle& b )
00150 {
00151 ChainType::iterator itr = m_chain.begin();
00152 ChainType::iterator end = m_chain.end();
00153 for ( ; itr != end ; ++itr )
00154 {
00155 if ( 0 != *itr )
00156 {
00157 (*itr)->exhausted(b);
00158 }
00159 }
00160 }
00161
00162 void
00163 ConsumerChain::addConsumer( Consumer* c )
00164 {
00165 if ( 0 != c )
00166 {
00167 m_chain.push_back(c);
00168 }
00169 }