Alex Bikfalvi
SimStream Documentation
Event.h
00001 #pragma once 00002 00003 #include <list> 00004 #include "IDelegate.h" 00005 00006 using namespace std; 00007 00008 template<typename R> class Event0 00009 { 00010 private: 00011 list<IDelegate0<R>*> delegates; 00012 00013 public: 00014 Event0() { } 00015 virtual ~Event0() { } 00016 00017 void operator+=(IDelegate0<R>* del); 00018 void operator()(); 00019 }; 00020 00021 template<typename R, typename P1> class Event1 00022 { 00023 private: 00024 list<IDelegate1<R, P1>*> delegates; 00025 00026 public: 00027 Event1() { } 00028 virtual ~Event1() { } 00029 00030 void operator+=(IDelegate1<R, P1>* del); 00031 void operator()(P1 p1); 00032 }; 00033 00034 template<typename R, typename P1, typename P2> class Event2 00035 { 00036 private: 00037 list<IDelegate2<R, P1, P2>*> delegates; 00038 00039 public: 00040 Event2() { } 00041 virtual ~Event2() { } 00042 00043 void operator+=(IDelegate2<R, P1, P2>* del); 00044 void operator()(P1 p1, P2 p2); 00045 }; 00046 00047 template<typename R, typename P1, typename P2, typename P3> class Event3 00048 { 00049 private: 00050 list<IDelegate3<R, P1, P2, P3>*> delegates; 00051 00052 public: 00053 Event3() { } 00054 virtual ~Event3() { } 00055 00056 void operator+=(IDelegate3<R, P1, P2, P3>* del); 00057 void operator()(P1 p1, P2 p2, P3 p3); 00058 }; 00059 00060 template<typename R, typename P1, typename P2, typename P3, typename P4> class Event4 00061 { 00062 private: 00063 list<IDelegate4<R, P1, P2, P3, P4>*> delegates; 00064 00065 public: 00066 Event4() { } 00067 virtual ~Event4() { } 00068 00069 void operator+=(IDelegate4<R, P1, P2, P3, P4>* del); 00070 void operator()(P1 p1, P2 p2, P3 p3, P4 p4); 00071 }; 00072 00073 template<typename R, typename P1, typename P2, typename P3, typename P4, typename P5> class Event5 00074 { 00075 private: 00076 list<IDelegate5<R, P1, P2, P3, P4, P5>*> delegates; 00077 00078 public: 00079 Event5() { } 00080 virtual ~Event5() { } 00081 00082 void operator+=(IDelegate5<R, P1, P2, P3, P4, P5>* del); 00083 void operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5); 00084 }; 00085 00086 template<typename R> void Event0<R>::operator +=(IDelegate0<R> *del) 00087 { 00088 this->delegates.push_back(del); 00089 } 00090 00091 template<typename R> void Event0<R>::operator ()() 00092 { 00093 for(typename list<IDelegate0<R>*>::iterator iter = this->delegates.begin(); iter != this->delegates.end(); iter++) 00094 (**iter)(); 00095 } 00096 00097 template<typename R, typename P1> void Event1<R, P1>::operator +=(IDelegate1<R, P1> *del) 00098 { 00099 this->delegates.push_back(del); 00100 } 00101 00102 template<typename R, typename P1> void Event1<R, P1>::operator ()(P1 p1) 00103 { 00104 for(typename list<IDelegate1<R, P1>*>::iterator iter = this->delegates.begin(); iter != this->delegates.end(); iter++) 00105 (**iter)(p1); 00106 } 00107 00108 template<typename R, typename P1, typename P2> void Event2<R, P1, P2>::operator +=(IDelegate2<R, P1, P2> *del) 00109 { 00110 this->delegates.push_back(del); 00111 } 00112 00113 template<typename R, typename P1, typename P2> void Event2<R, P1, P2>::operator ()(P1 p1, P2 p2) 00114 { 00115 for(typename list<IDelegate2<R, P1, P2>*>::iterator iter = this->delegates.begin(); iter != this->delegates.end(); iter++) 00116 (**iter)(p1, p2); 00117 } 00118 00119 template<typename R, typename P1, typename P2, typename P3> void Event3<R, P1, P2, P3>::operator +=(IDelegate3<R, P1, P2, P3> *del) 00120 { 00121 this->delegates.push_back(del); 00122 } 00123 00124 template<typename R, typename P1, typename P2, typename P3> void Event3<R, P1, P2, P3>::operator ()(P1 p1, P2 p2, P3 p3) 00125 { 00126 for(typename list<IDelegate3<R, P1, P2, P3>*>::iterator iter = this->delegates.begin(); iter != this->delegates.end(); iter++) 00127 (**iter)(p1, p2, p3); 00128 } 00129 00130 template<typename R, typename P1, typename P2, typename P3, typename P4> void Event4<R, P1, P2, P3, P4>::operator +=(IDelegate4<R, P1, P2, P3, P4> *del) 00131 { 00132 this->delegates.push_back(del); 00133 } 00134 00135 template<typename R, typename P1, typename P2, typename P3, typename P4> void Event4<R, P1, P2, P3, P4>::operator ()(P1 p1, P2 p2, P3 p3, P4 p4) 00136 { 00137 for(typename list<IDelegate4<R, P1, P2, P3, P4>*>::iterator iter = this->delegates.begin(); iter != this->delegates.end(); iter++) 00138 (**iter)(p1, p2, p3, p4); 00139 } 00140 00141 template<typename R, typename P1, typename P2, typename P3, typename P4, typename P5> void Event5<R, P1, P2, P3, P4, P5>::operator +=(IDelegate5<R, P1, P2, P3, P4, P5> *del) 00142 { 00143 this->delegates.push_back(del); 00144 } 00145 00146 template<typename R, typename P1, typename P2, typename P3, typename P4, typename P5> void Event5<R, P1, P2, P3, P4, P5>::operator ()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) 00147 { 00148 for(typename list<IDelegate5<R, P1, P2, P3, P4, P5>*>::iterator iter = this->delegates.begin(); iter != this->delegates.end(); iter++) 00149 (**iter)(p1, p2, p3, p4, p5); 00150 }
Last updated: February 8, 2011