SUMO - Simulation of Urban MObility
CastingFunctionBinding.h
Go to the documentation of this file.
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3
// Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4
/****************************************************************************/
5
//
6
// This program and the accompanying materials
7
// are made available under the terms of the Eclipse Public License v2.0
8
// which accompanies this distribution, and is available at
9
// http://www.eclipse.org/legal/epl-v20.html
10
//
11
/****************************************************************************/
19
// Function type template
20
/****************************************************************************/
21
#ifndef CastingFunctionBinding_h
22
#define CastingFunctionBinding_h
23
24
25
// ===========================================================================
26
// included modules
27
// ===========================================================================
28
#ifdef _MSC_VER
29
#include <
windows_config.h
>
30
#else
31
#include <
config.h
>
32
#endif
33
34
#include <
utils/common/ValueSource.h
>
35
36
37
// ===========================================================================
38
// class definitions
39
// ===========================================================================
43
template
<
class
T,
typename
R,
typename
O >
44
class
CastingFunctionBinding
:
public
ValueSource
<R> {
45
public
:
47
typedef
O(T::*
Operation
)()
const
;
48
49
CastingFunctionBinding
(T* source,
Operation
operation,
const
R scale = 1) :
50
mySource
(source),
51
myOperation
(operation),
52
myScale
(scale) {}
53
55
~CastingFunctionBinding
() {}
56
57
R
getValue
()
const
{
58
return
myScale
* (R)(
mySource
->*
myOperation
)();
59
}
60
61
ValueSource<R>
*
copy
()
const
{
62
return
new
CastingFunctionBinding<T, R, O>
(
mySource
,
myOperation
,
myScale
);
63
}
64
65
ValueSource<double>
*
makedoubleReturningCopy
()
const
{
66
return
new
CastingFunctionBinding<T, double, O>
(
mySource
,
myOperation
,
myScale
);
67
}
68
69
private
:
71
T*
mySource
;
72
74
Operation
myOperation
;
75
77
const
R
myScale
;
78
79
private
:
81
CastingFunctionBinding<T, R, O>
&
operator=
(
const
CastingFunctionBinding<T, R, O>
&);
82
83
};
84
85
86
#endif
87
88
/****************************************************************************/
89
CastingFunctionBinding::Operation
O(T::* Operation)() const
Type of the function to execute.
Definition:
CastingFunctionBinding.h:47
windows_config.h
ValueSource.h
config.h
CastingFunctionBinding::~CastingFunctionBinding
~CastingFunctionBinding()
Destructor.
Definition:
CastingFunctionBinding.h:55
CastingFunctionBinding::mySource
T * mySource
The object the action is directed to.
Definition:
CastingFunctionBinding.h:71
ValueSource
Definition:
ValueSource.h:40
CastingFunctionBinding::copy
ValueSource< R > * copy() const
Definition:
CastingFunctionBinding.h:61
CastingFunctionBinding::myOperation
Operation myOperation
The object's operation to perform.
Definition:
CastingFunctionBinding.h:74
CastingFunctionBinding::myScale
const R myScale
The scale to apply.
Definition:
CastingFunctionBinding.h:77
CastingFunctionBinding::operator=
CastingFunctionBinding< T, R, O > & operator=(const CastingFunctionBinding< T, R, O > &)
invalidated assignment operator
CastingFunctionBinding::makedoubleReturningCopy
ValueSource< double > * makedoubleReturningCopy() const
Definition:
CastingFunctionBinding.h:65
CastingFunctionBinding::CastingFunctionBinding
CastingFunctionBinding(T *source, Operation operation, const R scale=1)
Definition:
CastingFunctionBinding.h:49
CastingFunctionBinding
Definition:
CastingFunctionBinding.h:44
CastingFunctionBinding::getValue
R getValue() const
Definition:
CastingFunctionBinding.h:57
src
microsim
logging
CastingFunctionBinding.h
Generated on Fri May 25 2018 08:54:34 for SUMO - Simulation of Urban MObility by
1.8.13