• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/mobile/gridkeeper.h

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 #include "mobilenode.h"
00014 
00015 #define aligngrid(a,b) (((a)==(b))?((b)-1):((a)))
00016 
00017 
00018 class GridHandler : public Handler {
00019  public:
00020   GridHandler();
00021   void handle(Event *);
00022 };
00023 
00024 class GridKeeper : public TclObject {
00025 
00026 public:
00027   GridKeeper();
00028   ~GridKeeper();
00029   int command(int argc, const char*const* argv);
00030   int get_neighbors(MobileNode *mn, MobileNode **output);
00031   void new_moves(MobileNode *);
00032   void dump();
00033   static GridKeeper* instance() { return instance_;}
00034   int size_;                     /* how many nodes are kept */
00035 protected:
00036 
00037   MobileNode ***grid_;
00038 
00039   int dim_x_;
00040   int dim_y_;                    /* dimension */
00041   GridHandler *gh_; 
00042 
00043 private:
00044 
00045   static GridKeeper* instance_;
00046 
00047 };
00048 
00049 class MoveEvent : public Event {
00050 public:
00051   MoveEvent() : enter_(0), leave_(0), grid_x_(-1), grid_y_(-1) {}
00052   MobileNode **enter_;  /* grid to enter */
00053   MobileNode **leave_;  /* grid to leave */
00054   int grid_x_;
00055   int grid_y_;
00056   MobileNode *token_;    /* what node ?*/
00057 };
00058 
00059 
00060 
00061 #endif //gridkeeper_h
00062 
00063 

Generated on Tue Aug 10 2010 16:16:07 for ns-2.33 by  doxygen 1.7.1