/* 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_INSTREAMFILE_H
#define BLINKER_INSTREAMFILE_H

#include "File.h"
#include "StreamFile.h"
#include "StreamMgr.h"
#include "StreamRecv.h"

namespace Blinker {

/// setting file containting a name of an input stream
class InStreamFile: public StreamFile
{
public:
  /**
   * @brief constructor from path
   * @param[in] path path to file
   * @param[in] streamMgr stream manager
   */
  InStreamFile(const std::string &path, StreamMgr &streamMgr);

  /**
   * @brief constructor from basic file
   * @param[in] file basic file object
   * @param[in] streamMgr stream manager
   */
  InStreamFile(const File &file, StreamMgr &streamMgr);

  /// destructor
  ~InStreamFile();

  /**
   * @brief assignment operator
   * @param[in] file basic file object
   */
  const InStreamFile & operator=(const File &file);

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

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

public:
  /**
   * @brief set stream receiver
   * @param[in] pStreamRecv stream reciver (NULL if none)
   */
  void setStreamRecv(StreamRecv *pStreamRecv);

  /// update, i.e. (re-)read file and attach to new stream
  void update();

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

protected:
  /// attach to stream
  void attach();

  /// detach from stream
  void detach();

protected:
  StreamRecv *m_pStreamRecv; ///< stream receiver to attach to input stream
}; // class InStreamFile

} // namespace Blinker

#endif // #ifndef BLINKER_INSTREAMFILE_H

