Alex Bikfalvi
SimStream Documentation
Delegate.h
00001 #pragma once 00002 00003 #include "IDelegate.h" 00004 00005 template<typename T, typename R> class Delegate0 : public IDelegate0<R> 00006 { 00007 private: 00008 T* object; 00009 R (T::*func)(); 00010 00011 public: 00012 Delegate0(T* object, R (T::*func)()) 00013 { 00014 this->object = object; 00015 this->func = func; 00016 } 00017 virtual ~Delegate0() { } 00018 00019 virtual R operator()() 00020 { 00021 return (this->object->*this->func)(); 00022 } 00023 }; 00024 00025 template<typename T, typename R, typename P1> class Delegate1 : public IDelegate1<R, P1> 00026 { 00027 private: 00028 T* object; 00029 R (T::*func)(P1); 00030 00031 public: 00032 Delegate1(T* object, R (T::*func)(P1)) 00033 { 00034 this->object = object; 00035 this->func = func; 00036 } 00037 virtual ~Delegate1() { } 00038 00039 virtual R operator()(P1 p1) 00040 { 00041 return (this->object->*this->func)(p1); 00042 } 00043 }; 00044 00045 template<typename T, typename R, typename P1, typename P2> class Delegate2 : public IDelegate2<R, P1, P2> 00046 { 00047 private: 00048 T* object; 00049 R (T::*func)(P1, P2); 00050 00051 public: 00052 Delegate2(T* object, R (T::*func)(P1, P2)) 00053 { 00054 this->object = object; 00055 this->func = func; 00056 } 00057 virtual ~Delegate2() { } 00058 00059 virtual R operator()(P1 p1, P2 p2) 00060 { 00061 return (this->object->*this->func)(p1, p2); 00062 } 00063 }; 00064 00065 template<typename T, typename R, typename P1, typename P2, typename P3> class Delegate3 : public IDelegate3<R, P1, P2, P3> 00066 { 00067 private: 00068 T* object; 00069 R (T::*func)(P1, P2, P3); 00070 00071 public: 00072 Delegate3(T* object, R (T::*func)(P1, P2, P3)) 00073 { 00074 this->object = object; 00075 this->func = func; 00076 } 00077 virtual ~Delegate3() { } 00078 00079 virtual R operator()(P1 p1, P2 p2, P3 p3) 00080 { 00081 return (this->object->*this->func)(p1, p2, p3); 00082 } 00083 }; 00084 00085 template<typename T, typename R, typename P1, typename P2, typename P3, typename P4> class Delegate4 : public IDelegate4<R, P1, P2, P3, P4> 00086 { 00087 private: 00088 T* object; 00089 R (T::*func)(P1, P2, P3, P4); 00090 00091 public: 00092 Delegate4(T* object, R (T::*func)(P1, P2, P3, P4)) 00093 { 00094 this->object = object; 00095 this->func = func; 00096 } 00097 virtual ~Delegate4() { } 00098 00099 virtual R operator()(P1 p1, P2 p2, P3 p3, P4 p4) 00100 { 00101 return (this->object->*this->func)(p1, p2, p3, p4); 00102 } 00103 }; 00104 00105 template<typename T, typename R, typename P1, typename P2, typename P3, typename P4, typename P5> class Delegate5 : public IDelegate5<R, P1, P2, P3, P4, P5> 00106 { 00107 private: 00108 T* object; 00109 R (T::*func)(P1, P2, P3, P4, P5); 00110 00111 public: 00112 Delegate5(T* object, R (T::*func)(P1, P2, P3, P4, P5)) 00113 { 00114 this->object = object; 00115 this->func = func; 00116 } 00117 virtual ~Delegate5() { } 00118 00119 virtual R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) 00120 { 00121 return (this->object->*this->func)(p1, p2, p3, p4, p5); 00122 } 00123 };
Last updated: February 8, 2011