diff --git a/include/rosa/agent/State.hpp b/include/rosa/agent/State.hpp index 06bb085..fe977bb 100644 --- a/include/rosa/agent/State.hpp +++ b/include/rosa/agent/State.hpp @@ -1,77 +1,109 @@ //===-- 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 D type of data -template class State : public Functionality { +/// \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 class State : public Functionality { private: - DynamicHistory SampleHistory; //Make History dynamic - DynamicHistory DAB; - DynamicHistory DABHistory; //Implement LIFO + DynamicHistory SampleHistory; + DynamicHistory DAB; + DynamicHistory DABHistory; + + PartialFunction* ConfidenceSimilarToSample, + ConfidenceDifferentToSample; public: State(unsigned int sampleHistorySize, unsigned int DABSize, - unsigned int DABHistorySize) noexcept : + unsigned int DABHistorySize, PartialFunction* ConfidenceSimilarToSample, + PartialFunction* ConfidenceDifferentToSample) noexcept : SampleHistory(sampleHistorySize), DAB(DABSize), - DABHistory(DABHistorySize) {} + 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) { - if (numberOfEntries >= DAB) { + 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); - - } - - - //check if full/empty - - workedForAll &= DAB.addEntry(Sample); - - - - - + 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 \ No newline at end of file