//=========================================================================
// Summary  : */
// Filename : DeviceInterface.h
// Author   : */
// Project  : */
// Revision : 1
// Created  : 2000/08/19
// Modified : 2000/08/19
//=========================================================================
// Description :
//=========================================================================
#ifndef _DEVICEINTERFACE_H
#define _DEVICEINTERFACE_H

#include "ourTypes.h"
#include "Semaphore.h"

/*
CLASS 
DeviceInterface

DESCRIPTION
Abstract class for reading and writing to a device.

AUTHOR
Tom O'Reilly

*/
class DeviceInterface {

public:

  ///////////////////////////////////////////////////////////////////
  // Constructor
  DeviceInterface(const char *name);

  virtual ~DeviceInterface();

  ///////////////////////////////////////////////////////////////////
  // Read from device
  virtual int read(char *buf, int maxBytes, int timeout) = 0;

  ///////////////////////////////////////////////////////////////////
  // Write to device
  virtual int write(const char *buf, int nBytes) = 0;

  ///////////////////////////////////////////////////////////////////
  // Reset device
  virtual void reset() = 0;

  ///////////////////////////////////////////////////////////////////
  // Take exclusive access to the device
  void take();

  ///////////////////////////////////////////////////////////////////
  // Release exclusive access to the device
  void release();

  ///////////////////////////////////////////////////////////////////
  // Device name
  const char *name();

  Boolean simulated();

protected:

  Boolean _simulated;

private:

  const char *_name;

  // Pointer to "protection" semaphore
  auvSemaphore *_protectSem;

};


#endif

