rt300@0: // rt300@0: // uifunctor.h rt300@0: // Wablet rt300@0: // rt300@0: // Created by Robert Tubb on 22/03/2012. rt300@0: // Copyright (c) 2012 __MyCompanyName__. All rights reserved. rt300@0: // rt300@0: rt300@0: #ifndef Wablet_uifunctor_h rt300@0: #define Wablet_uifunctor_h rt300@0: rt300@0: //------------------- callback functor rt300@0: rt300@0: // abstract base class rt300@0: class UIFunctor rt300@0: { rt300@0: public: rt300@0: rt300@0: // two possible functions to call member function. virtual cause derived rt300@0: // classes will use a pointer to an object and a pointer to a member function rt300@0: // to make the function call rt300@0: virtual void operator()(int buttID)=0; // call using operator rt300@0: virtual void Call(int buttID)=0; // call using function rt300@0: }; rt300@0: rt300@0: rt300@0: // derived template class - this one is for memeber of testApp class rt300@0: template class UISpecificFunctor : public UIFunctor rt300@0: { rt300@0: private: rt300@0: void (testApp::*fpt)(int); // pointer to member function rt300@0: testApp* pt2Object; // pointer to object rt300@0: rt300@0: public: rt300@0: rt300@0: // constructor - takes pointer to an object and pointer to a member and stores rt300@0: // them in two private variables rt300@0: rt300@0: UISpecificFunctor( testApp* _pt2Object, void(testApp::*_fpt)(int)) rt300@0: { rt300@0: pt2Object = _pt2Object; rt300@0: fpt=_fpt; rt300@0: }; rt300@0: rt300@0: // override operator "()" rt300@0: rt300@0: virtual void operator()(int buttID) rt300@0: { (*pt2Object.*fpt)(buttID);}; // execute member function rt300@0: rt300@0: // override function "Call" rt300@0: virtual void Call(int buttID) rt300@0: { (*pt2Object.*fpt)(buttID);}; // execute member function rt300@0: }; rt300@0: rt300@0: rt300@0: #endif