/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     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: sgx/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 tUINT32 size);
	tUINT32	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;
	tUINT32					m_iBufferIdx;
	tUINT32					m_iBufferSize;

	CCommPortDevice	*		m_pDevice;
};


#endif /* SGX_CORE_COMMS_COMPORT_HPP */
