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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // �Function type template
20 /****************************************************************************/
21 #ifndef FuncBinding_IntParam_h
22 #define FuncBinding_IntParam_h
23 
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
36 
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
44 template< class T, typename R >
45 class FuncBinding_IntParam : public ValueSource<R> {
46 public:
48  typedef R(T::* Operation)(int) const;
49 
50  FuncBinding_IntParam(T* source, Operation operation,
51  int param)
52  :
53  mySource(source),
54  myOperation(operation),
55  myParam(param) {}
56 
59 
60  double getValue() const {
61  return (mySource->*myOperation)(myParam);
62  }
63 
64  ValueSource<R>* copy() const {
65  return new FuncBinding_IntParam<T, R>(
67  }
68 
71  }
72 
73 protected:
74 
75 private:
78 
81 
82  int myParam;
83 
84 };
85 
86 
87 #endif
88 
89 /****************************************************************************/
90 
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.