SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FunctionBinding.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Function type template
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef FunctionBinding_h
24 #define FunctionBinding_h
25 
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
38 #include "CastingFunctionBinding.h"
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
47 template< class T, typename R >
48 class FunctionBinding : public ValueSource<R> {
49 public:
51  typedef R(T::* Operation)() const;
52 
53  FunctionBinding(T* const source, Operation operation, const R scale = 1) :
54  mySource(source),
55  myOperation(operation),
56  myScale(scale) {}
57 
60 
61  R getValue() const {
62  return myScale * (mySource->*myOperation)();
63  }
64 
65  ValueSource<R>* copy() const {
67  }
68 
71  }
72 
73 private:
76 
79 
81  const R myScale;
82 
83 private:
86 
87 };
88 
89 
90 #endif
91 
92 /****************************************************************************/
93 
FunctionBinding(T *const source, Operation operation, const R scale=1)
T * mySource
The object the action is directed to.
R getValue() const
ValueSource< SUMOReal > * makeSUMORealReturningCopy() const
const R myScale
The scale to apply.
FunctionBinding< T, R > & operator=(const FunctionBinding< T, R > &)
invalidated assignment operator
R(T::* Operation)() const
Type of the function to execute.
Operation myOperation
The object's operation to perform.
~FunctionBinding()
Destructor.
ValueSource< R > * copy() const