#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Core/Base/CallMethods.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2001, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVL_CALLMETHODS_HEADER #define RAVL_CALLMETHODS_HEADER 1 ////////////////////////////////////////////////////////// //! rcsid="$Id: CallMethods.hh,v 1.8 2002/07/25 17:34:06 craftit Exp $" //! docentry="Ravl.Core.Calls" //! lib=RavlCore //! author="Charles Galambos" //! file="Ravl/Core/Base/CallMethods.hh" //! date="24/01/2001" #include "Ravl/Calls.hh" namespace RavlN { ////////////////////////////////////////////////////// //! userlevel=Develop //: Signal Event handle template class CallMethod0BodyC : public CallFunc0BodyC { public: CallMethod0BodyC(const ObjT &nobj,RetT (ObjT::*nfunc)()) : CallFunc0BodyC((VoidFuncPtrT) 0), mPtr(nfunc), obj(nobj) {} //: Constructor. virtual void Invoke() { (obj.*FuncPtr())(); } //: Invoke event. protected: typedef RetT (ObjT::*FuncT)(); //: Function ptr type. virtual RCBodyVC &Copy() const { return *new CallMethod0BodyC(obj,FuncPtr()); } //: Copy call. FuncT mPtr; inline FuncT FuncPtr() const { return mPtr; } //: Function. ObjT obj; }; //! userlevel=Advanced //: Signal Event handle template class CallMethod0C : public CallFunc0C { public: CallMethod0C() {} //: Default constructor. // Creates an invalid handle. CallMethod0C(const ObjT &nobj,RetT (ObjT::*nfunc)()) : CallFunc0C(*new CallMethod0BodyC(nobj,nfunc)) {} //: Constructor. }; ///////////////////////////////////////////////////////// //! userlevel=Develop //: Signal Event handle template class CallMethod1BodyC : public CallFunc1BodyC { public: CallMethod1BodyC(const ObjT &nobj,RetT (ObjT::*nfunc)(DataT &),const DataT &ndat) : CallFunc1BodyC((VoidFuncPtrT) 0,ndat), mPtr(nfunc), obj(nobj) {} //: Constructor. virtual void Invoke() { (obj.*FuncPtr())(dat1); } //: Invoke event. virtual RetT Call() { return (obj.*FuncPtr())(dat1); } //: Invoke event, with paramiter. virtual RetT Call(DataT &pd) { return (obj.*FuncPtr())(pd); } //: Invoke event, with paramiter. protected: typedef RetT (ObjT::*FuncT)(DataT &); //: Function ptr type. virtual RCBodyVC &Copy() const { return *new CallMethod1BodyC(obj,FuncPtr(),dat1); } //: Copy call. FuncT mPtr; inline FuncT FuncPtr() const { return mPtr; } //: Function. ObjT obj; }; //! userlevel=Advanced //: Signal Event handle template class CallMethod1C : public CallFunc1C { public: CallMethod1C() {} //: Default constructor. // Creates an invalid handle. CallMethod1C(const ObjT &nobj,RetT (ObjT::*nfunc)(DataT &), const DataT &dat = DataT()) : CallFunc1C(*new CallMethod1BodyC(nobj,nfunc,dat)) {} //: Constructor. }; ///////////////////////////////////////////////////////// //! userlevel=Develop //: Signal Event handle template class CallMethod2BodyC : public CallFunc2BodyC { public: typedef RetT (ObjT::*FuncT)(Data1T &,Data2T &); //: Function ptr type. CallMethod2BodyC(const ObjT &nobj,FuncT nfunc,const Data1T &ndat1,const Data2T &ndat2) : CallFunc2BodyC((VoidFuncPtrT) 0,ndat1,ndat2), mPtr(nfunc), obj(nobj) {} //: Constructor. virtual void Invoke() { (obj.*FuncPtr())(dat1,dat2); } //: Invoke event. virtual RetT Call() { return (obj.*FuncPtr())(dat1,dat2); } //: Invoke event, with paramiter. virtual RetT Call(Data1T &pd) { return (obj.*FuncPtr())(pd,dat2); } //: Invoke event, with paramiter. virtual RetT Call(Data1T &pd1,Data2T &pd2) { return (obj.*FuncPtr())(pd1,pd2); } //: Invoke event, with paramiter. protected: inline FuncT FuncPtr() const { return mPtr; } //: Function. virtual RCBodyVC &Copy() const { return *new CallMethod2BodyC(obj,FuncPtr(),dat1,dat2); } //: Copy call. FuncT mPtr; ObjT obj; }; //! userlevel=Advanced //: Signal Event handle template class CallMethod2C : public CallFunc2C { public: CallMethod2C() {} //: Default constructor. // Creates an invalid handle. CallMethod2C(const ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &), const Data1T &ndat1 = Data1T(),const Data2T &ndat2 = Data2T()) : CallFunc2C(*new CallMethod2BodyC(nobj,nfunc,ndat1,ndat2)) {} //: Default constructor. // Creates an invalid handle. }; ///////////////////////////////////////////////////////// //! userlevel=Develop //: Signal Event handle template class CallMethod3BodyC : public CallFunc3BodyC { public: CallMethod3BodyC(const ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &), const Data1T &ndat1,const Data2T &ndat2,const Data3T &ndat3) : CallFunc3BodyC((VoidFuncPtrT) 0,ndat1,ndat2,ndat3), mPtr(nfunc), obj(nobj) {} //: Constructor. virtual void Invoke() { (obj.*FuncPtr())(dat1,dat2,dat3); } //: Invoke event. virtual RetT Call() { return (obj.*FuncPtr())(dat1,dat2,dat3); } //: Invoke event, with paramiter. virtual RetT Call(Data1T &pd) { return (obj.*FuncPtr())(pd,dat2,dat3); } //: Invoke event, with paramiter. virtual RetT Call(Data1T &pd1,Data2T &pd2) { return (obj.*FuncPtr())(pd1,pd2,dat3); } //: Invoke event, with paramiter. virtual RetT Call(Data1T &pd1,Data2T &pd2,Data3T &pd3) { return (obj.*FuncPtr())(pd1,pd2,pd3); } //: Invoke event, with paramiter. protected: typedef RetT (ObjT::*FuncT)(Data1T &,Data2T &,Data3T &); //: Function ptr type. virtual RCBodyVC &Copy() const { return *new CallMethod3BodyC(obj,FuncPtr(),dat1,dat2,dat3); } //: Copy call. FuncT mPtr; inline FuncT FuncPtr() const { return mPtr; } //: Function. ObjT obj; }; //! userlevel=Advanced //: Signal Event handle template class CallMethod3C : public CallFunc3C { public: CallMethod3C() {} //: Default constructor. // Creates an invalid handle. CallMethod3C(const ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &), const Data1T &ndat1 = Data1T(),const Data2T &ndat2 = Data2T(),const Data3T &ndat3 = Data3T()) : CallFunc3C(*new CallMethod3BodyC(nobj,nfunc,ndat1,ndat2,ndat3)) {} //: Constructor. }; ///////////////////////////////////////////////////////// //! userlevel=Develop //: Signal Event handle template class CallMethod4BodyC : public CallFunc4BodyC { public: CallMethod4BodyC(const ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &),const Data1T &ndat1,const Data2T &ndat2,const Data3T &ndat3,const Data4T &ndat4) : CallFunc4BodyC((VoidFuncPtrT) 0,ndat1,ndat2,ndat3,ndat4), mPtr(nfunc), obj(nobj) {} //: Constructor. virtual void Invoke() { (obj.*FuncPtr())(dat1,dat2,dat3,dat4); } //: Invoke event. virtual RetT Call() { return (obj.*FuncPtr())(dat1,dat2,dat3,dat4); } //: Invoke event. virtual RetT Call(Data1T &pd) { return (obj.*FuncPtr())(pd,dat2,dat3,dat4); } //: Invoke event, with paramiters. virtual RetT Call(Data1T &pd1,Data2T &pd2) { return (obj.*FuncPtr())(pd1,pd2,dat3,dat4); } //: Invoke event, with paramiters. virtual RetT Call(Data1T &pd1,Data2T &pd2,Data3T &pd3) { return (obj.*FuncPtr())(pd1,pd2,pd3,dat4); } //: Invoke event, with paramiters. virtual RetT Call(Data1T &pd1,Data2T &pd2,Data3T &pd3,Data4T &pd4) { return (obj.*FuncPtr())(pd1,pd2,pd3,pd4); } //: Invoke event, with paramiters. protected: typedef RetT (ObjT::*FuncT)(Data1T &,Data2T &,Data3T &,Data4T &); //: Function ptr type. virtual RCBodyVC &Copy() const { return *new CallMethod4BodyC(obj,FuncPtr(),dat1,dat2,dat3,dat4); } //: Copy call. FuncT mPtr; inline FuncT FuncPtr() const { return mPtr; } //: Function. ObjT obj; }; //! userlevel=Advanced //: Signal Event handle template class CallMethod4C : public CallFunc4C { public: CallMethod4C() {} //: Default constructor. // Creates an invalid handle. CallMethod4C(const ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &), const Data1T &ndat1 = Data1T(),const Data2T &ndat2 = Data2T(),const Data3T &ndat3 = Data3T(),const Data4T &ndat4 = Data4T()) : CallFunc4C(*new CallMethod4BodyC(nobj,nfunc,ndat1,ndat2,ndat3,ndat4)) {} //: Constructor. }; ///////////////////////////////////////////////////////// //! userlevel=Develop //: Signal Event handle template class CallMethod5BodyC : public CallFunc5BodyC { public: CallMethod5BodyC(const ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &,Data5T &), const Data1T &ndat1 = Data1T(), const Data2T &ndat2 = Data2T(), const Data3T &ndat3 = Data3T(), const Data4T &ndat4 = Data4T(), const Data5T &ndat5 = Data5T()) : CallFunc5BodyC((VoidFuncPtrT) 0,ndat1,ndat2,ndat3,ndat4,ndat5), mPtr(nfunc), obj(nobj) {} //: Constructor. virtual void Invoke() { (obj.*FuncPtr())(dat1,dat2,dat3,dat4,dat5); } //: Invoke event. virtual RetT Call() { return (obj.*FuncPtr())(dat1,dat2,dat3,dat4,dat5); } //: Invoke event. virtual RetT Call(Data1T &pd) { return (obj.*FuncPtr())(pd,dat2,dat3,dat4,dat5); } //: Invoke event, with paramiters. virtual RetT Call(Data1T &pd1,Data2T &pd2) { return (obj.*FuncPtr())(pd1,pd2,dat3,dat4,dat5); } //: Invoke event, with paramiters. virtual RetT Call(Data1T &pd1,Data2T &pd2,Data3T &pd3) { return (obj.*FuncPtr())(pd1,pd2,pd3,dat4,dat5); } //: Invoke event, with paramiters. virtual RetT Call(Data1T &pd1,Data2T &pd2,Data3T &pd3,Data4T &pd4) { return (obj.*FuncPtr())(pd1,pd2,pd3,pd4,dat5); } //: Invoke event, with paramiters. virtual RetT Call(Data1T &pd1,Data2T &pd2,Data3T &pd3,Data4T &pd4,Data5T &pd5) { return (obj.*FuncPtr())(pd1,pd2,pd3,pd4,pd5); } //: Invoke event, with paramiters. protected: typedef RetT (ObjT::*FuncT)(Data1T &,Data2T &,Data3T &,Data4T &,Data5T &); //: Function ptr type. FuncT mPtr; virtual RCBodyVC &Copy() const { return *new CallMethod5BodyC(obj,FuncPtr(),dat1,dat2,dat3,dat4,dat5); } //: Copy call. inline FuncT FuncPtr() const { return mPtr; } //: Function. ObjT obj; }; //! userlevel=Advanced //: Signal Event handle template class CallMethod5C : public CallFunc5C { public: CallMethod5C() {} //: Default constructor. // Creates an invalid handle. CallMethod5C(const ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &,Data5T &),const Data1T &ndat1,const Data2T &ndat2,const Data3T &ndat3,const Data4T &ndat4,const Data5T &ndat5) : CallFunc5C(*new CallMethod5BodyC(nobj,nfunc,ndat1,ndat2,ndat3,ndat4,ndat5)) {} //: Constructor. }; //! userlevel=Normal #if !defined(VISUAL_CPP) template inline CallMethod0C Trigger(const ObjT &nobj,RetT (ObjT::*nfunc)()) { return CallMethod0C(nobj,nfunc); } template inline CallMethod1C Trigger(const ObjT &nobj,RetT (ObjT::*nfunc)(DataT &),const DataT &dat) { return CallMethod1C(nobj,nfunc,dat); } template inline CallMethod2C Trigger(const ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &),const Data1T &dat1,const Data2T &dat2) { return CallMethod2C(nobj,nfunc,dat1,dat2); } template inline CallMethod3C Trigger(const ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &),const Data1T &dat1,const Data2T &dat2,const Data3T &dat3) { return CallMethod3C(nobj,nfunc,dat1,dat2,dat3); } template inline CallMethod4C Trigger(const ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &),const Data1T &dat1,const Data2T &dat2,const Data3T &dat3,const Data4T &dat4) { return CallMethod4C(nobj,nfunc,dat1,dat2,dat3,dat4); } template inline CallMethod5C Trigger(const ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &,Data5T &),const Data1T &dat1,const Data2T &dat2,const Data3T &dat3,const Data4T &dat4,const Data5T &dat5) { return CallMethod5C(nobj,nfunc,dat1,dat2,dat3,dat4,dat5); } #else template inline CallMethod0C Trigger(const ObjT &nobj,bool (ObjT::*nfunc)()) { return CallMethod0C(nobj,nfunc); } template inline CallMethod1C Trigger(const ObjT &nobj,bool (ObjT::*nfunc)(DataT &),const DataT &dat) { return CallMethod1C(nobj,nfunc,dat); } template inline CallMethod2C Trigger(const ObjT &nobj,bool (ObjT::*nfunc)(Data1T &,Data2T &),const Data1T &dat1,const Data2T &dat2) { return CallMethod2C(nobj,nfunc,dat1,dat2); } template inline CallMethod3C Trigger(const ObjT &nobj,bool (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &),const Data1T &dat1,const Data2T &dat2,const Data3T &dat3) { return CallMethod3C(nobj,nfunc,dat1,dat2,dat3); } template inline CallMethod4C Trigger(const ObjT &nobj,bool (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &),const Data1T &dat1,const Data2T &dat2,const Data3T &dat3,const Data4T &dat4) { return CallMethod4C(nobj,nfunc,dat1,dat2,dat3,dat4); } template inline CallMethod5C Trigger(const ObjT &nobj,bool (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &,Data5T &),const Data1T &dat1,const Data2T &dat2,const Data3T &dat3,const Data4T &dat4,const Data5T &dat5) { return CallMethod5C(nobj,nfunc,dat1,dat2,dat3,dat4,dat5); } #endif } #endif