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.

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