1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file FuncBinding_IntParam.h 11 /// @author Daniel Krajzewicz 12 /// @author Sascha Krieg 13 /// @author Michael Behrisch 14 /// @date Fri, 29.04.2005 15 /// @version $Id$ 16 /// 17 // �Function type template 18 /****************************************************************************/ 19 #ifndef FuncBinding_IntParam_h 20 #define FuncBinding_IntParam_h 21 22 23 24 // =========================================================================== 25 // included modules 26 // =========================================================================== 27 #include <config.h> 28 29 #include <utils/common/ValueSource.h> 30 31 32 // =========================================================================== 33 // class definitions 34 // =========================================================================== 35 /** 36 * @class FuncBinding_IntParam 37 */ 38 template< class T, typename R > 39 class FuncBinding_IntParam : public ValueSource<R> { 40 public: 41 /// Type of the function to execute. 42 typedef R(T::* Operation)(int) const; 43 FuncBinding_IntParam(T * source,Operation operation,int param)44 FuncBinding_IntParam(T* source, Operation operation, 45 int param) 46 : 47 mySource(source), 48 myOperation(operation), 49 myParam(param) {} 50 51 /// Destructor. ~FuncBinding_IntParam()52 ~FuncBinding_IntParam() {} 53 getValue()54 double getValue() const { 55 return (mySource->*myOperation)(myParam); 56 } 57 copy()58 ValueSource<R>* copy() const { 59 return new FuncBinding_IntParam<T, R>( 60 mySource, myOperation, myParam); 61 } 62 makedoubleReturningCopy()63 ValueSource<double>* makedoubleReturningCopy() const { 64 return new FuncBinding_IntParam<T, double>(mySource, myOperation, myParam); 65 } 66 67 protected: 68 69 private: 70 /// The object the action is directed to. 71 T* mySource; 72 73 /// The object's operation to perform. 74 Operation myOperation; 75 76 int myParam; 77 78 }; 79 80 81 #endif 82 83 /****************************************************************************/ 84 85