Eclipse SUMO - Simulation of Urban MObility
FuncBinding_IntParam.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // �Function type template
18 /****************************************************************************/
19 #ifndef FuncBinding_IntParam_h
20 #define FuncBinding_IntParam_h
21 
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
38 template< class T, typename R >
39 class FuncBinding_IntParam : public ValueSource<R> {
40 public:
42  typedef R(T::* Operation)(int) const;
43 
44  FuncBinding_IntParam(T* source, Operation operation,
45  int param)
46  :
47  mySource(source),
48  myOperation(operation),
49  myParam(param) {}
50 
53 
54  double getValue() const {
55  return (mySource->*myOperation)(myParam);
56  }
57 
58  ValueSource<R>* copy() const {
59  return new FuncBinding_IntParam<T, R>(
61  }
62 
65  }
66 
67 protected:
68 
69 private:
72 
75 
76  int myParam;
77 
78 };
79 
80 
81 #endif
82 
83 /****************************************************************************/
84 
ValueSource< double > * makedoubleReturningCopy() const
~FuncBinding_IntParam()
Destructor.
Operation myOperation
The object&#39;s operation to perform.
T * mySource
The object the action is directed to.
ValueSource< R > * copy() const
FuncBinding_IntParam(T *source, Operation operation, int param)
R(T::* Operation)(int) const
Type of the function to execute.