Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1493977
DeluxeSensor.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Size
3 KB
Referenced Files
None
Subscribers
None
DeluxeSensor.cpp
View Options
//===-- deluxe/DeluxeSensor.cpp ---------------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file deluxe/DeluxeSensor.cpp
///
/// \author David Juhasz (david.juhasz@tuwien.ac.at)
///
/// \date 2017-2019
///
/// \brief Implementation of rosa/deluxe/DeluxeSensor.hpp.
///
//===----------------------------------------------------------------------===//
#include
"rosa/deluxe/DeluxeSensor.hpp"
#include
"rosa/deluxe/DeluxeSystem.hpp"
namespace
rosa
{
namespace
deluxe
{
bool
DeluxeSensor
::
inv
(
void
)
const
noexcept
{
// Check execution policy.
// \note The \c rosa::System the \c rosa::Unit is created with is a
// \c rosa::DeluxeSystem.
const
DeluxeSystem
&
DS
=
static_cast
<
DeluxeSystem
&>
(
Unit
::
system
());
if
(
!
ExecutionPolicy
||
!
ExecutionPolicy
->
canHandle
(
Self
,
DS
))
{
return
false
;
}
// All checks were successful, the invariant is held.
return
true
;
}
DeluxeSensor
::~
DeluxeSensor
(
void
)
noexcept
{
ASSERT
(
inv
());
LOG_TRACE
(
"Destroying DeluxeSensor..."
);
// Make sure \p this object is not a registered *slave*.
if
(
Master
)
{
ASSERT
(
unwrapAgent
(
*
Master
).
Kind
==
atoms
::
AgentKind
);
// Sanity check.
DeluxeAgent
&
M
=
static_cast
<
DeluxeAgent
&>
(
unwrapAgent
(
*
Master
));
ASSERT
(
M
.
positionOfSlave
(
self
())
!=
M
.
NumberOfInputs
);
// Sanity check.
M
.
registerSlave
(
M
.
positionOfSlave
(
self
()),
{});
Master
=
{};
}
}
const
DeluxeExecutionPolicy
&
DeluxeSensor
::
executionPolicy
(
void
)
const
noexcept
{
ASSERT
(
inv
());
return
*
ExecutionPolicy
;
}
bool
DeluxeSensor
::
setExecutionPolicy
(
std
::
unique_ptr
<
DeluxeExecutionPolicy
>
&&
EP
)
noexcept
{
ASSERT
(
inv
());
LOG_TRACE_STREAM
<<
"DeluxeSensor "
<<
FullName
<<
" setting execution policy "
<<
*
EP
<<
std
::
endl
;
bool
Success
=
false
;
// \note The \c rosa::System the \c rosa::Unit is created with is a
// \c rosa::DeluxeSystem.
const
DeluxeSystem
&
DS
=
static_cast
<
DeluxeSystem
&>
(
Unit
::
system
());
if
(
EP
&&
EP
->
canHandle
(
self
(),
DS
))
{
ExecutionPolicy
.
swap
(
EP
);
Success
=
true
;
}
else
{
LOG_TRACE_STREAM
<<
"Execution policy "
<<
*
EP
<<
" cannot handle DeluxeSensor "
<<
FullName
<<
std
::
endl
;
}
ASSERT
(
inv
());
return
Success
;
}
Optional
<
AgentHandle
>
DeluxeSensor
::
master
(
void
)
const
noexcept
{
ASSERT
(
inv
());
return
Master
;
}
void
DeluxeSensor
::
registerMaster
(
const
Optional
<
AgentHandle
>
_Master
)
noexcept
{
ASSERT
(
inv
()
&&
(
!
_Master
||
unwrapAgent
(
*
_Master
).
Kind
==
atoms
::
AgentKind
));
Master
=
_Master
;
ASSERT
(
inv
());
}
void
DeluxeSensor
::
clearSimulationDataSource
(
void
)
noexcept
{
ASSERT
(
inv
());
SFP
=
nullptr
;
ASSERT
(
inv
());
}
bool
DeluxeSensor
::
simulationDataSourceIsSet
(
void
)
const
noexcept
{
ASSERT
(
inv
());
return
SFP
!=
nullptr
;
}
void
DeluxeSensor
::
handleTrigger
(
atoms
::
Trigger
)
noexcept
{
ASSERT
(
inv
());
// Use \c rosa::deluxe::DeluxeSensor::SFP if set, otherwise
// \c rosa::deluxe::DeluxeSensor::FP.
const
H
&
F
=
SFP
?
SFP
:
FP
;
F
();
ASSERT
(
inv
());
}
}
// End namespace deluxe
}
// End namespace rosa
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sun, Mar 1, 6:02 PM (1 d, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
281427
Default Alt Text
DeluxeSensor.cpp (3 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline
Log In to Comment