SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CastingFunctionBinding.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // »missingDescription«/****************************************************************************/ // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/ // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors /****************************************************************************/ // // This file is part of SUMO. // SUMO is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // /****************************************************************************/ #ifndef CastingFunctionBinding_h #define CastingFunctionBinding_h // =========================================================================== // included modules // =========================================================================== #ifdef _MSC_VER #include <windows_config.h> #else #include <config.h> #endif #include <utils/common/ValueSource.h> // =========================================================================== // class definitions // =========================================================================== /** * @class CastingFunctionBinding */ template< class T, typename R, typename O > class CastingFunctionBinding : public ValueSource<R> { public: /// Type of the function to execute. typedef O(T::* Operation)() const; CastingFunctionBinding(T* source, Operation operation, const R scale = 1) : mySource(source), myOperation(operation), myScale(scale) {} /// Destructor. ~CastingFunctionBinding() {} R getValue() const { return myScale * (R)(mySource->*myOperation)(); } ValueSource<R>* copy() const { return new CastingFunctionBinding<T, R, O>(mySource, myOperation, myScale); } ValueSource<SUMOReal>* makeSUMORealReturningCopy() const { return new CastingFunctionBinding<T, SUMOReal, O>(mySource, myOperation, myScale); } private: /// The object the action is directed to. T* mySource; /// The object's operation to perform. Operation myOperation; /// The scale to apply. const R myScale; private: /// @brief invalidated assignment operator CastingFunctionBinding<T, R, O>& operator=(const CastingFunctionBinding<T, R, O>&); }; #endif /****************************************************************************/
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef CastingFunctionBinding_h
23 #define CastingFunctionBinding_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
36 
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
44 template< class T, typename R, typename O >
46 public:
48  typedef O(T::* Operation)() const;
49 
50  CastingFunctionBinding(T* source, Operation operation, const R scale = 1) :
51  mySource(source),
52  myOperation(operation),
53  myScale(scale) {}
54 
57 
58  R getValue() const {
59  return myScale * (R)(mySource->*myOperation)();
60  }
61 
62  ValueSource<R>* copy() const {
64  }
65 
68  }
69 
70 private:
73 
76 
78  const R myScale;
79 
80 private:
83 
84 };
85 
86 
87 #endif
88 
89 /****************************************************************************/
90 
ValueSource< SUMOReal > * makeSUMORealReturningCopy() const
T * mySource
The object the action is directed to.
Operation myOperation
The object&#39;s operation to perform.
O(T::* Operation)() const
Type of the function to execute.
const R myScale
The scale to apply.
CastingFunctionBinding< T, R, O > & operator=(const CastingFunctionBinding< T, R, O > &)
invalidated assignment operator
CastingFunctionBinding(T *source, Operation operation, const R scale=1)
ValueSource< R > * copy() const