SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // �missingDescription� 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 #ifndef FuncBinding_IntParam_h 00023 #define FuncBinding_IntParam_h 00024 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #include <utils/common/ValueSource.h> 00037 00038 00039 // =========================================================================== 00040 // class definitions 00041 // =========================================================================== 00045 template< class T, typename R > 00046 class FuncBinding_IntParam : public ValueSource<R> { 00047 public: 00049 typedef R(T::* Operation)(int) const; 00050 00051 FuncBinding_IntParam(T* source, Operation operation, 00052 size_t param) 00053 : 00054 mySource(source), 00055 myOperation(operation), 00056 myParam(param) {} 00057 00059 ~FuncBinding_IntParam() {} 00060 00061 SUMOReal getValue() const { 00062 return (mySource->*myOperation)(myParam); 00063 } 00064 00065 ValueSource<R> *copy() const { 00066 return new FuncBinding_IntParam<T, R>( 00067 mySource, myOperation, myParam); 00068 } 00069 00070 ValueSource<SUMOReal> *makeSUMORealReturningCopy() const { 00071 return new FuncBinding_IntParam<T, SUMOReal>(mySource, myOperation, myParam); 00072 } 00073 00074 protected: 00075 00076 private: 00078 T* mySource; 00079 00081 Operation myOperation; 00082 00083 int myParam; 00084 00085 }; 00086 00087 00088 #endif 00089 00090 /****************************************************************************/ 00091