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 /****************************************************************************/
16 // �Function type template
17 /****************************************************************************/
18 #ifndef FuncBinding_IntParam_h
19 #define FuncBinding_IntParam_h
20 
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
29 
30 
31 // ===========================================================================
32 // class definitions
33 // ===========================================================================
37 template< class T, typename R >
38 class FuncBinding_IntParam : public ValueSource<R> {
39 public:
41  typedef R(T::* Operation)(int) const;
42 
43  FuncBinding_IntParam(T* source, Operation operation,
44  int param)
45  :
46  mySource(source),
47  myOperation(operation),
48  myParam(param) {}
49 
52 
53  double getValue() const {
54  return (mySource->*myOperation)(myParam);
55  }
56 
57  ValueSource<R>* copy() const {
58  return new FuncBinding_IntParam<T, R>(
60  }
61 
64  }
65 
66 protected:
67 
68 private:
71 
74 
75  int myParam;
76 
77 };
78 
79 
80 #endif
81 
82 /****************************************************************************/
83 
FuncBinding_IntParam::myParam
int myParam
Definition: FuncBinding_IntParam.h:75
FuncBinding_IntParam
Definition: FuncBinding_IntParam.h:38
FuncBinding_IntParam::copy
ValueSource< R > * copy() const
Definition: FuncBinding_IntParam.h:57
FuncBinding_IntParam::FuncBinding_IntParam
FuncBinding_IntParam(T *source, Operation operation, int param)
Definition: FuncBinding_IntParam.h:43
FuncBinding_IntParam::myOperation
Operation myOperation
The object's operation to perform.
Definition: FuncBinding_IntParam.h:73
FuncBinding_IntParam::Operation
R(T::* Operation)(int) const
Type of the function to execute.
Definition: FuncBinding_IntParam.h:41
FuncBinding_IntParam::~FuncBinding_IntParam
~FuncBinding_IntParam()
Destructor.
Definition: FuncBinding_IntParam.h:51
FuncBinding_IntParam::getValue
double getValue() const
Definition: FuncBinding_IntParam.h:53
FuncBinding_IntParam::makedoubleReturningCopy
ValueSource< double > * makedoubleReturningCopy() const
Definition: FuncBinding_IntParam.h:62
ValueSource.h
config.h
ValueSource
Definition: ValueSource.h:32
FuncBinding_IntParam::mySource
T * mySource
The object the action is directed to.
Definition: FuncBinding_IntParam.h:70