/* 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_FILTER_H
#define BLINKER_FILTER_H

#include <string>

#include <BlinkenLib/BlinkenFrame.h>

#include "Directory.h"
#include "File.h"
#include "Format.h"
#include "FormatFile.h"
#include "InStreamFile.h"
#include "Mgrs.h"
#include "Module.h"
#include "OutStreamFile.h"
#include "Size.h"
#include "SizeFile.h"
#include "StreamRecv.h"
#include "UInt.h"
#include "UIntFile.h"

namespace Blinker {

/// a stream resizer
class Filter: public Module, public StreamRecv
{
public:
  /**
   * @brief constructor
   * @param[in] name module name
   * @param[in] mgrs managers
   * @param[in] dirBase base directory
   */
  Filter(const std::string &name, Mgrs &mgrs, const Directory &dirBase);

  /// virtual destructor
  virtual ~Filter();

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

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

public:
  /// check for update of configuration
  virtual 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);

protected:
  /**
   * @brief (re-)get settings that changed
   * @param[in] force if true: (re-)get all settings w/o checking for change
   */
  void getSettingsIfChanged(bool force);

  /// send current frame to output stream
  void sendFrame();

  /**
   * @brief process frame
   * @param[in] pFrame frame to process (NULL for none)
   */
  void procFrame(stBlinkenFrame *pFrame);

protected:
  InStreamFile  m_fileInStream;    ///< input stream name file
  FormatFile    m_fileFormat;      ///< format file
  SizeFile      m_fileSize;        ///< size file
  UIntFile      m_fileWidthMin;    ///< minimum width file
  UIntFile      m_fileWidthMax;    ///< maximum width file
  UIntFile      m_fileHeightMin;   ///< minimum height file
  UIntFile      m_fileHeightMax;   ///< maximum height file
  UIntFile      m_fileChannelsMin; ///< minimum channels file
  UIntFile      m_fileChannelsMax; ///< maximum channels file
  UIntFile      m_fileColorsMin;   ///< minimum colors per channel file
  UIntFile      m_fileColorsMax;   ///< maximum colors per channel file
  OutStreamFile m_fileOutStream;   ///< output stream name file
}; // class Filter

} // namespace Blinker

#endif // #ifndef BLINKER_FILTER_H

