Tracer.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 "simlpy/interpreter_defs.h"
00032 
00033 #include "Tracer.h"
00034 #include "WrapNode.h"
00035 #include "WrapLink.h"
00036 
00037 TracerChain::~TracerChain()
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 TracerChain::node( const WrapNode& wn )
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)->node(wn);
00060       }
00061    }
00062 }
00063 
00064 void
00065 TracerChain::link( const WrapLink& wn )
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)->link(wn);
00074       }
00075    }
00076 }
00077 
00078 void
00079 TracerChain::enqueue( const DTN::Bundle& b, const DTN::Node* n )
00080 {
00081    if ( 0 == n ) return;
00082    ChainType::iterator itr = m_chain.begin();
00083    ChainType::iterator end = m_chain.end();
00084    for ( ; itr != end ; ++itr )
00085    {
00086       if ( 0 != *itr )
00087       {
00088          (*itr)->enqueue(b,n);
00089       }
00090    }
00091 }
00092 
00093 void
00094 TracerChain::dequeue( const DTN::Bundle& b, const DTN::Node* n )
00095 {
00096    if ( 0 == n ) return;
00097    ChainType::iterator itr = m_chain.begin();
00098    ChainType::iterator end = m_chain.end();
00099    for ( ; itr != end ; ++itr )
00100    {
00101       if ( 0 != *itr )
00102       {
00103          (*itr)->dequeue(b,n);
00104       }
00105    }
00106 }
00107 
00108 void
00109 TracerChain::send( const DTN::Bundle& b, const DTN::Node* n )
00110 {
00111    if ( 0 == n ) return;
00112    ChainType::iterator itr = m_chain.begin();
00113    ChainType::iterator end = m_chain.end();
00114    for ( ; itr != end ; ++itr )
00115    {
00116       if ( 0 != *itr )
00117       {
00118          (*itr)->send(b,n);
00119       }
00120    }
00121 }
00122 
00123 void
00124 TracerChain::receive( const DTN::Bundle& b, const DTN::Node* n )
00125 {
00126    if ( 0 == n ) return;
00127    ChainType::iterator itr = m_chain.begin();
00128    ChainType::iterator end = m_chain.end();
00129    for ( ; itr != end ; ++itr )
00130    {
00131       if ( 0 != *itr )
00132       {
00133          (*itr)->receive(b,n);
00134       }
00135    }
00136 }
00137 
00138 void
00139 TracerChain::drop( const DTN::Bundle& b,
00140                    const DTN::DropCause& c,
00141                    const DTN::Node* n )
00142 {
00143    if ( 0 == n ) return;
00144    ChainType::iterator itr = m_chain.begin();
00145    ChainType::iterator end = m_chain.end();
00146    for ( ; itr != end ; ++itr )
00147    {
00148       if ( 0 != *itr )
00149       {
00150          (*itr)->drop(b,c,n);
00151       }
00152    }
00153 }
00154 
00155 void
00156 TracerChain::addTracer( Tracer* t )
00157 {
00158    if ( 0 != t )
00159    {
00160       m_chain.push_back(t);
00161    }
00162 }
00163 
00164 GlobalTracer* GlobalTracer::m_instance = 0;
00165 
00166 GlobalTracer::GlobalTracer()
00167 {
00168 }
00169 
00170 GlobalTracer::~GlobalTracer()
00171 {
00172 }
00173 
00174 void
00175 GlobalTracer::enable()
00176 {
00177    if ( 0 != m_instance ) return;
00178    m_instance = new GlobalTracer();
00179 }
00180 
00181 GlobalTracer*
00182 GlobalTracer::instance()
00183 {
00184    return m_instance;
00185 }

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