/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: include/sgx/core/comms/commsport.hpp

*/

#ifndef SGX_CORE_COMMS_COMPORT_HPP
#define SGX_CORE_COMMS_COMPORT_HPP	1

class CCommsPort {
public:

	CCommsPort(const CCommPortSettings &settings);
	~CCommsPort();

	tBOOL	open();
	tBOOL	isOpen();
	void	setBufferSize(tMEM_SIZE size);
	tBOOL	write(const int i);
	tBOOL	write(const sgxString s);
	tBOOL	write(const tBYTE *pData, const int size);
	int		getReadySize();
	tBOOL	isReady();
	tBOOL	read(tBYTE &c);
	tBOOL	read(int &i);
	tBOOL	read(sgxString &s);
	tBOOL	read(tBYTE *pData, int maxSixe);
	tBOOL	close();

	void	update();

protected:
	CCommPortSettings		m_Settings;
	tBYTE					*m_pBuffer;
	int						m_iBufferIdx;
	int						m_iBufferSize;

	CCommPortDevice			*m_pDevice;
};


#endif /* SGX_CORE_COMMS_COMPORT_HPP */
