00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _CONNECTIVITY_H_
00018 #define _CONNECTIVITY_H_
00019
00020 #include "SimEventHandler.h"
00021 #include <oasys/debug/DebugUtils.h>
00022 #include <oasys/debug/Logger.h>
00023 #include <oasys/util/StringUtils.h>
00024
00025 namespace dtnsim {
00026
00027 class Node;
00028
00029
00034 struct ConnState {
00039 ConnState(): open_(true), bw_(100000), latency_(0.01) {}
00040
00044 ConnState(bool open, int bw, int latency)
00045 : open_(open), bw_(bw), latency_(latency) {}
00046
00050 bool parse_time(const char* time_str, double* time);
00051
00056 bool parse_options(int argc, const char** argv, const char** invalidp);
00057
00058 bool open_;
00059 u_int64_t bw_;
00060 double latency_;
00061 };
00062
00067 class Connectivity : public oasys::Logger {
00068 public:
00072 static Connectivity* instance()
00073 {
00074 if (!instance_) {
00075 ASSERT(type_ != "");
00076 instance_ = create_conn();
00077 }
00078
00079 return instance_;
00080 }
00081
00085 Connectivity();
00086
00090 virtual ~Connectivity() {}
00091
00095 const ConnState* lookup(Node* n1, Node* n2);
00096
00097 protected:
00098 friend class ConnCommand;
00099
00105 typedef oasys::StringHashMap<ConnState> StateTable;
00106 StateTable state_;
00107
00111 static Connectivity* create_conn();
00112
00116 void set_state(const char* n1, const char* n2, const ConnState& s);
00117
00118 static std::string type_;
00119 static Connectivity* instance_;
00120 };
00121
00122 }
00123
00124 #endif