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