base_data.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef __BASE_DATA__
  2. #define __BASE_DATA__
  3. #include <map>
  4. #include <list>
  5. #include <deque>
  6. #include <vector>
  7. #include "boost\shared_ptr.hpp"
  8. #include "ProcessRemodule.h"
  9. typedef unsigned long long uint64_t;
  10. typedef unsigned short int uint16_t;
  11. struct context
  12. {
  13. };
  14. //--------------------------------
  15. struct point_2
  16. {
  17. double x_;
  18. double y_;
  19. //缺省构造一个系统不会使用的无效坐标
  20. point_2()
  21. :x_(0x12345678)
  22. ,y_(0x87654321)
  23. {
  24. }
  25. point_2(double x,double y)
  26. :x_(x),y_(y)
  27. {}
  28. void setX(double x)
  29. {
  30. x_ = x;
  31. }
  32. void setY(double y)
  33. {
  34. y_ = y;
  35. }
  36. static inline bool is_valid(const point_2&p)
  37. {
  38. const point_2 &pt=invalid_point();
  39. return pt.x_!=p.x_ || pt.y_!=p.y_;
  40. }
  41. static inline const point_2& invalid_point()
  42. {
  43. static const point_2 pt;
  44. return pt;
  45. }
  46. static inline double sqr(double x)
  47. {
  48. return x*x;
  49. }
  50. //计算this到(x,y)的距离
  51. double dist_to(double x,double y)
  52. {
  53. return sqrt(sqr(x-x_)+sqr(y-y_));
  54. }
  55. double dist_to(const point_2&pt)
  56. {
  57. return dist_to(pt.x_,pt.y_);
  58. }
  59. };
  60. struct st_coord :point_2
  61. {
  62. uint64_t gen_time_; //精确到毫秒的测距时间
  63. uint16_t m_ct;//ct
  64. void clear()
  65. {
  66. gen_time_ = 0;
  67. m_ct = 0;
  68. x_ = 0;
  69. y_ = 0;
  70. }
  71. void setTime(uint64_t t)
  72. {
  73. gen_time_ = t;
  74. }
  75. void setCT(uint16_t t)
  76. {
  77. m_ct = t;
  78. }
  79. };
  80. #endif