diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2012-12-20 00:13:45 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2012-12-20 00:13:45 +0000 |
| commit | 8ba750c2d52b9db90c8274020c6053a32441ed43 (patch) | |
| tree | c17e0e12a34fdc4bbe59dbe4ba92e74a77cf3ffd /src/tests | |
| parent | 15628cc7534c008d0f5e206f29fd71a412031650 (diff) | |
| download | libbu++-8ba750c2d52b9db90c8274020c6053a32441ed43.tar.gz libbu++-8ba750c2d52b9db90c8274020c6053a32441ed43.tar.bz2 libbu++-8ba750c2d52b9db90c8274020c6053a32441ed43.tar.xz libbu++-8ba750c2d52b9db90c8274020c6053a32441ed43.zip | |
gensigs.bld now generates SignalList classes in addition to Signal classes.
They're pretty nifty.
Diffstat (limited to '')
| -rw-r--r-- | src/tests/signal.cpp | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/src/tests/signal.cpp b/src/tests/signal.cpp index 8920461..93519fa 100644 --- a/src/tests/signal.cpp +++ b/src/tests/signal.cpp | |||
| @@ -17,56 +17,16 @@ void PrintFancy( const Bu::String &s ) | |||
| 17 | 17 | ||
| 18 | int Square( int a ) | 18 | int Square( int a ) |
| 19 | { | 19 | { |
| 20 | println("Square called"); | ||
| 20 | return a*a; | 21 | return a*a; |
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | int Double( int a ) | 24 | int Double( int a ) |
| 24 | { | 25 | { |
| 26 | println("Double called"); | ||
| 25 | return a+a; | 27 | return a+a; |
| 26 | } | 28 | } |
| 27 | 29 | ||
| 28 | template<typename R, typename P> | ||
| 29 | class SignalList1 : public Bu::List<Bu::Signal1<R,P> > | ||
| 30 | { | ||
| 31 | typedef Bu::List<Bu::Signal1<R,P> > MyType; | ||
| 32 | public: | ||
| 33 | SignalList1() | ||
| 34 | { | ||
| 35 | } | ||
| 36 | |||
| 37 | using MyType::iterator; | ||
| 38 | using MyType::const_iterator; | ||
| 39 | |||
| 40 | R operator()( P p1 ) | ||
| 41 | { | ||
| 42 | println("===Non-void um...non-specialization==="); | ||
| 43 | R tmp; | ||
| 44 | for( typename MyType::iterator i = MyType::begin(); i; i++ ) | ||
| 45 | tmp = (*i)( p1 ); | ||
| 46 | return tmp; | ||
| 47 | } | ||
| 48 | }; | ||
| 49 | |||
| 50 | template<typename P> | ||
| 51 | class SignalList1<void, P> : public Bu::List<Bu::Signal1<void,P> > | ||
| 52 | { | ||
| 53 | typedef Bu::List<Bu::Signal1<void,P> > MyType; | ||
| 54 | public: | ||
| 55 | SignalList1() | ||
| 56 | { | ||
| 57 | } | ||
| 58 | |||
| 59 | using MyType::iterator; | ||
| 60 | using MyType::const_iterator; | ||
| 61 | |||
| 62 | void operator()( P p1 ) | ||
| 63 | { | ||
| 64 | println("===Void specialization==="); | ||
| 65 | for( typename MyType::iterator i = MyType::begin(); i; i++ ) | ||
| 66 | (*i)( p1 ); | ||
| 67 | } | ||
| 68 | }; | ||
| 69 | |||
| 70 | int main() | 30 | int main() |
| 71 | { | 31 | { |
| 72 | SignalList1<void,const Bu::String &> lPrints; | 32 | SignalList1<void,const Bu::String &> lPrints; |
