/*
 * Sound.h
 *
 *  Created on: Aug 2, 2018
 *      Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
 */

#ifndef _SRC_OUTPUT_SOUND_H_
#define _SRC_OUTPUT_SOUND_H_

#include "output/items/Sound.h"
#include "Item.h"
#include "DriverBoardItem.h"

#include <memory>
#include <string>
#include <chrono>
#include <future>

namespace flippR_driver
{
namespace output
{

class SoundBoardPinController;

namespace items
{
namespace detail
{

class Sound : public detail::Item, public items::Sound, public detail::DriverBoardItem
{
public:
	u_int id;

public:
	Sound(std::shared_ptr<SoundBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name, const std::chrono::milliseconds & deactivation_time, const u_int id);
	~Sound() override = default;

	void play() override;

private:
	const std::chrono::milliseconds deactivation_time;

	const std::shared_ptr<SoundBoardPinController> pin_controller;

	std::future<void> play_task;

private:
	virtual void playTask();
};

}
}
} /* namespace output */
}
#endif
