]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/functor.h
creaButtonContainer: Documentation updates :) :). If you turns on the documentation...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / creaButtonContainer / model / functor.h
1 /*!
2  * @file functor.h
3  * @brief defines TFunctor class
4  * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
5  * @date  2011-05-19
6  */
7
8 #ifndef TFUNCTOR_H_
9 #define TFUNCTOR_H_
10
11 #include <string>
12
13 /*!     @namespace <creaButtonContainer>
14  *      @brief Contains the creaButtonContainer library included in creaMaracasVisu.
15  */
16 namespace creaButtonContainer
17 {
18         /*! @namespace <creaButtonContainer::model>
19          *      @brief Contains the implementation of the model in creaButtonContainer library.
20          *      @see <a href="http://en.wikipedia.org/wiki/Model-view-controller">MVC Software Architecture</a>
21          */
22         namespace model
23         {
24                 //typedef definition.
25                 /*!     @typedef std::string ButtonIDType;
26                  *      @brief Defines the ButtonIDType type.
27                  */
28                 typedef std::string ButtonIDType;
29                 //end of typedef definition
30                 /*! @class TFunctor functor.h "functor.h"
31                  *      @brief This is an abstract class for call_back functions.
32                  */
33                 class TFunctor
34                 {
35                         public:
36                                 // two possible functions to call member function. virtual cause derived
37                                 // classes will use a pointer to an object and a pointer to a member function
38                                 /*! @fn virtual void TFunctor::operator()( const ButtonIDType &buttonName )
39                                  *      @brief  To make the function call.
40                                  *      Call_Back function.
41                                  *      @param buttonName
42                                  */
43                                 virtual void
44                                 operator()( const ButtonIDType &buttonName )=0; // call using operator
45                                 /*! @fn
46                                  *  @brief Call using function.
47                                  *  Call_Back function.
48                                  *      @param buttonName
49                                  */
50                                 virtual void
51                                 Call( const ButtonIDType &buttonName )=0;
52                 };
53
54                 // derived template class
55                 /*! @tparam <typename TClass>
56                  *      @brief TClass makes TConcreteFunctor usable for all Classes.
57                  */
58                 template< typename TClass >
59                         /*! @class TConcreteFunctor: public TFunctor  functor.h "functor.h"
60                          *      @brief This class allows to make call_back functions.
61                          */
62                         class TConcreteFunctor : public TFunctor
63                         {
64                                 public:
65                                         /*! @fn TConcreteFunctor::TConcreteFunctor( TClass* _pt2Object, void
66                                          (TClass::*_fpt)( const ButtonIDType &buttonName ) );
67                                          *      @brief This is the parameterized constructor.
68                                          *      Takes pointer to an object and pointer to a member and stores them in two private variables
69                                          *      @param _pt2Object Pointer to object.
70                                          *      @param _fpt Pointer to the function.
71                                          *      @param buttonName The ID of the button (ButtonName).
72                                          */
73                                         TConcreteFunctor( TClass* _pt2Object, void
74                                         (TClass::*_fpt)( const ButtonIDType &buttonName ) );
75                                         // -------------------------------------------------------------------------------
76                                         /*! @fn virtual void TConcreteFunctor::operator()( const ButtonIDType &buttonName );
77                                          *      @brief Override operator "()". Execute member function.
78                                          *      @see TFunctor
79                                          *      @param buttonName
80                                          */
81                                         virtual void
82                                         operator()( const ButtonIDType &buttonName );
83                                         // -------------------------------------------------------------------------------
84                                         /*! @fn virtual void TConcreteFunctor::Call( const ButtonIDType &buttonName );
85                                          *      @brief Override function "Call". Execute member function
86                                          *      @see TFunctor
87                                          *      @param buttonName
88                                          */
89                                         virtual void
90                                         Call( const ButtonIDType &buttonName );
91                                         // -------------------------------------------------------------------------------
92                                 private:
93                                         void
94                                         (TClass::*fpt)( const ButtonIDType &buttonName ); //! <void (TClass::*fpt) Pointer to member function.
95                                         TClass* pt2Object; //! <TClass* pointer to object.
96                         };
97
98         }//ecapseman
99 }//ecapseman
100
101 //! @include "functor.txx"
102 #include "functor.txx"
103
104 #endif /* TFUNCTOR_H_ */