<commit_before>/*
 * PuckManager.cpp
 *
 *  Created on: 09.06.2017
 *      Author: aca592
 */

#include "PuckManager.h"

PuckManager::PuckManager() {
	// TODO Auto-generated constructor stub
}

PuckManager::~PuckManager() {
	// TODO Auto-generated destructor stub
}

void PuckManager::addPuck(PuckContext *puck) {
	puck->setPuckID(nextPuckID++);
	puckList.push_back(puck);
}

PuckManager::ManagerReturn PuckManager::process(PuckSignal::Signal signal) {
	ManagerReturn prioReturnVal; // the prioritized return value
	prioReturnVal.puckSpeed = PuckSignal::PuckSpeed::FAST;
	prioReturnVal.actorFlag = false;
	prioReturnVal.errorFlag = false;
	prioReturnVal.slideFullFlag = false;
	prioReturnVal.puck = nullptr;

	// TODO: Pass timer signals to puck with puckid
	//if(signal.signalType == PuckSignal::SignalType::TIMER_SIGNAL) {
	//	do {
	//
	//	} while ()
	//
	//}<commit_msg>todo: getspeed of all pucls for timer evaluation<commit_after>/*
 * PuckManager.cpp
 *
 *  Created on: 09.06.2017
 *      Author: aca592
 */

#include "PuckManager.h"

PuckManager::PuckManager() {
	// TODO Auto-generated constructor stub
}

PuckManager::~PuckManager() {
	// TODO Auto-generated destructor stub
}

void PuckManager::addPuck(PuckContext *puck) {
	puck->setPuckID(nextPuckID++);
	puckList.push_back(puck);
}

PuckManager::ManagerReturn PuckManager::process(PuckSignal::Signal signal) {
	ManagerReturn prioReturnVal; // the prioritized return value
	prioReturnVal.puckSpeed = PuckSignal::PuckSpeed::FAST;
	prioReturnVal.actorFlag = false;
	prioReturnVal.errorFlag = false;
	prioReturnVal.slideFullFlag = false;
	prioReturnVal.puck = nullptr;

	// TODO: Pass timer signals to puck with puckid
	if(signal.signalType == PuckSignal::SignalType::TIMER_SIGNAL) {
		std::list<PuckContext*>::iterator it = puckList.begin();
		do {
			uint16_t currentPuckID = (*it)->getPuckID();
			if(currentPuckID == signal.timerSignal.puckID) {
				PuckSignal::Return returnVal = (*it)->process(signal);

				switch(returnVal.puckReturn) {
					case PuckSignal::PuckReturn::ACCEPT:

						break;
					case PuckSignal::PuckReturn::DELETE:

						delete *it;					// delete the puck from memory
						it = puckList.erase(it);	// delete the puck from list
						break;
					case PuckSignal::PuckReturn::SEND:

						prioReturnVal.puck = (*it);
						prioReturnVal.actorFlag = true;
						prioReturnVal.actorSignal = ActorSignal::SEND_PUCK;
						break;
					case PuckSignal::PuckReturn::EVALUATE:

						// todo: sort
						break;
					case PuckSignal::PuckReturn::HEIGHT:

						prioReturnVal.actorFlag = true;
						prioReturnVal.actorSignal = ActorSignal::START_MEASUREMENT;
						break;
					case PuckSignal::PuckReturn::SLIDE_FULL:

						prioReturnVal.slideFullFlag = true;
						break;
					//
					case PuckSignal::PuckReturn::WARNING:

						break;
					case PuckSignal::PuckReturn::DENY:
						break;
					case PuckSignal::PuckReturn::ERROR:
						prioReturnVal.errorFlag = true;
						prioReturnVal.errorSignal = ErrorSignal::PUCK_LOST;
						break;
					default:
						prioReturnVal.errorFlag = true;
						prioReturnVal.errorSignal = ErrorSignal::UNEXPECTED_SIGNAL;
						return prioReturnVal;
				}
			}
		} while (it != puckList.end());

		return prioReturnVal;
	}
{'fraction_non_alphanumeric': 0.12040753318925594, 'fraction_numerical': 0.007409694350108058, 'mean_word_length': 3.8795180722891565, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2359284', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1111, 'n_words': 199}