SUMO - Simulation of Urban MObility
FunctionBinding.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-2018 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 /****************************************************************************/
18 // Function type template
19 /****************************************************************************/
20 #ifndef FunctionBinding_h
21 #define FunctionBinding_h
22 
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #include <config.h>
29 
31 #include "CastingFunctionBinding.h"
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
40 template< class T, typename R >
41 class FunctionBinding : public ValueSource<R> {
42 public:
44  typedef R(T::* Operation)() const;
45 
46  FunctionBinding(T* const source, Operation operation, const R scale = 1) :
47  mySource(source),
48  myOperation(operation),
49  myScale(scale) {}
50 
53 
54  R getValue() const {
55  return myScale * (mySource->*myOperation)();
56  }
57 
58  ValueSource<R>* copy() const {
60  }
61 
64  }
65 
66 private:
69 
72 
74  const R myScale;
75 
76 private:
79 
80 };
81 
82 
83 #endif
84 
85 /****************************************************************************/
86 
ValueSource< R > * copy() const
FunctionBinding(T *const source, Operation operation, const R scale=1)
T * mySource
The object the action is directed to.
R(T::* Operation)() const
Type of the function to execute.
const R myScale
The scale to apply.
FunctionBinding< T, R > & operator=(const FunctionBinding< T, R > &)
invalidated assignment operator
ValueSource< double > * makedoubleReturningCopy() const
Operation myOperation
The object&#39;s operation to perform.
~FunctionBinding()
Destructor.
R getValue() const