FunctionBinding.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 //  »missingDescription«
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 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 FunctionBinding_h
00020 #define FunctionBinding_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 #include "CastingFunctionBinding.h"
00035 
00036 
00037 // ===========================================================================
00038 // class definitions
00039 // ===========================================================================
00043 template< class T, typename R  >
00044 class FunctionBinding : public ValueSource<R> {
00045 public:
00047     typedef R(T::* Operation)() const;
00048 
00049     FunctionBinding(T* source, Operation operation) :
00050             mySource(source),
00051             myOperation(operation) {}
00052 
00054     ~FunctionBinding() {}
00055 
00056     R getValue() const {
00057         return (mySource->*myOperation)();
00058     }
00059 
00060     ValueSource<R> *copy() const {
00061         return new FunctionBinding<T, R>(mySource, myOperation);
00062     }
00063 
00064     ValueSource<SUMOReal> *makeSUMORealReturningCopy() const {
00065         return new CastingFunctionBinding<T, SUMOReal, R>(mySource, myOperation);
00066     }
00067 
00068 private:
00070     T* mySource;
00071 
00073     Operation myOperation;
00074 };
00075 
00076 
00077 #endif
00078 
00079 /****************************************************************************/
00080 

Generated on Wed May 5 00:06:29 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6