|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // �missingDescription� 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef FuncBinding_IntParam_h 00020 #define FuncBinding_IntParam_h 00021 00022 00023 00024 // =========================================================================== 00025 // included modules 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 // class definitions 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