#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Core/Base/CallMethodRefs.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_CALLMETHODREFS_HEADER #define RAVL_CALLMETHODREFS_HEADER 1 ////////////////////////////////////////////////////////// //! rcsid="$Id: CallMethodRefs.hh,v 1.7 2002/03/07 13:49:30 craftit Exp $" //! docentry="Ravl.Core.Calls" //! lib=RavlCore //! file="Ravl/Core/Base/CallMethodRefs.hh" //! author="Charles Galambos" //! date="24/01/2001" #include "Ravl/Calls.hh" namespace RavlN { ////////////////////////////////////////////////////// //! userlevel=Develop //: Signal Event handle template class CallMethodRef0BodyC : public CallFunc0BodyC { public: CallMethodRef0BodyC(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 CallMethodRef0BodyC(const_cast(obj),FuncPtr()); } //: Copy call. FuncT mPtr; inline FuncT FuncPtr() const { return mPtr; } //: Function. ObjT &obj; }; //! userlevel=Advanced //: Signal Event handle template class CallMethodRef0C : public CallFunc0C { public: CallMethodRef0C() {} //: Default constructor. // Creates an invalid handle. CallMethodRef0C(ObjT &nobj,RetT (ObjT::*nfunc)()) : CallFunc0C(*new CallMethodRef0BodyC(nobj,nfunc)) {} //: Default constructor. // Creates an invalid handle. }; ///////////////////////////////////////////////////////// //! userlevel=Develop //: Signal Event handle template class CallMethodRef1BodyC : public CallFunc1BodyC { public: CallMethodRef1BodyC(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 CallMethodRef1BodyC(obj,FuncPtr(),dat1); } //: Copy call. FuncT mPtr; inline FuncT FuncPtr() const { return mPtr; } //: Function. ObjT &obj; }; //! userlevel=Advanced //: Signal Event handle template class CallMethodRef1C : public CallFunc1C { public: CallMethodRef1C() {} //: Default constructor. // Creates an invalid handle. CallMethodRef1C(ObjT &nobj,RetT (ObjT::*nfunc)(DataT &), const DataT &dat = DataT()) : CallFunc1C(*new CallMethodRef1BodyC(nobj,nfunc,dat)) {} //: Default constructor. // Creates an invalid handle. }; ///////////////////////////////////////////////////////// //! userlevel=Develop //: Signal Event handle template class CallMethodRef2BodyC : public CallFunc2BodyC { public: typedef RetT (ObjT::*FuncT)(Data1T &,Data2T &); //: Function ptr type. CallMethodRef2BodyC(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 CallMethodRef2BodyC(obj,FuncPtr(),dat1,dat2); } //: Copy call. FuncT mPtr; ObjT &obj; }; //! userlevel=Advanced //: Signal Event handle template class CallMethodRef2C : public CallFunc2C { public: CallMethodRef2C() {} //: Default constructor. // Creates an invalid handle. CallMethodRef2C(ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &),const Data1T &ndat1 = Data1T(),const Data2T &ndat2 = Data2T()) : CallFunc2C(*new CallMethodRef2BodyC(nobj,nfunc,ndat1,ndat2)) {} //: Default constructor. // Creates an invalid handle. }; ///////////////////////////////////////////////////////// //! userlevel=Develop //: Signal Event handle template class CallMethodRef3BodyC : public CallFunc3BodyC { public: CallMethodRef3BodyC(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 CallMethodRef3BodyC(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 CallMethodRef3C : public CallFunc3C { public: CallMethodRef3C() {} //: Default constructor. // Creates an invalid handle. CallMethodRef3C(ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &),const Data1T &ndat1 = Data1T(),const Data2T &ndat2 = Data2T(),const Data3T &ndat3 = Data3T()) : CallFunc3C(*new CallMethodRef3BodyC(nobj,nfunc,ndat1,ndat2,ndat3)) {} //: Default constructor. // Creates an invalid handle. }; ///////////////////////////////////////////////////////// //! userlevel=Develop //: Signal Event handle template class CallMethodRef4BodyC : public CallFunc4BodyC { public: CallMethodRef4BodyC(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 CallMethodRef4BodyC(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 CallMethodRef4C : public CallFunc4C { public: CallMethodRef4C() {} //: Default constructor. // Creates an invalid handle. CallMethodRef4C(ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &),const Data1T &ndat1,const Data2T &ndat2,const Data3T &ndat3,const Data4T &ndat4) : CallFunc4C(*new CallMethodRef4BodyC(nobj,nfunc,ndat1,ndat2,ndat3,ndat4)) {} //: Default constructor. // Creates an invalid handle. }; ///////////////////////////////////////////////////////// //! userlevel=Develop //: Signal Event handle template class CallMethodRef5BodyC : public CallFunc5BodyC { public: CallMethodRef5BodyC(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) : CallFunc5BodyC((VoidFuncPtrT) 0,dat1,dat2,dat3,dat4,dat5), 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. virtual RCBodyVC &Copy() const { return *new CallMethodRef5BodyC(obj,FuncPtr(),dat1,dat2,dat3,dat4,dat5); } //: Copy call. FuncT mPtr; inline FuncT FuncPtr() const { return mPtr; } //: Function. ObjT &obj; }; //! userlevel=Advanced //: Signal Event handle template class CallMethodRef5C : public CallFunc5C { public: CallMethodRef5C() {} //: Default constructor. // Creates an invalid handle. CallMethodRef5C(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 CallMethodRef5BodyC(nobj,nfunc,ndat1,ndat2,ndat3,ndat4,ndat5)) {} //: Default constructor. // Creates an invalid handle. }; //! userlevel=Normal #if !defined(VISUAL_CPP) template inline CallMethodRef0C TriggerR(ObjT &nobj,RetT (ObjT::*nfunc)()) { return CallMethodRef0C(nobj,nfunc); } template inline CallMethodRef1C TriggerR(ObjT &nobj,RetT (ObjT::*nfunc)(DataT &),const DataT &dat) { return CallMethodRef1C(nobj,nfunc,dat); } template inline CallMethodRef2C TriggerR(ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &),const Data1T &dat1,const Data2T &dat2) { return CallMethodRef2C(nobj,nfunc,dat1,dat2); } template inline CallMethodRef3C TriggerR(ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &),const Data1T &dat1,const Data2T &dat2,const Data3T &dat3) { return CallMethodRef3C(nobj,nfunc,dat1,dat2,dat3); } template inline CallMethodRef4C TriggerR(ObjT &nobj,RetT (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &),const Data1T &dat1,const Data2T &dat2,const Data3T &dat3,const Data4T &dat4) { return CallMethodRef4C(nobj,nfunc,dat1,dat2,dat3,dat4); } template inline CallMethodRef5C TriggerR(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 CallMethodRef5C(nobj,nfunc,dat1,dat2,dat3,dat4,dat5); } #else template inline CallMethodRef0C TriggerR(ObjT &nobj,bool (ObjT::*nfunc)()) { return CallMethodRef0C(nobj,nfunc); } template inline CallMethodRef1C TriggerR(ObjT &nobj,bool (ObjT::*nfunc)(DataT &),const DataT &dat) { return CallMethodRef1C(nobj,nfunc,dat); } template inline CallMethodRef2C TriggerR(ObjT &nobj,bool (ObjT::*nfunc)(Data1T &,Data2T &),const Data1T &dat1,const Data2T &dat2) { return CallMethodRef2C(nobj,nfunc,dat1,dat2); } template inline CallMethodRef3C TriggerR(ObjT &nobj,bool (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &),const Data1T &dat1,const Data2T &dat2,const Data3T &dat3) { return CallMethodRef3C(nobj,nfunc,dat1,dat2,dat3); } template inline CallMethodRef4C TriggerR(ObjT &nobj,bool (ObjT::*nfunc)(Data1T &,Data2T &,Data3T &,Data4T &),const Data1T &dat1,const Data2T &dat2,const Data3T &dat3,const Data4T &dat4) { return CallMethodRef4C(nobj,nfunc,dat1,dat2,dat3,dat4); } template inline CallMethodRef5C TriggerR(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 CallMethodRef5C(nobj,nfunc,dat1,dat2,dat3,dat4,dat5); } #endif } #endif