demo_simple_log.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 "simple_log_archive.hpp"
  13. int main(int argc, char *argv[])
  14. {
  15. // make the schedule
  16. bus_schedule schedule;
  17. // fill in the data
  18. // make a few stops
  19. bus_stop *bs0 = new bus_stop_corner(
  20. gps_position(34, 135, 52.560f),
  21. gps_position(134, 22, 78.30f),
  22. "24th Street", "10th Avenue"
  23. );
  24. bus_stop *bs1 = new bus_stop_corner(
  25. gps_position(35, 137, 23.456f),
  26. gps_position(133, 35, 54.12f),
  27. "State street", "Cathedral Vista Lane"
  28. );
  29. bus_stop *bs2 = new bus_stop_destination(
  30. gps_position(35, 136, 15.456f),
  31. gps_position(133, 32, 15.300f),
  32. "White House"
  33. );
  34. bus_stop *bs3 = new bus_stop_destination(
  35. gps_position(35, 134, 48.789f),
  36. gps_position(133, 32, 16.230f),
  37. "Lincoln Memorial"
  38. );
  39. // make a routes
  40. bus_route route0;
  41. route0.append(bs0);
  42. route0.append(bs1);
  43. route0.append(bs2);
  44. // add trips to schedule
  45. schedule.append("bob", 6, 24, &route0);
  46. schedule.append("bob", 9, 57, &route0);
  47. schedule.append("alice", 11, 02, &route0);
  48. // make aother routes
  49. bus_route route1;
  50. route1.append(bs3);
  51. route1.append(bs2);
  52. route1.append(bs1);
  53. // add trips to schedule
  54. schedule.append("ted", 7, 17, &route1);
  55. schedule.append("ted", 9, 38, &route1);
  56. schedule.append("alice", 11, 47, &route1);
  57. // display the complete schedule
  58. simple_log_archive log(std::cout);
  59. log << schedule;
  60. delete bs0;
  61. delete bs1;
  62. delete bs2;
  63. delete bs3;
  64. return 0;
  65. }