/* 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_SENDERDEST_H
#define BLINKER_SENDERDEST_H

#include <string>

#include "Directory.h"
#include "File.h"
#include "Module.h"
#include "Sender.h"
#include "SettingFile.h"

namespace Blinker {

/// static destination of a stream sender
template<typename ADDR, typename SOCK>
class Sender<ADDR, SOCK>::Dest
{
public:
  /**
   * @brief constructor
   * @param[in] sender owning sender object
   * @param[in] name destination name
   * @param[in] dirBase base directory
   */
  Dest(Sender &sender, const std::string &name, const Directory &dirBase);

  /// destructor
  ~Dest();

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

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

public:
  /// check for update of configuration
  void updateConfig();

  /**
   * @brief set current protocol data
   * @param[in] pData protocol data to send to address (empty if unkown)
   */
  void setProtoData(const std::string *pData);

protected:
  /// (re-)get address
  void getAddr();

  /**
   * @brief send protocol data to address
   * @param[in] pData protocol data to send to address (empty if unknown)
   */
  void send(const std::string *pData);

protected:
  Sender            &m_sender;  ///< owning sender object
  std::string       m_name;     ///< destination name
  AddrFile          m_fileAddr; ///< address file
  const std::string *m_pData;   ///< protocol data to send to address
}; // class Sender<ADDR, SOCK>::Dest

} // namespace Blinker

#endif // #ifndef BLINKER_SENDERDEST_H

