WrapNode.h

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 #ifndef __WRAPPERS_HARNESS_WRAP_NODE_H__
00032 #define __WRAPPERS_HARNESS_WRAP_NODE_H__
00033 
00034 
00035 #include "config.h"
00036 #include "dtn/Node.h"
00037 #include "dtn/ConsumerChain.h"
00038 #include "dtn/Application.h"
00039 #include "BundleHandler.h"
00040 #include "NodeCollector.h"
00041 
00042 #include <list>
00043 
00044 class BundleEvent;
00045 class ResendEvent;
00046 
00049 
00058 class WrapNode : public BundleHandler
00059 {
00060    public :
00062       typedef std::list< NodeCollector* > CollectorList;
00063 
00065       WrapNode();
00067       virtual ~WrapNode();
00068 
00070       Entity* create() const;
00071 
00092       void configure( const ArgList& args );
00093 
00116       void emit( const ArgList& args );
00117 
00119       InterpreterItem get( const ArgList& args );
00120 
00125       void addLink( DTN::Link* l );
00126 
00130       void addConsumer( DTN::Consumer* c );
00131 
00135       void addApplication( DTN::Application* a );
00136 
00140       void addCollector( NodeCollector* c );
00141 
00144       void setVolatileStorePolicy( DTN::VolatileStorePolicy* p );
00145 
00149       void setForwardingPolicy( DTN::ForwardingPolicy* p );
00150 
00153       void setVolatileStore( DTN::VolatileBundleStore* s );
00154 
00157       void setPersistentStore( DTN::PersistentBundleStore* s );
00158 
00168       bool handler( BundleEvent& event );
00169 
00178       bool handler( ResendEvent& event );
00179 
00183       std::string identifier() const { return "node"; }
00184 
00186       void finalize() const;
00187 
00189       void collect() const;
00190 
00193       void setAddr( const DTN::ByteString& a );
00194 
00196       DTN::Node& node() { return m_node; }
00197 
00200       const DTN::ByteString& addr() const;
00201 
00203       const std::string& addrString() const;
00204 
00209       void forwardOn( DTN::Link& l );
00210 
00215       void drop( DTN::Bundle* b, const DTN::DropCause& c=DTN::DropCause::inst);
00216 
00218       size_t volatileBundles() const;
00219 
00221       DTN::BundlePointer cachedVolatile();
00222 
00224       const DTN::BundlePointer cachedVolatile() const;
00225 
00227       size_t persistentBundles() const;
00228 
00230       DTN::BundlePointer cachedPersistent();
00231 
00233       const DTN::BundlePointer cachedPersistent() const;
00234 
00236       const Time& bundleLifetime() const { return m_bundleLifetime; }
00237 
00238    private :
00239       DTN::Node  m_node; 
00240 
00241       DTN::ConsumerChain*  m_consumers; 
00242       CollectorList        m_collectors;
00243 
00244       Time  m_bundleLifetime;
00245 
00246       Time  m_resendPeriod;
00247       bool  m_resending;
00248 
00249       mutable std::string  m_addrString;
00250 };
00251 
00253 
00254 #endif /* __WRAPPERS_HARNESS_WRAP_NODE_H__ */

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