SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FunctionBinding.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // »missingDescription«/****************************************************************************/ // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/ // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors /****************************************************************************/ // // This file is part of SUMO. // SUMO is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // /****************************************************************************/ #ifndef FunctionBinding_h #define FunctionBinding_h // =========================================================================== // included modules // =========================================================================== #ifdef _MSC_VER #include <windows_config.h> #else #include <config.h> #endif #include <utils/common/ValueSource.h> #include "CastingFunctionBinding.h" // =========================================================================== // class definitions // =========================================================================== /** * @class FunctionBinding */ template< class T, typename R > class FunctionBinding : public ValueSource<R> { public: /// Type of the function to execute. typedef R(T::* Operation)() const; FunctionBinding(T* const source, Operation operation) : mySource(source), myOperation(operation) {} /// Destructor. ~FunctionBinding() {} R getValue() const { return (mySource->*myOperation)(); } ValueSource<R>* copy() const { return new FunctionBinding<T, R>(mySource, myOperation); } ValueSource<SUMOReal>* makeSUMORealReturningCopy() const { return new CastingFunctionBinding<T, SUMOReal, R>(mySource, myOperation); } private: /// The object the action is directed to. T* mySource; /// The object's operation to perform. Operation myOperation; }; #endif /****************************************************************************/
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef FunctionBinding_h
24 #define FunctionBinding_h
25 
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
38 #include "CastingFunctionBinding.h"
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
47 template< class T, typename R >
48 class FunctionBinding : public ValueSource<R> {
49 public:
51  typedef R(T::* Operation)() const;
52 
53  FunctionBinding(T* const source, Operation operation) :
54  mySource(source),
55  myOperation(operation) {}
56 
59 
60  R getValue() const {
61  return (mySource->*myOperation)();
62  }
63 
64  ValueSource<R>* copy() const {
66  }
67 
70  }
71 
72 private:
75 
78 };
79 
80 
81 #endif
82 
83 /****************************************************************************/
84 
T * mySource
The object the action is directed to.
R getValue() const
ValueSource< SUMOReal > * makeSUMORealReturningCopy() const
FunctionBinding(T *const source, Operation operation)
R(T::* Operation)() const
Type of the function to execute.
Operation myOperation
The object&#39;s operation to perform.
~FunctionBinding()
Destructor.
ValueSource< R > * copy() const