From 6fcf117c7543a6adec19a6afea0da7df087170ab Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 3 Jun 2011 15:22:35 +0000 Subject: A build file that will generate the signals file has been started. --- gensigs.bld | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 gensigs.bld diff --git a/gensigs.bld b/gensigs.bld new file mode 100644 index 0000000..accf107 --- /dev/null +++ b/gensigs.bld @@ -0,0 +1,136 @@ +for i in range( 0, 5 ) do +{ + templparams = ""; + funcparams = ""; + templcallparams = ""; + funccallparams = ""; + if i >= 1 then + { + for p in range( 1, i ) do + { + if p > 1 then + { + templcallparams << ", "; + funccallparams << ", "; + funcparams << ", "; + } + templparams << ", typename p${p}t"; + funcparams << "p${p}t p${p}"; + templcallparams << "p${p}t"; + funccallparams << "p${p}"; + } + } + warning "template"; + warning "virtual ret operator()( ${funcparams} )=0;"; +} +/* + + // + // 1 Parameter + // + + template + class _Slot1 + { + public: + _Slot1() { } + virtual ~_Slot1() { } + + virtual ret operator()( p1t p1 )=0; + + virtual _Slot1 *clone() const=0; + }; + + template + class __Slot1 : public _Slot1 + { + public: + __Slot1( cls *pCls, ret (cls::*pFnc)( p1t ) ) : + pCls( pCls ), pFnc( pFnc ) { } + virtual ~__Slot1() { } + + virtual ret operator()( p1t p1 ) + { + return (pCls->*pFnc)( p1 ); + } + + virtual _Slot1 *clone() const + { + return new __Slot1( pCls, pFnc ); + } + + private: + cls *pCls; + ret (cls::*pFnc)( p1t ); + }; + + template + class __Slot1F : public _Slot1 + { + public: + __Slot1F( ret (*pFnc)( p1t ) ) : + pFnc( pFnc ) { } + virtual ~__Slot1F() { } + + virtual ret operator()( p1t p1 ) + { + return (*pFnc)( p1 ); + } + + virtual _Slot1 *clone() const + { + return new __Slot1F( pFnc ); + } + + private: + ret (*pFnc)( p1t p1 ); + }; + + template + class Signal1 + { + public: + Signal1() : pCb( NULL ) { } + Signal1( _Slot1 *pCb ) : pCb( pCb ) { } + Signal1( const Signal1 &rSrc ) : + pCb( (rSrc.pCb)?(rSrc.pCb->clone()):(NULL) ) { } + + virtual ~Signal1() { delete pCb; pCb = NULL; } + + ret operator()( p1t p1 ) + { + if( !pCb ) throw SignalException("Uninitialized signal used."); + return (*pCb)( p1 ); + } + + bool isSet() const { return pCb != NULL; } + operator bool() const { return isSet(); } + + Signal1 &operator=( const Signal1 &rhs ) + { + pCb = rhs.pCb->clone(); + return *this; + } + + private: + _Slot1 *pCb; + }; + + template + Signal1 slot( cls *pCls, ret (cls::*pFnc)( p1t ) ) + { + if( !pCls || !pFnc ) throw SignalException("NULL pointer in slot()."); + return Signal1( + new __Slot1( pCls, pFnc ) + ); + } + + template + Signal1 slot( ret (*pFnc)( p1t ) ) + { + if( !pFnc ) throw SignalException("NULL pointer in slot()."); + return Signal1( + new __Slot1F( pFnc ) + ); + } + */ -- cgit v1.2.3