/* 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_SYNC_H
#define BLINKER_SYNC_H

#include <set>
#include <string>

#include "SyncRecv.h"

namespace Blinker {

/// a synchronization information sync stream
class Sync
{
public:
  /// synchronization information
  typedef SyncRecv::Info Info;

protected:
  /// set of receivers of this sync stream
  typedef std::set<SyncRecv *> Recvs;

public:
  /// constructor
  Sync();

  /// destructor
  ~Sync();

public:
  /**
   * @brief attach a sync stream receiver
   * @param[in] recv sync stream receiver to attach
   */
  void attach(SyncRecv *recv);

  /**
   * @brief detach a sync stream receiver
   * @param[in] recv sync stream receiver to detach
   */
  void detach(SyncRecv *recv);

  /**
   * @brief send synchronization information
   * @param[in] pInfo synchronization information
   */
  void sendInfo(Info &info);

protected:
  /// sync stream name
  std::string m_name;
  /// receivers of this sync stream
  Recvs m_recvs;

friend class SyncMgr;
}; // class Sync

} // namespace Blinker

#endif // #ifndef BLINKER_SYNC_H

