/* 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_OPSPLITTEREXTENSION_H
#define BLINKER_OPSPLITTEREXTENSION_H

#include <string>

#include "Directory.h"
#include "Module.h"
#include "NameFile.h"
#include "OpSplitter.h"

namespace Blinker {

/// extension of operator connection splitter
class OpSplitter::Extension
{
public:
  /**
   * @brief constructor
   * @param[in] opSplitter owning operator connection splitter object
   * @param[in] name extension name (i.e. number)
   * @param[in] dirBase base directory
   */
  Extension(OpSplitter &opSplitter, const std::string &name,
            const Directory &dirBase);

  /// destructor
  ~Extension();

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

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

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

protected:
  /// (re-)get target operator interface to connect to
  void getTarget();

  /**
   * @brief convert extension name to extension number
   * @param[in] name extension name
   * @param[out] number extension number (name without all non-digits)
   */
  static void name2number(const std::string &name, std::string &number);

protected:
  OpSplitter  &m_opSplitter; ///< owning operator connection splitter object
  std::string m_name;        ///< extension name (i.e. number)
  NameFile    m_fileTarget;  ///< target operator interface name to connect to
  std::string m_number;      ///< number of extension
  bool        m_addedToMap;  ///< if extension number could be added to map
}; // class OpSplitter::Extension

} // namespace Blinker

#endif // #ifndef BLINKER_OPSPLITTEREXTENSION_H

