Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1497749
RangeConfidence.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Size
3 KB
Referenced Files
None
Subscribers
None
RangeConfidence.hpp
View Options
//===-- rosa/agent/RangeConfidence.hpp --------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file rosa/agent/RangeConfidence.hpp
///
/// \author Benedikt Tutzer (benedikt.tutzer@tuwien.ac.at)
///
/// \date 2019
///
/// \brief Definition of *RangeConfidence* *functionality*.
///
//===----------------------------------------------------------------------===//
#ifndef ROSA_AGENT_RANGECONFIDENCE_HPP
#define ROSA_AGENT_RANGECONFIDENCE_HPP
#include
"rosa/agent/Functionality.h"
#include
"rosa/agent/Abstraction.hpp"
#include
"rosa/agent/FunctionAbstractions.hpp"
#include
"rosa/support/debug.hpp"
#include
<algorithm>
#include
<vector>
#include
<cmath>
#include
<memory>
namespace
rosa
{
namespace
agent
{
/// Evaluates a vector of Abstractions at a given value and returns the results
/// as a vector
///
/// \note This implementation is supposed to be used to abstract ranges of
/// arithmetic types into vectors of another arithmetic type, which is
/// statically enforced.
///
/// \tparam T type to abstract from
/// \tparam A type to abstract a vector of to
template
<
typename
T
,
typename
A
,
typename
B
>
class
RangeConfidence
:
protected
Abstraction
<
T
,
std
::
map
<
A
,
B
>>
,
private
std
::
map
<
A
,
PartialFunction
<
T
,
B
>>
{
// Make sure the actual type arguments are matching our expectations.
STATIC_ASSERT
((
std
::
is_arithmetic
<
T
>::
value
),
"abstracting not arithmetic"
);
STATIC_ASSERT
((
std
::
is_arithmetic
<
B
>::
value
),
"abstracting not to arithmetic"
);
// Bringing into scope inherited members.
using
std
::
map
<
A
,
PartialFunction
<
T
,
B
>>::
size
;
using
std
::
map
<
A
,
PartialFunction
<
T
,
B
>>::
begin
;
using
std
::
map
<
A
,
PartialFunction
<
T
,
B
>>::
end
;
private
:
bool
IgnoreDefaults
;
public
:
/// Creates an instance by Initializing the underlying \c RangeAbstraction.
///
/// \param Abstractions the Abstractions to be evaluated
RangeConfidence
(
const
std
::
map
<
A
,
PartialFunction
<
T
,
B
>>
&
Abstractions
,
bool
IgnoreDefaults
=
false
)
:
Abstraction
<
T
,
std
::
map
<
A
,
B
>>
({}),
std
::
map
<
A
,
PartialFunction
<
T
,
B
>>
(
Abstractions
),
IgnoreDefaults
(
IgnoreDefaults
){
}
/// Destroys \p this object.
~
RangeConfidence
(
void
)
=
default
;
/// Evaluates an Abstraction from type \p T to type \p A based on the set
/// mapping.
///
/// Results in the value associated by the set mapping to the argument, or
/// \c rosa::agent::RangeAbstraction::Default if the actual argument is not
/// included in any of the ranges in the set mapping.
///
/// \param V value to abstract
///
/// \return the abstracted value based on the set mapping
std
::
map
<
A
,
B
>
operator
()(
const
T
&
V
)
const
noexcept
override
{
std
::
map
<
A
,
B
>
ret
;
for
(
auto
const
&
p
:
((
std
::
map
<
A
,
PartialFunction
<
T
,
B
>>
)
*
this
)){
B
res
=
p
.
second
(
V
);
if
(
!
IgnoreDefaults
||
p
.
second
.
Default
!=
res
)
ret
.
insert
(
std
::
pair
<
A
,
B
>
(
p
.
first
,
res
));
}
return
ret
;
}
};
}
// End namespace agent
}
// End namespace rosa
#endif
// ROSA_AGENT_RANGECONFIDENCE_HPP
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sun, Mar 1, 9:39 PM (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
289192
Default Alt Text
RangeConfidence.hpp (3 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline
Log In to Comment