]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/functor.h
Diego Caceres: creaButtonContainer and creaPanelButtonContainer has been added to...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / creaButtonContainer / model / include / functor.h
1 /***************************************************************
2  * Name:      TFunctor
3  * Purpose:   Call_Back Functions
4  * Author:    Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
5  * Modified:  2011-05-09
6  * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/)
7  * License:
8  **************************************************************/
9
10 #ifndef TFUNCTOR_H_
11 #define TFUNCTOR_H_
12
13 #include <string>
14
15 namespace creaButtonContainer
16 {
17         namespace model
18         {
19                 typedef std::string ButtonIDType;
20                 // abstract base class
21                 class TFunctor
22                 {
23                         public:
24                                 // two possible functions to call member function. virtual cause derived
25                                 // classes will use a pointer to an object and a pointer to a member function
26                                 // to make the function call
27                                 virtual void
28                                 operator()( const ButtonIDType &buttonName )=0; // call using operator
29                                 virtual void
30                                 Call( const ButtonIDType &buttonName )=0;
31                                 // call using function
32                 };
33
34                 // derived template class
35                 template< typename TClass >
36                         class TConcreteFunctor : public TFunctor
37                         {
38                                 public:
39                                         // constructor - takes pointer to an object and pointer to a member and stores
40                                         // them in two private variables
41                                         TConcreteFunctor( TClass* _pt2Object, void
42                                         (TClass::*_fpt)( const ButtonIDType &buttonName ) );
43                                         // override operator "()" // execute member function
44                                         virtual void
45                                         operator()( const ButtonIDType &buttonName );
46                                         // override function "Call" // execute member function
47                                         virtual void
48                                         Call( const ButtonIDType &buttonName );
49                                 private:
50                                         void
51                                         (TClass::*fpt)( const ButtonIDType &buttonName );
52                                         // pointer to member function
53                                         TClass* pt2Object;
54                                         // pointer to object
55                         };
56
57         }//ecapseman
58 }//ecapseman
59
60 #include "functor.txx"
61
62 #endif /* TFUNCTOR_H_ */