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

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

namespace Blinker {

/**
 * @brief constructor from path
 * @param[in] path path to file
 * @param[in] syncMgr sync stream manager
 */
OutSyncFile::OutSyncFile(const std::string &path, SyncMgr &syncMgr):
  SyncFile(path, syncMgr)
{
  update();
}

/**
 * @brief constructor from basic file
 * @param[in] file basic file object
 * @param[in] syncMgr sync stream manager
 */
OutSyncFile::OutSyncFile(const File &file, SyncMgr &syncMgr):
  SyncFile(file, syncMgr)
{
  update();
}

/// destructor
OutSyncFile::~OutSyncFile()
{
  // unreferencing sync stream happens in destructor of SyncFile
}

/**
 * @brief assignment operator
 * @param[in] file basic file object
 */
const OutSyncFile & OutSyncFile::operator=(const File &file)
{
  SyncFile::operator=(file);
  return *this;
}

/// update, i.e. (re-)read file and reference new sync stream
void OutSyncFile::update()
{
  SyncFile::update();
}

/**
 * @brief send synchronization information
 * @param[in] pInfo synchronization information
 */
void OutSyncFile::sendInfo(SyncRecv::Info &info)
{
  if (m_pSync)
    m_pSync->sendInfo(info);
}

} // namespace Blinker

