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