Wiselib
|
00001 #ifndef _FAKECLUSTERING_H 00002 #define _FAKECLUSTERING_H 00003 00004 #include "util/delegates/delegate.hpp" 00005 00006 namespace wiselib { 00007 template<typename OsModel_P, 00008 typename Radio_P, 00009 typename Timer_P, 00010 typename Debug_P> 00011 00012 class FakeClustering { 00013 public: 00014 typedef OsModel_P OsModel; 00015 typedef Radio_P Radio; 00016 typedef Timer_P Timer; 00017 typedef Debug_P Debug; 00018 typedef FakeClustering<OsModel_P, Radio_P, Timer_P, Debug_P> self_t; 00019 00020 typedef int cluster_id_t; 00021 typedef int cluster_level_t; 00022 typedef typename Radio::node_id_t node_id_t; 00023 typedef typename Radio::size_t size_t; 00024 typedef typename Radio::block_data_t block_data_t; 00025 typedef wiselib::vector_static<OsModel, node_id_t, 200 > vector_t; 00026 00027 typedef delegate1<void, int> cluster_delegate_t; 00028 00029 cluster_level_t cluster_level() { 00030 return 0; 00031 } 00032 00033 cluster_id_t cluster_id() { 00034 return 0; 00035 } 00036 00037 bool cluster_head() { 00038 if(radio_->id() == 5344 || radio_->id() == 3) // 0x14e0 Wiselib, 3 Shawn 00039 //if(radio_->id() == 0) 00040 return 1; // don't laugh ! 00041 return 0; 00042 } 00043 00044 node_id_t parent() { 00045 return 0; 00046 } 00047 00048 size_t hops() { 00049 return 1; 00050 } 00051 00052 template<class T, void (T::*TMethod)(int) > 00053 inline int reg_changed_callback(T *obj_pnt) { 00054 state_changed_callback_ = cluster_delegate_t::from_method<T, TMethod > (obj_pnt); 00055 return state_changed_callback_; 00056 } 00057 00058 void unreg_changed_callback(int idx) { 00059 state_changed_callback_ = cluster_delegate_t(); 00060 } 00061 00062 void init(Radio& radio, Timer& timer, Debug& debug) { 00063 radio_ = &radio; 00064 timer_ = &timer; 00065 debug_ = &debug; 00066 } 00067 00068 void enable(void) { } 00069 00070 void disable(){ } 00071 00072 private: 00073 00074 Radio *radio_; 00075 Timer *timer_; 00076 Debug *debug_; 00077 00078 cluster_delegate_t state_changed_callback_; 00079 }; 00080 } 00081 00082 #endif