Router stores filters in a sequence. For now packages just point
[metaproxy-moved-to-github.git] / src / design_main.cpp
1
2 #include <iostream>
3 #include  "design.h"
4
5 int main(int argc, char **argv) {
6
7     // test filter set/get/exception
8     try {
9         std::cout << "\nTRY" << "\n";
10         yp2::Filter filter;
11     
12         filter.name("filter1");
13         std::cout << "filter: " << filter.name() << "\n";
14
15         filter.name() = "filter1 rename";
16         std::cout << "filter: " << filter.name() << "\n";
17
18         throw yp2::Filter_Exception("finished");
19     }
20     catch (std::exception &e) {
21         std::cout << e.what() << "\n";
22     }
23
24   
25     try {
26         std::cout << "\nTRY" << "\n";
27
28         yp2::Filter filter1;
29         filter1.name("filter1");
30     
31         yp2::Filter filter2;
32         filter2.name() = "filter2";
33
34         std::cout << "filter1 filter2" << "\n";
35     
36         yp2::Router router1;
37         router1.rule(filter1);
38         std::cout << "router1.rule(filter1)" << "\n";
39
40         yp2::Router router2;
41         router2.rule(filter2);
42         std::cout << "router2.rule(filter2)" << "\n";
43
44         yp2::Package pack_in;
45         pack_in.data(7).router(router1);
46         std::cout << "pack_in.data(7).router(router1)" << "\n";
47
48         pack_in.move();
49         std::cout << "pack_in.move()" << "\n";
50
51         pack_in.router(router2);
52         std::cout << "pack_in.router(router2)" << "\n";
53
54         pack_in.move();
55         std::cout << "pack_in.move()" << "\n";
56
57         throw  yp2::Router_Exception("finished");
58
59     }
60     catch (std::exception &e) {
61         std::cout << e.what() << "\n";
62     }
63 }
64
65 /*
66  * Local variables:
67  * c-basic-offset: 4
68  * indent-tabs-mode: nil
69  * End:
70  * vim: shiftwidth=4 tabstop=8 expandtab
71  */