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