You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __BASIC_TNSPORT_HEADERS__
  2. #define __BASIC_TNSPORT_HEADERS__
  3. #include "basicLogCollection.h"
  4. #include "basicMutex.h"
  5. #include <algorithm>
  6. #include <vector>
  7. #define SERIAL_PING_PONG
  8. #ifdef DEBUG
  9. // #ifndef DUBUG_COMMUNICATION
  10. // #define DUBUG_COMMUNICATION
  11. // #endif
  12. #endif
  13. class protocolParser;
  14. typedef std::vector<protocolParser *> parseQueue;
  15. class basicTransport
  16. {
  17. private:
  18. basicLogCollection * m_pLog;
  19. protected:
  20. parseQueue m_vParsers;
  21. basicMutex m_mQueueProtectorMutex;
  22. basicMutex m_mBufferProtectorMutex;
  23. CONNECTION_STATUS m_eConnectionStatus;
  24. public:
  25. basicTransport();
  26. ~basicTransport();
  27. #ifdef SERIAL_PING_PONG
  28. virtual bool sendData(unsigned char * Data, int DataSize, protocolParser *src = NULL )
  29. #else
  30. virtual bool sendData(unsigned char * Data, int DataSize )
  31. #endif
  32. {
  33. if ( !Data ) return false;
  34. if ( !DataSize ) return false;
  35. return true;
  36. }
  37. virtual bool reconnect(void)
  38. {
  39. return false;
  40. }
  41. bool addRecipient(protocolParser * ProtoParser);
  42. bool removeRecipient(protocolParser * ProtoParser);
  43. bool getStatus(void)
  44. {
  45. return m_eConnectionStatus == CS_CONNECTED;
  46. }
  47. void setConnectionStatus(CONNECTION_STATUS ES);
  48. CONNECTION_STATUS getConnectionStatus(void);
  49. virtual int getRawHandle(void)
  50. {
  51. return -1;
  52. }
  53. };
  54. #endif