CastingFunctionBinding.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 CastingFunctionBinding_h
00020 #define CastingFunctionBinding_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <utils/common/ValueSource.h>
00033 
00034 
00035 // ===========================================================================
00036 // class definitions
00037 // ===========================================================================
00041 template< class T, typename R, typename O  >
00042 class CastingFunctionBinding : public ValueSource<R> {
00043 public:
00045     typedef O(T::* Operation)() const;
00046 
00047     CastingFunctionBinding(T* source, Operation operation) :
00048             mySource(source),
00049             myOperation(operation) {}
00050 
00052     ~CastingFunctionBinding() {}
00053 
00054     R getValue() const {
00055         return (R)(mySource->*myOperation)();
00056     }
00057 
00058     ValueSource<R> *copy() const {
00059         return new CastingFunctionBinding<T, R, O>(mySource, myOperation);
00060     }
00061 
00062     ValueSource<SUMOReal> *makeSUMORealReturningCopy() const {
00063         return new CastingFunctionBinding<T, SUMOReal, O>(mySource, myOperation);
00064     }
00065 
00066 protected:
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:28 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6