Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F5277686
State.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
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/FunctionAbstractions.hpp"
#include
"rosa/agent/Functionality.h"
#include
"rosa/agent/History.hpp"
namespace
rosa
{
namespace
agent
{
// QUESTION: I think a global variable is not fine, I think it would be better
// to have that in private in the class. However, I have no idea how to
// initialize it then.
static
unsigned
int
StateIdCounter
=
0
;
/// \tparam INDATATYPE type of input data, \tparam DABSTORETYPE type of data
/// in which DABs are saved,
template
<
typename
INDATATYPE
,
typename
DABSTORETYPE
>
class
State
:
public
Functionality
{
// Make sure the actual type arguments are matching our expectations.
STATIC_ASSERT
((
std
::
is_arithmetic
<
INDATATYPE
>::
value
),
"input data type not arithmetic"
);
STATIC_ASSERT
((
std
::
is_arithmetic
<
DABSTORETYPE
>::
value
),
"DAB storage type is not to arithmetic"
);
private
:
using
PartFuncPointer
=
std
::
shared_ptr
<
PartialFunction
<
INDATATYPE
,
DABSTORETYPE
>>
;
unsigned
int
StateId
;
DynamicLengthHistory
<
INDATATYPE
,
HistoryPolicy
::
FIFO
>
SampleHistory
;
DynamicLengthHistory
<
INDATATYPE
,
HistoryPolicy
::
SRWF
>
DAB
;
DynamicLengthHistory
<
DABSTORETYPE
,
HistoryPolicy
::
LIFO
>
DABHistory
;
PartFuncPointer
PartialFunctionSampleMatches
;
PartFuncPointer
PartialFunctionSampleMismatches
;
PartFuncPointer
PartialFunctionNumOfSamplesMatches
;
PartFuncPointer
PartialFunctionNumOfSamplesMismatches
;
bool
StateIsValid
;
bool
StateIsValidAfterReentrance
;
public
:
State
(
unsigned
int
sampleHistorySize
,
unsigned
int
DABSize
,
unsigned
int
DABHistorySize
,
PartFuncPointer
PartialFunctionSampleMatches
,
PartFuncPointer
PartialFunctionSampleMismatches
,
PartFuncPointer
PartialFunctionNumOfSamplesMatches
,
PartFuncPointer
PartialFunctionNumOfSamplesMismatches
)
noexcept
:
SampleHistory
(
sampleHistorySize
),
DAB
(
DABSize
),
DABHistory
(
DABHistorySize
),
PartialFunctionSampleMatches
(
PartialFunctionSampleMatches
),
PartialFunctionSampleMismatches
(
PartialFunctionSampleMismatches
),
PartialFunctionNumOfSamplesMatches
(
PartialFunctionNumOfSamplesMatches
),
PartialFunctionNumOfSamplesMismatches
(
PartialFunctionNumOfSamplesMismatches
)
{
/*
StateIsValid = false;
StateIsValidAfterReentrance = false;
*/
}
~
State
(
void
)
=
default
;
void
leaveState
(
void
)
{
DAB
.
clear
();
StateIsValidAfterReentrance
=
false
;
}
bool
insertSample
(
INDATATYPE
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
())
{
DABSTORETYPE
AvgOfDAB
=
DAB
.
average
<
DABSTORETYPE
>
();
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) { return NULL; }
// 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
Sun, Apr 12, 4:48 AM (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
307313
Default Alt Text
State.hpp (3 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline
Log In to Comment