Node.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2004-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 #ifndef _NODE_H_
00018 #define _NODE_H_
00019 
00020 #include <oasys/debug/DebugUtils.h>
00021 #include <oasys/debug/Log.h>
00022 
00023 #include "SimEventHandler.h"
00024 #include "bundling/BundleDaemon.h"
00025 
00026 using namespace dtn;
00027 
00028 namespace dtn {
00029 
00030 class ContactManager;
00031 
00032 }
00033 
00034 namespace dtnsim {
00035 
00044 class Node : public SimEventHandler, public BundleDaemon {
00045 public:
00049     Node(const char* name);
00050 
00054     void do_init();
00055 
00059     virtual ~Node() {}
00060         
00065     virtual void post_event(BundleEvent* event, bool at_back = true);
00066     
00070     virtual void process(SimEvent *e);
00071 
00075     void process_bundle_events();
00076     
00080     const char* name() { return name_.c_str(); }
00081     
00085     BundleRouter* router() { return router_; }
00086 
00095     void set_active()
00096     {
00097         instance_ = this;
00098         oasys::Log::instance()->set_prefix(name_.c_str());
00099     }
00100 
00104     static Node* active_node()
00105     {
00106         return (Node*)instance_;
00107     }
00108 
00109 protected:
00110     const std::string   name_;
00111     u_int32_t           next_bundleid_;
00112     u_int32_t           next_regid_;
00113     std::queue<BundleEvent*>* eventq_;
00114 };
00115 
00116 } // namespace dtnsim
00117 
00118 #endif /* _NODE_H_ */

Generated on Sat Sep 8 08:36:17 2007 for DTN Reference Implementation by  doxygen 1.5.3