SUMO - Simulation of Urban MObility
CastingFunctionBinding.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 CastingFunctionBinding_h
22 #define CastingFunctionBinding_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
43 template< class T, typename R, typename O >
45 public:
47  typedef O(T::* Operation)() const;
48 
49  CastingFunctionBinding(T* source, Operation operation, const R scale = 1) :
50  mySource(source),
51  myOperation(operation),
52  myScale(scale) {}
53 
56 
57  R getValue() const {
58  return myScale * (R)(mySource->*myOperation)();
59  }
60 
61  ValueSource<R>* copy() const {
63  }
64 
67  }
68 
69 private:
72 
75 
77  const R myScale;
78 
79 private:
82 
83 };
84 
85 
86 #endif
87 
88 /****************************************************************************/
89 
O(T::* Operation)() const
Type of the function to execute.
T * mySource
The object the action is directed to.
ValueSource< R > * copy() const
Operation myOperation
The object&#39;s operation to perform.
const R myScale
The scale to apply.
CastingFunctionBinding< T, R, O > & operator=(const CastingFunctionBinding< T, R, O > &)
invalidated assignment operator
ValueSource< double > * makedoubleReturningCopy() const
CastingFunctionBinding(T *source, Operation operation, const R scale=1)