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.

89 lines
1.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __BASICFIFO_H_INCL__
  2. #define __BASICFIFO_H_INCL__
  3. #include <malloc.h>
  4. typedef struct DataPackageFIFO
  5. {
  6. DataPackageFIFO * next;
  7. void * data;
  8. } DataPackageFIFO, *pDataPackageFIFO;
  9. /**
  10. * TODO: Add class description
  11. *
  12. * @author gagua
  13. */
  14. class basicFIFO
  15. {
  16. private:
  17. pDataPackageFIFO head;
  18. pDataPackageFIFO tale;
  19. int nodeCount;
  20. public:
  21. // Constructor
  22. basicFIFO();
  23. // Destructor
  24. virtual ~basicFIFO();
  25. // Copy constructor
  26. // TODO: Uncomment the copy constructor when you need it.
  27. // basicFIFO(const basicFIFO& src);
  28. // Assignment operator
  29. // TODO: Uncomment the assignment operator when you need it.
  30. // basicFIFO& operator=(const basicFIFO& src);
  31. bool pushData(void * buffer);
  32. bool pushNode(pDataPackageFIFO & node);
  33. pDataPackageFIFO popNode(void);
  34. void * popData(void);
  35. int getCount(void)
  36. {
  37. return nodeCount;
  38. }
  39. bool clear(void);
  40. pDataPackageFIFO touch(int index);
  41. bool removeNode(pDataPackageFIFO & node);
  42. };
  43. // Constructor implementation
  44. inline basicFIFO::basicFIFO()
  45. {
  46. head = NULL;
  47. tale = NULL;
  48. }
  49. // Destructor implementation
  50. inline basicFIFO::~basicFIFO()
  51. {
  52. if (head != NULL)
  53. {
  54. clear();
  55. };
  56. }
  57. // TODO: Uncomment the copy constructor when you need it.
  58. // inline basicFIFO::basicFIFO(const basicFIFO& src)
  59. //{
  60. // // TODO: copy
  61. //}
  62. // TODO: Uncomment the assignment operator when you need it.
  63. // inline basicFIFO& basicFIFO::operator=(const basicFIFO& rhs)
  64. //{
  65. // if (this == &rhs) {
  66. // return *this;
  67. // }
  68. //
  69. // // TODO: assignment
  70. //
  71. // return *this;
  72. //}
  73. #endif // __BASICFIFO_H_INCL__