Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F27036428
State.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
State.hpp
View Options
//===-- rosa/agent/State.hpp ----------------------------*- C++ -*-===//
//
// The RoSA Framework
//
//===----------------------------------------------------------------------===//
///
/// \file rosa/agent/State.hpp
///
/// \author Maximilian Götzinger (maximilian.goetzinger@tuwien.ac.at)
///
/// \date 2019
///
/// \brief Definition of *state* *functionality*.
///
//===----------------------------------------------------------------------===//
#ifndef ROSA_AGENT_STATE_HPP
#define ROSA_AGENT_STATE_HPP
#include
"rosa/agent/Functionality.h"
#include
"rosa/agent/History.hpp"
namespace
rosa
{
namespace
agent
{
using
PartFuncPointer
=
std
::
shared_ptr
<
PartialFunction
<
DIN
,
DDAB
>>
;
/// \tparam DIN type of data of input, \tparam DDAB type of data in which DABs are saved,
template
<
typename
DIN
,
typename
DDAB
,
>
class
State
:
public
Functionality
{
private
:
unsigned
int
StateId
;
//counter static und nur raufzählen, wenn sprung von invalid auf valid
DynamicHistory
<
DIN
,
HistoryPolicy
::
FIFO
>
SampleHistory
;
DynamicHistory
<
DIN
,
HistoryPolicy
::
SRWF
>
DAB
;
DynamicHistory
<
DDAB
,
HistoryPolicy
::
LIFO
>
DABHistory
;
PartFuncPointer
PartialFunctionSampleMatches
;
PartFuncPointer
PartialFunctionSampleMismatches
;
PartFuncPointer
PartialFunctionNumOfSamplesMatches
;
PartFuncPointer
PartialFunctionNumOfSamplesMismatches
;
bool
StateIsValid
;
bool
StateIsValidAfterReentrance
;
public
:
State
(
unsigned
int
StateId
,
unsigned
int
sampleHistorySize
,
unsigned
int
DABSize
,
unsigned
int
DABHistorySize
,
PartFuncPointer
PartialFunctionSampleMatches
,
PartialFunction
*
PartialFunctionSampleMismatches
,
PartialFunction
*
PartialFunctionNumOfSamplesMatches
,
PartialFunction
*
PartialFunctionNumOfSamplesMismatches
)
noexcept
:
SampleHistory
(
sampleHistorySize
),
DAB
(
DABSize
),
DABHistory
(
DABHistorySize
)
{
this
->
StateId
=
StateId
;
//TODO: oben machen
this
->
PartialFunctionSampleMatches
=
PartialFunctionSampleMatches
;
this
->
PartialFunctionSampleMismatches
=
PartialFunctionSampleMismatches
;
this
->
PartialFunctionNumOfSamplesMatches
=
PartialFunctionNumOfSamplesMatches
;
this
->
PartialFunctionNumOfSamplesMismatches
=
PartialFunctionNumOfSamplesMismatches
;
StateIsValid
=
false
;
StateIsValidAfterReentrance
=
false
;
}
//TODO: static assert -> check:
// 1) if DIN == arithmetic,
// 2) if DDAB == float, double, ...? (vielleicht annäherung mit int)
~
State
(
void
)
=
default
;
void
leaveState
(
void
)
{
DAB
.
clear
();
StateIsValidAfterReentrance
=
false
;
}
bool
insertSample
(
D
Sample
)
{
bool
workedForAll
;
//maybe ignor that //auc hnicht abchecken einfach kübeln
workedForAll
=
SampleHistory
.
addEntry
(
Sample
);
//QUESTION: is it important to have this flag (workedForAll). What should I do if it does not work at some point?
if
(
workedForAll
)
{
workedForAll
&=
DAB
.
addEntry
(
Sample
);
if
(
workedForAll
)
{
if
(
DAB
.
full
())
{
DDAB
AvgOfDAB
=
DAB
.
average
<
DDAB
>
();
workedForAll
&=
DABHistory
.
addEntry
(
AvgOfDAB
);
if
(
workedForAll
)
{
DAB
.
clear
();
}
//QUESTION: - what should be done if it has not worked?
}
if
(
workedForAll
)
{
//TODO: calculate whether state is valid
}
}
}
return
workedForAll
;
}
DDAB
confSampleMatchesState
(
DIN
sample
)
{
}
DDAB
confSampleMismatchesState
()
{
}
unsigned
int
stateId
(
void
)
{
return
StateId
;
}
};
}
// End namespace agent
}
// End namespace rosa
#endif
// ROSA_AGENT_STATE_HPP
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Tue, Oct 27, 7:57 PM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
410460
Default Alt Text
State.hpp (3 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline