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