/* Blinker
   Copyright 2011-2019 Stefan Schuermans <stefan@blinkenarea.org>
   Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
   a blinkenarea.org project */

#ifndef BLINKER_PRIORITYINPUT_H
#define BLINKER_PRIORITYINPUT_H

#include <string>

#include <BlinkenLib/BlinkenFrame.h>

#include "File.h"
#include "InStreamFile.h"
#include "Priority.h"
#include "StreamMgr.h"
#include "StreamRecv.h"

namespace Blinker {

/// input to priority based selector
class Priority::Input: public StreamRecv
{
public:
  /**
   * @brief constructor
   * @param[in] priority owning priority based selector
   * @param[in] name name of input (i.e. priority)
   * @param[in] dirBase base directory
   */
  Input(Priority &priority, const std::string &name,
        const Directory &dirBase);

  /// virtual destructor
  virtual ~Input();

private:
  /// copy constructor disabled
  Input(const Input &that);

  /// assignment operator disabled
  const Input & operator=(const Input &that);

public:
  /// check for update of configuration
  void updateConfig();

  /**
   * @brief set current frame
   * @param[in] stream stream name
   * @param[in] pFrame current frame (NULL for none)
   */
  virtual void setFrame(const std::string &stream, stBlinkenFrame *pFrame);

  /**
   * @brief get current frame
   * @return current frame (NULL if none)
   */
  stBlinkenFrame * getCurFrame();

protected:
  /**
   * @brief set current frame
   * @param[in] pFrame current frame (NULL for none)
   */
  void frame(stBlinkenFrame *pFrame);

protected:
  Priority       &m_priority;    ///< owning priority based selector
  std::string    m_name;         ///< name of input (i.e. priority)
  InStreamFile   m_fileInStream; ///< input stream name file
  std::string    m_nameInStream; ///< name of input stream
  stBlinkenFrame *m_pFrame;      ///< current frame
}; // class Priority::Input

} // namespace Blinker

#endif // #ifndef BLINKER_PRIORITYINPUT_H

