/* 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_INSYNCFILE_H
#define BLINKER_INSYNCFILE_H

#include "File.h"
#include "SyncFile.h"
#include "SyncMgr.h"
#include "SyncRecv.h"

namespace Blinker {

/// setting file containting a name of an input sync stream
class InSyncFile: public SyncFile
{
public:
  /**
   * @brief constructor from path
   * @param[in] path path to file
   * @param[in] syncMgr sync stream manager
   */
  InSyncFile(const std::string &path, SyncMgr &syncMgr);

  /**
   * @brief constructor from basic file
   * @param[in] file basic file object
   * @param[in] syncMgr sync stream manager
   */
  InSyncFile(const File &file, SyncMgr &syncMgr);

  /// destructor
  ~InSyncFile();

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

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

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

public:
  /**
   * @brief set sync stream receiver
   * @param[in] pSyncRecv sync stream reciver (NULL if none)
   */
  void setSyncRecv(SyncRecv *pSyncRecv);

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

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

  /// detach from sync stream
  void detach();

protected:
  SyncRecv *m_pSyncRecv; ///< sync stream receiver to attach to input sync stream
}; // class InSyncFile

} // namespace Blinker

#endif // #ifndef BLINKER_INSYNCFILE_H

