ConsumerChain.cc

00001 // Copyright 2008 Michael Marsh, University of Maryland.
00002 //
00003 // This file is part of pydtn.
00004 //
00005 // pydtn is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // pydtn is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with pydtn.  If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 // The views and conclusions contained in the software and documentation
00019 // are those of the authors and should not be interpreted as representing
00020 // official policies, either expressed or implied, of the University
00021 // of Maryland.
00022 //
00023 // pydtn extends and embeds the Python interpreter, which is
00024 // Copyright 2001-2006 Python Software Foundation, All Rights Reserved,
00025 // and is released under the PSF License Agreement.
00026 //
00027 // RANLUX random number generation uses the Boost library,
00028 // Copyright 1994-2006 by various authors (details in individual files),
00029 // which is released under the Boost Software License, Version 1.0.
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 }

Generated on Mon Mar 24 11:15:45 2008 for Pydtn Simulator by  doxygen 1.5.4