1 | // |
---|
2 | // You received this file as part of RRLib |
---|
3 | // Robotics Research Library |
---|
4 | // |
---|
5 | // Copyright (C) Finroc GbR (finroc.org) |
---|
6 | // |
---|
7 | // This program is free software; you can redistribute it and/or |
---|
8 | // modify it under the terms of the GNU General Public License |
---|
9 | // as published by the Free Software Foundation; either version 2 |
---|
10 | // of the License, or (at your option) any later version. |
---|
11 | // |
---|
12 | // This program is distributed in the hope that it will be useful, |
---|
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | // GNU General Public License for more details. |
---|
16 | // |
---|
17 | // You should have received a copy of the GNU General Public License |
---|
18 | // along with this program; if not, write to the Free Software |
---|
19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
20 | // |
---|
21 | //---------------------------------------------------------------------- |
---|
22 | /*!\file tFirstParameterBinder.h |
---|
23 | * |
---|
24 | * \author Tobias Foehst |
---|
25 | * |
---|
26 | * \date 2010-10-24 |
---|
27 | * |
---|
28 | * \brief Contains tFirstParameterBinder |
---|
29 | * |
---|
30 | * \b tFirstParameterBinder |
---|
31 | * |
---|
32 | */ |
---|
33 | //---------------------------------------------------------------------- |
---|
34 | #ifndef __rrlib__util__patterns__command__tFirstParameterBinder_h__ |
---|
35 | #define __rrlib__util__patterns__command__tFirstParameterBinder_h__ |
---|
36 | |
---|
37 | #include "rrlib/util/patterns/command/tFunctorHandlerBase.h" |
---|
38 | //---------------------------------------------------------------------- |
---|
39 | // External includes (system with <>, local with "") |
---|
40 | //---------------------------------------------------------------------- |
---|
41 | |
---|
42 | //---------------------------------------------------------------------- |
---|
43 | // Internal includes with "" |
---|
44 | //---------------------------------------------------------------------- |
---|
45 | |
---|
46 | //---------------------------------------------------------------------- |
---|
47 | // Debugging |
---|
48 | //---------------------------------------------------------------------- |
---|
49 | |
---|
50 | //---------------------------------------------------------------------- |
---|
51 | // Namespace declaration |
---|
52 | //---------------------------------------------------------------------- |
---|
53 | namespace rrlib |
---|
54 | { |
---|
55 | namespace util |
---|
56 | { |
---|
57 | |
---|
58 | //---------------------------------------------------------------------- |
---|
59 | // Forward declarations / typedefs / enums |
---|
60 | //---------------------------------------------------------------------- |
---|
61 | |
---|
62 | //---------------------------------------------------------------------- |
---|
63 | // Class declaration |
---|
64 | //---------------------------------------------------------------------- |
---|
65 | //! |
---|
66 | /*! |
---|
67 | * |
---|
68 | */ |
---|
69 | template <typename TReturn, typename TFirstParameter, typename ... TParameterRest> |
---|
70 | class tFirstParameterBinder : public tFunctorHandlerBase<TReturn, TParameterRest...> |
---|
71 | { |
---|
72 | |
---|
73 | //---------------------------------------------------------------------- |
---|
74 | // Public methods and typedefs |
---|
75 | //---------------------------------------------------------------------- |
---|
76 | public: |
---|
77 | |
---|
78 | tFirstParameterBinder(const tFunctor<TReturn, TFirstParameter, TParameterRest...> &functor, TFirstParameter bound_parameter) |
---|
79 | : functor(functor), |
---|
80 | bound_parameter(bound_parameter) |
---|
81 | {} |
---|
82 | |
---|
83 | TReturn operator()(TParameterRest... parameters) |
---|
84 | { |
---|
85 | return this->functor(bound_parameter, parameters...); |
---|
86 | } |
---|
87 | |
---|
88 | //---------------------------------------------------------------------- |
---|
89 | // Private fields and methods |
---|
90 | //---------------------------------------------------------------------- |
---|
91 | private: |
---|
92 | |
---|
93 | tFunctor<TReturn, TFirstParameter, TParameterRest...> functor; |
---|
94 | TFirstParameter bound_parameter; |
---|
95 | }; |
---|
96 | |
---|
97 | //---------------------------------------------------------------------- |
---|
98 | // End of namespace declaration |
---|
99 | //---------------------------------------------------------------------- |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | #endif |
---|