Eclipse 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-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
/****************************************************************************/
16
// Function type template
17
/****************************************************************************/
18
#ifndef CastingFunctionBinding_h
19
#define CastingFunctionBinding_h
20
21
22
// ===========================================================================
23
// included modules
24
// ===========================================================================
25
#include <
config.h
>
26
27
#include <
utils/common/ValueSource.h
>
28
29
30
// ===========================================================================
31
// class definitions
32
// ===========================================================================
36
template
<
class
T,
typename
R,
typename
O >
37
class
CastingFunctionBinding
:
public
ValueSource
<R> {
38
public
:
40
typedef
O(T::*
Operation
)()
const
;
41
42
CastingFunctionBinding
(T* source,
Operation
operation,
const
R scale = 1) :
43
mySource
(source),
44
myOperation
(operation),
45
myScale
(scale) {}
46
48
~CastingFunctionBinding
() {}
49
50
R
getValue
()
const
{
51
return
myScale
* (R)(
mySource
->*
myOperation
)();
52
}
53
54
ValueSource<R>
*
copy
()
const
{
55
return
new
CastingFunctionBinding<T, R, O>
(
mySource
,
myOperation
,
myScale
);
56
}
57
58
ValueSource<double>
*
makedoubleReturningCopy
()
const
{
59
return
new
CastingFunctionBinding<T, double, O>
(
mySource
,
myOperation
,
myScale
);
60
}
61
62
private
:
64
T*
mySource
;
65
67
Operation
myOperation
;
68
70
const
R
myScale
;
71
72
private
:
74
CastingFunctionBinding<T, R, O>
&
operator=
(
const
CastingFunctionBinding<T, R, O>
&);
75
76
};
77
78
79
#endif
80
81
/****************************************************************************/
82
CastingFunctionBinding::myOperation
Operation myOperation
The object's operation to perform.
Definition:
CastingFunctionBinding.h:67
CastingFunctionBinding
Definition:
CastingFunctionBinding.h:37
CastingFunctionBinding::getValue
R getValue() const
Definition:
CastingFunctionBinding.h:50
CastingFunctionBinding::copy
ValueSource< R > * copy() const
Definition:
CastingFunctionBinding.h:54
CastingFunctionBinding::makedoubleReturningCopy
ValueSource< double > * makedoubleReturningCopy() const
Definition:
CastingFunctionBinding.h:58
CastingFunctionBinding::~CastingFunctionBinding
~CastingFunctionBinding()
Destructor.
Definition:
CastingFunctionBinding.h:48
CastingFunctionBinding::CastingFunctionBinding
CastingFunctionBinding(T *source, Operation operation, const R scale=1)
Definition:
CastingFunctionBinding.h:42
CastingFunctionBinding::Operation
O(T::* Operation)() const
Type of the function to execute.
Definition:
CastingFunctionBinding.h:40
CastingFunctionBinding::mySource
T * mySource
The object the action is directed to.
Definition:
CastingFunctionBinding.h:64
ValueSource.h
CastingFunctionBinding::operator=
CastingFunctionBinding< T, R, O > & operator=(const CastingFunctionBinding< T, R, O > &)
invalidated assignment operator
config.h
ValueSource
Definition:
ValueSource.h:32
CastingFunctionBinding::myScale
const R myScale
The scale to apply.
Definition:
CastingFunctionBinding.h:70
src
microsim
logging
CastingFunctionBinding.h
Generated on Sun Dec 13 2020 08:44:58 for Eclipse SUMO - Simulation of Urban MObility by
1.8.20