#ifndef __BASIC_TNSPORT_HEADERS__ #define __BASIC_TNSPORT_HEADERS__ #include "basicLogCollection.h" #include "basicMutex.h" #include #include #include #ifdef DEBUG // #ifndef DUBUG_COMMUNICATION // #define DUBUG_COMMUNICATION // #endif #endif #define SERIAL_PING_PONG #ifdef SERIAL_PING_PONG class protocolParser; #endif #ifndef MAXIMAL_SERIAL_IO_BUFFER_LENGTH #define MAXIMAL_SERIAL_IO_BUFFER_LENGTH 102400 #endif typedef struct S_SIO_TZ { bool wReplay; bool finished; bool success; int inp_size; int out_size; #ifdef SERIAL_PING_PONG protocolParser * boundParser; #endif uint8_t out_buffer[MAXIMAL_SERIAL_IO_BUFFER_LENGTH]; uint8_t inp_buffer[MAXIMAL_SERIAL_IO_BUFFER_LENGTH]; } SIO_TZ; typedef std::queue Q_SIO_TZ; class protocolParser; typedef std::vector parseQueue; class basicTransport { private: basicLogCollection * m_pLog; protected: parseQueue m_vParsers; basicMutex m_mQueueProtectorMutex; basicMutex m_mBufferProtectorMutex; CONNECTION_STATUS m_eConnectionStatus; public: basicTransport(); ~basicTransport(); #ifdef SERIAL_PING_PONG virtual bool sendData(unsigned char * Data, int DataSize, protocolParser *src = NULL ) #else virtual bool sendData(unsigned char * Data, int DataSize ) #endif { if ( !Data ) return false; if ( !DataSize ) return false; return true; } virtual bool reconnect(void) { return false; } bool addRecipient(protocolParser * ProtoParser); bool removeRecipient(protocolParser * ProtoParser); bool getStatus(void) { return m_eConnectionStatus == CS_CONNECTED; } void setConnectionStatus(CONNECTION_STATUS ES); CONNECTION_STATUS getConnectionStatus(void); virtual int getRawHandle(void) { return -1; } }; #endif