Year 2007.
[metaproxy-moved-to-github.git] / src / router_chain.cpp
1 /* $Id: router_chain.cpp,v 1.8 2007-01-25 14:05:54 adam Exp $
2    Copyright (c) 2005-2007, Index Data.
3    
4       See the LICENSE file for details
5 */
6
7 #include "router_chain.hpp"
8
9 #include <list>
10
11 namespace mp = metaproxy_1;
12
13 namespace metaproxy_1
14 {
15     class ChainPos;
16
17     class RouterChain::Rep {
18         friend class RouterChain;
19         friend class RouterChain::Pos;
20         std::list<const filter::Base *> m_filter_list;
21     };
22     class RouterChain::Pos : public RoutePos {
23     public:
24         virtual const filter::Base *move(const char *route);
25         virtual RoutePos *clone();
26         virtual ~Pos();
27         std::list<const filter::Base *>::const_iterator it;
28         mp::RouterChain::Rep *m_p;
29     };
30 }
31
32 mp::RouterChain::RouterChain() : m_p(new mp::RouterChain::Rep)
33 {
34 }
35
36 mp::RouterChain::~RouterChain()
37 {
38 }
39
40 const mp::filter::Base *mp::RouterChain::Pos::move(const char *route)
41 {
42     if (it == m_p->m_filter_list.end())
43         return 0;
44     const mp::filter::Base *f = *it;
45     it++;
46     return f;
47 }
48
49 mp::RoutePos *mp::RouterChain::createpos() const
50 {
51     mp::RouterChain::Pos *p = new mp::RouterChain::Pos;
52     p->it = m_p->m_filter_list.begin();
53     p->m_p = m_p.get();
54     return p;
55 }
56
57 mp::RoutePos *mp::RouterChain::Pos::clone()
58 {
59     mp::RouterChain::Pos *p = new mp::RouterChain::Pos;
60     p->it = it;
61     p->m_p = m_p;
62     return p;
63 }
64
65
66 mp::RouterChain::Pos::~Pos()
67 {
68 }
69
70 mp::RouterChain & mp::RouterChain::append(const filter::Base &filter)
71 {
72     m_p->m_filter_list.push_back(&filter);
73     return *this;
74 }
75
76
77 /*
78  * Local variables:
79  * c-basic-offset: 4
80  * indent-tabs-mode: nil
81  * c-file-style: "stroustrup"
82  * End:
83  * vim: shiftwidth=4 tabstop=8 expandtab
84  */