00001 /* 00002 * A possible optimizer for wireless simulation 00003 * 00004 * No guarantee for making wireless simulation better 00005 * Use it according to your scenario 00006 * 00007 * Ported from Sun's mobility code 00008 */ 00009 00010 #ifndef __gridkeeper_h__ 00011 #define __gridkeeper_h__ 00012 00013 00014 #include "mobilenode.h" 00015 00016 #define min(a,b) (((a)>(b))?(b):(a)) 00017 #define max(a,b) (((a)<(b))?(b):(a)) 00018 #define aligngrid(a,b) (((a)==(b))?((b)-1):((a))) 00019 00020 00021 class GridHandler : public Handler { 00022 public: 00023 GridHandler(); 00024 void handle(Event *); 00025 }; 00026 00027 class GridKeeper : public TclObject { 00028 00029 public: 00030 GridKeeper(); 00031 ~GridKeeper(); 00032 int command(int argc, const char*const* argv); 00033 int get_neighbors(MobileNode *mn, MobileNode **output); 00034 void new_moves(MobileNode *); 00035 void dump(); 00036 static GridKeeper* instance() { return instance_;} 00037 int size_; /* how many nodes are kept */ 00038 protected: 00039 00040 MobileNode ***grid_; 00041 00042 int dim_x_; 00043 int dim_y_; /* dimension */ 00044 GridHandler *gh_; 00045 00046 private: 00047 00048 static GridKeeper* instance_; 00049 00050 }; 00051 00052 class MoveEvent : public Event { 00053 public: 00054 MoveEvent() : enter_(0), leave_(0), grid_x_(-1), grid_y_(-1) {} 00055 MobileNode **enter_; /* grid to enter */ 00056 MobileNode **leave_; /* grid to leave */ 00057 int grid_x_; 00058 int grid_y_; 00059 MobileNode *token_; /* what node ?*/ 00060 }; 00061 00062 00063 00064 #endif //gridkeeper_h 00065 00066
1.3.3