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-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 /****************************************************************************/
20 // Function type template
21 /****************************************************************************/
22 #ifndef FunctionBinding_h
23 #define FunctionBinding_h
24 
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
37 #include "CastingFunctionBinding.h"
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
46 template< class T, typename R >
47 class FunctionBinding : public ValueSource<R> {
48 public:
50  typedef R(T::* Operation)() const;
51 
52  FunctionBinding(T* const source, Operation operation, const R scale = 1) :
53  mySource(source),
54  myOperation(operation),
55  myScale(scale) {}
56 
59 
60  R getValue() const {
61  return myScale * (mySource->*myOperation)();
62  }
63 
64  ValueSource<R>* copy() const {
66  }
67 
70  }
71 
72 private:
75 
78 
80  const R myScale;
81 
82 private:
85 
86 };
87 
88 
89 #endif
90 
91 /****************************************************************************/
92 
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