CastingFunctionBinding.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CastingFunctionBinding_h
00020 #define CastingFunctionBinding_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include <utils/common/ValueSource.h>
00033
00034
00035
00036
00037
00041 template< class T, typename R, typename O >
00042 class CastingFunctionBinding : public ValueSource<R> {
00043 public:
00045 typedef O(T::* Operation)() const;
00046
00047 CastingFunctionBinding(T* source, Operation operation) :
00048 mySource(source),
00049 myOperation(operation) {}
00050
00052 ~CastingFunctionBinding() {}
00053
00054 R getValue() const {
00055 return (R)(mySource->*myOperation)();
00056 }
00057
00058 ValueSource<R> *copy() const {
00059 return new CastingFunctionBinding<T, R, O>(mySource, myOperation);
00060 }
00061
00062 ValueSource<SUMOReal> *makeSUMORealReturningCopy() const {
00063 return new CastingFunctionBinding<T, SUMOReal, O>(mySource, myOperation);
00064 }
00065
00066 protected:
00067
00068 private:
00070 T* mySource;
00071
00073 Operation myOperation;
00074 };
00075
00076
00077 #endif
00078
00079
00080