demo_log.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  2. //
  3. // demo_log.cpp
  4. //
  5. // (C) Copyright 2009 Robert Ramey - http://www.rrsd.com .
  6. // Use, modification and distribution is subject to the Boost Software
  7. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. #include <iostream>
  10. #include <cstdio>
  11. #include "demo_gps.hpp"
  12. #include "log_archive.hpp"
  13. int main(int argc, char *argv[]){
  14. // make the schedule
  15. bus_schedule schedule;
  16. // fill in the data
  17. // make a few stops
  18. bus_stop *bs0 = new bus_stop_corner(
  19. gps_position(34, 135, 52.560f),
  20. gps_position(134, 22, 78.30f),
  21. "24th Street", "10th Avenue"
  22. );
  23. bus_stop *bs1 = new bus_stop_corner(
  24. gps_position(35, 137, 23.456f),
  25. gps_position(133, 35, 54.12f),
  26. "State street", "Cathedral Vista Lane"
  27. );
  28. bus_stop *bs2 = new bus_stop_destination(
  29. gps_position(35, 136, 15.456f),
  30. gps_position(133, 32, 15.300f),
  31. "White House"
  32. );
  33. bus_stop *bs3 = new bus_stop_destination(
  34. gps_position(35, 134, 48.789f),
  35. gps_position(133, 32, 16.230f),
  36. "Lincoln Memorial"
  37. );
  38. // make a routes
  39. bus_route route0;
  40. route0.append(bs0);
  41. route0.append(bs1);
  42. route0.append(bs2);
  43. // add trips to schedule
  44. schedule.append("bob", 6, 24, &route0);
  45. schedule.append("bob", 9, 57, &route0);
  46. schedule.append("alice", 11, 02, &route0);
  47. // make aother routes
  48. bus_route route1;
  49. route1.append(bs3);
  50. route1.append(bs2);
  51. route1.append(bs1);
  52. // add trips to schedule
  53. schedule.append("ted", 7, 17, &route1);
  54. schedule.append("ted", 9, 38, &route1);
  55. schedule.append("alice", 11, 47, &route1);
  56. // display the complete schedule
  57. log_archive oa(std::cout);
  58. oa << BOOST_SERIALIZATION_NVP(schedule);
  59. oa << schedule;
  60. delete bs0;
  61. delete bs1;
  62. delete bs2;
  63. delete bs3;
  64. return 0;
  65. }