/* 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_DEVICE_H
#define BLINKER_DEVICE_H

#include <string>

#include "Io.h"
#include "SerCfg.h"

namespace Blinker {

/// a character device
class Device: public Io
{
public:
  /**
   * @brief constructor
   * @param[in] path path to device
   */
  Device(const std::string &path);

  /// destructor
  ~Device();

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

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

public:
  /**
   * @brief set serial port configuration
   * @param[in] serCfg serial port configuration
   * @return if configuration succeeded
   *
   * This function should only be used if device is a serial port.
   */
  bool setSerCfg(const SerCfg& serCfg);

  /**
   * @brief write data to device
   * @param[in] data data to write
   * @param[out] len number of byte written to device
   * @return if some (or zero) data could be written,
   *         i.e. if the device is still operational
   */
  bool write(const std::string &data, std::string::size_type &len);

}; // class Device

} // namespace Blinker

#endif // #ifndef BLINKER_DEVICE_H


