map.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * space_server 任务地图管理。
  3. *
  4. * © 2020 成都河狸智能科技有限责任公司。保留所有权利。
  5. *
  6. * 作者: zhq1229
  7. */
  8. #ifndef __MAP_H__
  9. #define __MAP_H__
  10. #include <map>
  11. #include <list>
  12. #include <string>
  13. using MapId = unsigned int;
  14. namespace task {
  15. namespace map {
  16. struct MapInfo {
  17. MapInfo():
  18. map_id(0),
  19. name(""),
  20. width(0),
  21. height(0),
  22. floor(0),
  23. resolution(0.0f),
  24. map("") {}
  25. MapId map_id;
  26. std::string name;
  27. unsigned int width;
  28. unsigned int height;
  29. int floor;
  30. float resolution;
  31. float x_origin;
  32. float y_origin;
  33. std::string map; // base64打包的地图数据
  34. };
  35. /**
  36. * 读取地图列表
  37. *
  38. * @return 地图列表
  39. */
  40. std::list<MapId> mapList();
  41. /**
  42. * 读取所有地图信息
  43. *
  44. * @return 所有地图信息
  45. */
  46. std::map<MapId, MapInfo> mapInfos();
  47. /**
  48. * 读取地图信息
  49. *
  50. * @param map_id [in] 地图id
  51. * @param map_info [out] 地图信息
  52. * @return 通用错误码
  53. */
  54. int mapInfo(MapId map_id, MapInfo &map_info);
  55. /**
  56. * 读取地图名称
  57. *
  58. * @param map_id [in] 地图id
  59. * @return 地图名称
  60. */
  61. std::string mapName(MapId map_id);
  62. /**
  63. * 保存地图
  64. *
  65. * @param map_info [in] 地图信息
  66. * @return 通用错误码
  67. */
  68. int mapSave(MapInfo &map_info);
  69. /**
  70. * 删除地图
  71. *
  72. * @param map_info [in] 地图id
  73. * @return 通用错误码
  74. */
  75. int mapDelete(MapId map_id);
  76. /**
  77. * 请求map_id,在建图时调用,获取一个唯一的地图编号
  78. *
  79. * @return 0-失败 1~99-地图编号
  80. */
  81. MapId mapReqId();
  82. } // namespace map
  83. } // namespace task
  84. #endif // __MAP_H__