/* 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 <set>

#include "Sync.h"
#include "SyncRecv.h"

namespace Blinker {

/// constructor
Sync::Sync()
{
}

/// destructor
Sync::~Sync()
{
}

/**
 * @brief attach a sync stream receiver
 * @param[in] recv sync stream receiver to attach
 */
void Sync::attach(SyncRecv *recv)
{
  m_recvs.insert(recv);
}

/**
 * @brief detach a sync stream receiver
 * @param[in] recv sync stream receiver to detach
 */
void Sync::detach(SyncRecv *recv)
{
  m_recvs.erase(recv);
}

/**
 * @brief send synchronization information
 * @param[in] pInfo synchronization information
 */
void Sync::sendInfo(Info &info)
{
  // pass sync information to all receivers
  Recvs::iterator it;
  for (it = m_recvs.begin(); it != m_recvs.end(); ++it)
    (*it)->sendInfo(m_name, info);
}

} // namespace Blinker

