Page MenuHomePhorge

State.hpp
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

State.hpp

//===-- 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 {
/// \tparam DIN type of data of input, \tparam DDAB type of data in which DABs are saved,
/// \tparam DIN type of data of output
template <typename DIN, typename DDAB, typename DOUT> class State : public Functionality {
private:
DynamicHistory<DIN, HistoryPolicy::FIFO> SampleHistory;
DynamicHistory<DIN, HistoryPolicy::SRWF> DAB;
DynamicHistory<DDAB, HistoryPolicy::LIFO> DABHistory;
PartialFunction* ConfidenceSimilarToSample,
ConfidenceDifferentToSample;
public:
State(unsigned int sampleHistorySize, unsigned int DABSize,
unsigned int DABHistorySize, PartialFunction* ConfidenceSimilarToSample,
PartialFunction* ConfidenceDifferentToSample) noexcept :
SampleHistory(sampleHistorySize),
DAB(DABSize),
DABHistory(DABHistorySize) {
this->ConfidenceSimilarToSample = ConfidenceSimilarToSample;
this->ConfidenceDifferentToSample = ConfidenceDifferentToSample;
}
//TODO: static assert -> check:
// 1) if DIN == arithmetic,
// 2) if DDAB == float, double, ...?
// 3) output could be arithemtic or char/string, right?
~State(void) = default;
void leaveState(void) {
if(!DAB.empty()) {
//TODO: delete all entries in DAB
//@Benedikt:I would need such a method in history
}
}
bool insertSample(D Sample) {
bool workedForAll;
workedForAll = SampleHistory.addEntry(Sample);
if (workedForAll) {
workedForAll &= DAB.addEntry(Sample);
if (workedForAll) {
if (numberOfEntries >= DAB) {
//TODO: calculate average of DAB
//@Benedikt: should we do this avg calc in the history class or here or somewhere else?
AvgOfDAB = 0; //XXX - Dummy value
workedForAll &= DABHistory.addEntry(AvgOfDAB);
if(workedForAll) {
//TODO: delete all entries in DAB
} //xxx - what should be done if it has not worked?
}
if(workedForAll) {
//calculate if state is valid
}
}
}
return workedForAll;
}
};
} // End namespace agent
} // End namespace rosa
#endif // ROSA_AGENT_STATE_HPP

File Metadata

Mime Type
text/x-c++
Expires
Sun, Apr 12, 11:42 AM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
307625
Default Alt Text
State.hpp (2 KB)

Event Timeline