diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-06-03 15:22:35 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-06-03 15:22:35 +0000 |
commit | 6fcf117c7543a6adec19a6afea0da7df087170ab (patch) | |
tree | fe44c8b8b9042dab8a8a2acd8797d33a44e5bfce /gensigs.bld | |
parent | 665b31165837d89ac9b64f9d9a540d0b87ae19e5 (diff) | |
download | libbu++-6fcf117c7543a6adec19a6afea0da7df087170ab.tar.gz libbu++-6fcf117c7543a6adec19a6afea0da7df087170ab.tar.bz2 libbu++-6fcf117c7543a6adec19a6afea0da7df087170ab.tar.xz libbu++-6fcf117c7543a6adec19a6afea0da7df087170ab.zip |
A build file that will generate the signals file has been started.
Diffstat (limited to 'gensigs.bld')
-rw-r--r-- | gensigs.bld | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/gensigs.bld b/gensigs.bld new file mode 100644 index 0000000..accf107 --- /dev/null +++ b/gensigs.bld | |||
@@ -0,0 +1,136 @@ | |||
1 | for i in range( 0, 5 ) do | ||
2 | { | ||
3 | templparams = ""; | ||
4 | funcparams = ""; | ||
5 | templcallparams = ""; | ||
6 | funccallparams = ""; | ||
7 | if i >= 1 then | ||
8 | { | ||
9 | for p in range( 1, i ) do | ||
10 | { | ||
11 | if p > 1 then | ||
12 | { | ||
13 | templcallparams << ", "; | ||
14 | funccallparams << ", "; | ||
15 | funcparams << ", "; | ||
16 | } | ||
17 | templparams << ", typename p${p}t"; | ||
18 | funcparams << "p${p}t p${p}"; | ||
19 | templcallparams << "p${p}t"; | ||
20 | funccallparams << "p${p}"; | ||
21 | } | ||
22 | } | ||
23 | warning "template<typename ret${templparams}>"; | ||
24 | warning "virtual ret operator()( ${funcparams} )=0;"; | ||
25 | } | ||
26 | /* | ||
27 | |||
28 | // | ||
29 | // 1 Parameter | ||
30 | // | ||
31 | |||
32 | template<typename ret, typename p1t> | ||
33 | class _Slot1 | ||
34 | { | ||
35 | public: | ||
36 | _Slot1() { } | ||
37 | virtual ~_Slot1() { } | ||
38 | |||
39 | virtual ret operator()( p1t p1 )=0; | ||
40 | |||
41 | virtual _Slot1<ret, p1t> *clone() const=0; | ||
42 | }; | ||
43 | |||
44 | template<typename cls, typename ret, typename p1t> | ||
45 | class __Slot1 : public _Slot1<ret, p1t> | ||
46 | { | ||
47 | public: | ||
48 | __Slot1( cls *pCls, ret (cls::*pFnc)( p1t ) ) : | ||
49 | pCls( pCls ), pFnc( pFnc ) { } | ||
50 | virtual ~__Slot1() { } | ||
51 | |||
52 | virtual ret operator()( p1t p1 ) | ||
53 | { | ||
54 | return (pCls->*pFnc)( p1 ); | ||
55 | } | ||
56 | |||
57 | virtual _Slot1<ret, p1t> *clone() const | ||
58 | { | ||
59 | return new __Slot1<cls, ret, p1t>( pCls, pFnc ); | ||
60 | } | ||
61 | |||
62 | private: | ||
63 | cls *pCls; | ||
64 | ret (cls::*pFnc)( p1t ); | ||
65 | }; | ||
66 | |||
67 | template<typename ret, typename p1t> | ||
68 | class __Slot1F : public _Slot1<ret, p1t> | ||
69 | { | ||
70 | public: | ||
71 | __Slot1F( ret (*pFnc)( p1t ) ) : | ||
72 | pFnc( pFnc ) { } | ||
73 | virtual ~__Slot1F() { } | ||
74 | |||
75 | virtual ret operator()( p1t p1 ) | ||
76 | { | ||
77 | return (*pFnc)( p1 ); | ||
78 | } | ||
79 | |||
80 | virtual _Slot1<ret, p1t> *clone() const | ||
81 | { | ||
82 | return new __Slot1F<ret, p1t>( pFnc ); | ||
83 | } | ||
84 | |||
85 | private: | ||
86 | ret (*pFnc)( p1t p1 ); | ||
87 | }; | ||
88 | |||
89 | template<typename ret, typename p1t> | ||
90 | class Signal1 | ||
91 | { | ||
92 | public: | ||
93 | Signal1() : pCb( NULL ) { } | ||
94 | Signal1( _Slot1<ret, p1t> *pCb ) : pCb( pCb ) { } | ||
95 | Signal1( const Signal1<ret, p1t> &rSrc ) : | ||
96 | pCb( (rSrc.pCb)?(rSrc.pCb->clone()):(NULL) ) { } | ||
97 | |||
98 | virtual ~Signal1() { delete pCb; pCb = NULL; } | ||
99 | |||
100 | ret operator()( p1t p1 ) | ||
101 | { | ||
102 | if( !pCb ) throw SignalException("Uninitialized signal used."); | ||
103 | return (*pCb)( p1 ); | ||
104 | } | ||
105 | |||
106 | bool isSet() const { return pCb != NULL; } | ||
107 | operator bool() const { return isSet(); } | ||
108 | |||
109 | Signal1<ret, p1t> &operator=( const Signal1<ret, p1t> &rhs ) | ||
110 | { | ||
111 | pCb = rhs.pCb->clone(); | ||
112 | return *this; | ||
113 | } | ||
114 | |||
115 | private: | ||
116 | _Slot1<ret, p1t> *pCb; | ||
117 | }; | ||
118 | |||
119 | template<typename cls, typename ret, typename p1t> | ||
120 | Signal1<ret, p1t> slot( cls *pCls, ret (cls::*pFnc)( p1t ) ) | ||
121 | { | ||
122 | if( !pCls || !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
123 | return Signal1<ret, p1t>( | ||
124 | new __Slot1<cls, ret, p1t>( pCls, pFnc ) | ||
125 | ); | ||
126 | } | ||
127 | |||
128 | template<typename ret, typename p1t> | ||
129 | Signal1<ret, p1t> slot( ret (*pFnc)( p1t ) ) | ||
130 | { | ||
131 | if( !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
132 | return Signal1<ret, p1t>( | ||
133 | new __Slot1F<ret, p1t>( pFnc ) | ||
134 | ); | ||
135 | } | ||
136 | */ | ||