/* 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_SYNCNAMESPLITTER_H
#define BLINKER_SYNCNAMESPLITTER_H

#include <string>

#include "File.h"
#include "InSyncFile.h"
#include "Mgrs.h"
#include "Module.h"
#include "NameFile.h"
#include "OutSyncFile.h"
#include "SyncRecv.h"
#include "UIntFile.h"

namespace Blinker {

/// a synchronization name splitter
class SyncNameSplitter: public Module, public SyncRecv
{
public:
  /**
   * @brief constructor
   * @param[in] name module name
   * @param[in] mgrs managers
   * @param[in] dirBase base directory
   */
  SyncNameSplitter(const std::string &name, Mgrs &mgrs, const Directory &dirBase);

  /// virtual destructor
  virtual ~SyncNameSplitter();

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

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

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

  /**
   * @brief send synchronization information
   * @param[in] sync sync stream name
   * @param[in] pInfo synchronization information
   */
  virtual void sendInfo(const std::string &sync, Info &info);

protected:
  InSyncFile  m_fileInSync;    ///< input sync stream
  NameFile    m_fileDelimiter; ///< delimiter string for splitting
  UIntFile    m_fileFieldNo;   ///< number of field from name to pass on
  OutSyncFile m_fileOutSync;   ///< output sync stream name file
}; // class SyncNameSplitter

} // namespace Blinker

#endif // #ifndef BLINKER_SYNCNAMESPLITTER_H

