MURE
Loading...
Searching...
No Matches
TFunctor.hxx
Go to the documentation of this file.
1/*
2 This file is part of MURE,
3 Copyright (C) 2007-2021 MURE developers.
4
5 MURE is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 MURE is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with MURE. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef _TFUNCTOR_
20#define _TFUNCTOR_
21using namespace std;
22
29
37{
38 public:
39 virtual void operator()() = 0;
40 virtual void Call() = 0;
41 virtual ~TFunctor() = default;
42};
43
45
52template < class T > class TSpecificFunctor : public TFunctor
53{
54 public:
55 TSpecificFunctor(T *_pt2Object, void(T::*_fpt)())
56 {
57 pt2Object = _pt2Object;
58 fpt = _fpt;
59 }
61 {
62 pt2Object = nullptr;
63 fpt = nullptr;
64 }
65 void operator()() override
66 {
67 (*pt2Object.*fpt)();
68 }
69 void Call() override
70 {
71 (*pt2Object.*fpt)();
72 }
73 virtual void SetObj(T *obj)
74 {
75 pt2Object = obj;
76 }
77
78 private:
79 void (T::*fpt)();
81};
82#endif
Abstract class to define Functor (function of function).
Definition TFunctor.hxx:37
virtual void Call()=0
call using function
virtual ~TFunctor()=default
Virtual destructor to avoid GCC 4.0 warnings.
virtual void operator()()=0
call using operator
Template class to assign a method of class T as argument.
Definition TFunctor.hxx:53
~TSpecificFunctor() override
Definition TFunctor.hxx:60
T * pt2Object
pointer to object
Definition TFunctor.hxx:80
void(T::* fpt)()
pointer to member function
Definition TFunctor.hxx:79
virtual void SetObj(T *obj)
Definition TFunctor.hxx:73
void operator()() override
call using operator
Definition TFunctor.hxx:65
TSpecificFunctor(T *_pt2Object, void(T::*_fpt)())
Definition TFunctor.hxx:55
void Call() override
call using function
Definition TFunctor.hxx:69
the namespace of the Standard C++

MURE Project, documentation generated by Doxygen 1.9.7 - Fri Jan 19 2024