1 /* This file is part of Metaproxy.
2 Copyright (C) 2005-2012 Index Data
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
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
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
19 #include "router_chain.hpp"
20 #include <metaproxy/filter.hpp>
24 namespace mp = metaproxy_1;
30 class RouterChain::Rep {
31 friend class RouterChain;
32 friend class RouterChain::Pos;
33 std::list<const filter::Base *> m_filter_list;
35 class RouterChain::Pos : public RoutePos {
37 virtual const filter::Base *move(const char *route);
38 virtual RoutePos *clone();
40 std::list<const filter::Base *>::const_iterator it;
41 mp::RouterChain::Rep *m_p;
45 mp::RouterChain::RouterChain() : m_p(new mp::RouterChain::Rep)
49 mp::RouterChain::~RouterChain()
53 void mp::RouterChain::start()
55 std::list<const filter::Base *>::const_iterator it;
57 for (it = m_p->m_filter_list.begin(); it != m_p->m_filter_list.end(); it++)
61 void mp::RouterChain::stop()
63 std::list<const filter::Base *>::const_iterator it;
65 for (it = m_p->m_filter_list.begin(); it != m_p->m_filter_list.end(); it++)
69 const mp::filter::Base *mp::RouterChain::Pos::move(const char *route)
71 if (it == m_p->m_filter_list.end())
73 const mp::filter::Base *f = *it;
78 mp::RoutePos *mp::RouterChain::createpos() const
80 mp::RouterChain::Pos *p = new mp::RouterChain::Pos;
81 p->it = m_p->m_filter_list.begin();
86 mp::RoutePos *mp::RouterChain::Pos::clone()
88 mp::RouterChain::Pos *p = new mp::RouterChain::Pos;
94 mp::RouterChain::Pos::~Pos()
98 mp::RouterChain & mp::RouterChain::append(const filter::Base &filter)
100 m_p->m_filter_list.push_back(&filter);
108 * c-file-style: "Stroustrup"
109 * indent-tabs-mode: nil
111 * vim: shiftwidth=4 tabstop=8 expandtab