/*************************************************************** * Name: TFunctor * Purpose: Call_Back Functions * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) * Modified: 2011-05-09 * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) * License: **************************************************************/ #ifndef TFUNCTOR_H_ #define TFUNCTOR_H_ #include namespace creaButtonContainer { namespace model { typedef std::string ButtonIDType; // abstract base class class TFunctor { public: // two possible functions to call member function. virtual cause derived // classes will use a pointer to an object and a pointer to a member function // to make the function call virtual void operator()( const ButtonIDType &buttonName )=0; // call using operator virtual void Call( const ButtonIDType &buttonName )=0; // call using function }; // derived template class template< typename TClass > class TConcreteFunctor : public TFunctor { public: // constructor - takes pointer to an object and pointer to a member and stores // them in two private variables TConcreteFunctor( TClass* _pt2Object, void (TClass::*_fpt)( const ButtonIDType &buttonName ) ); // override operator "()" // execute member function virtual void operator()( const ButtonIDType &buttonName ); // override function "Call" // execute member function virtual void Call( const ButtonIDType &buttonName ); private: void (TClass::*fpt)( const ButtonIDType &buttonName ); // pointer to member function TClass* pt2Object; // pointer to object }; }//ecapseman }//ecapseman #include "functor.txx" #endif /* TFUNCTOR_H_ */