Version 1.0.23. Bump copyright year.
[metaproxy-moved-to-github.git] / src / router_chain.cpp
1 /* This file is part of Metaproxy.
2    Copyright (C) 2005-2010 Index Data
3
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #include "router_chain.hpp"
20
21 #include <list>
22
23 namespace mp = metaproxy_1;
24
25 namespace metaproxy_1
26 {
27     class ChainPos;
28
29     class RouterChain::Rep {
30         friend class RouterChain;
31         friend class RouterChain::Pos;
32         std::list<const filter::Base *> m_filter_list;
33     };
34     class RouterChain::Pos : public RoutePos {
35     public:
36         virtual const filter::Base *move(const char *route);
37         virtual RoutePos *clone();
38         virtual ~Pos();
39         std::list<const filter::Base *>::const_iterator it;
40         mp::RouterChain::Rep *m_p;
41     };
42 }
43
44 mp::RouterChain::RouterChain() : m_p(new mp::RouterChain::Rep)
45 {
46 }
47
48 mp::RouterChain::~RouterChain()
49 {
50 }
51
52 const mp::filter::Base *mp::RouterChain::Pos::move(const char *route)
53 {
54     if (it == m_p->m_filter_list.end())
55         return 0;
56     const mp::filter::Base *f = *it;
57     it++;
58     return f;
59 }
60
61 mp::RoutePos *mp::RouterChain::createpos() const
62 {
63     mp::RouterChain::Pos *p = new mp::RouterChain::Pos;
64     p->it = m_p->m_filter_list.begin();
65     p->m_p = m_p.get();
66     return p;
67 }
68
69 mp::RoutePos *mp::RouterChain::Pos::clone()
70 {
71     mp::RouterChain::Pos *p = new mp::RouterChain::Pos;
72     p->it = it;
73     p->m_p = m_p;
74     return p;
75 }
76
77
78 mp::RouterChain::Pos::~Pos()
79 {
80 }
81
82 mp::RouterChain & mp::RouterChain::append(const filter::Base &filter)
83 {
84     m_p->m_filter_list.push_back(&filter);
85     return *this;
86 }
87
88
89 /*
90  * Local variables:
91  * c-basic-offset: 4
92  * c-file-style: "Stroustrup"
93  * indent-tabs-mode: nil
94  * End:
95  * vim: shiftwidth=4 tabstop=8 expandtab
96  */
97