-## $Id: Makefile.am,v 1.26 2005-10-26 10:21:03 marc Exp $
+## $Id: Makefile.am,v 1.27 2005-10-26 10:55:26 marc Exp $
MAINTAINERCLEANFILES = Makefile.in config.in config.hpp
libyp2_la_SOURCES = \
session.cpp session.hpp package.hpp filter.hpp\
- router.hpp router_chain.hpp \
+ router.hpp router_chain.hpp router_chain.cpp \
thread_pool_observer.cpp thread_pool_observer.hpp \
filter_frontend_net.cpp filter_frontend_net.hpp \
filter_log.cpp filter_log.hpp \
-/* $Id: ex_filter_frontend_net.cpp,v 1.12 2005-10-26 10:21:03 marc Exp $
+/* $Id: ex_filter_frontend_net.cpp,v 1.13 2005-10-26 10:55:26 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
if (vm.count("duration")) {
filter_front.listen_duration() = vm["duration"].as<int>();
}
- router.rule(filter_front);
+ router.append(filter_front);
// put log filter in router
yp2::filter::Log filter_log_front("FRONT");
- router.rule(filter_log_front);
+ router.append(filter_log_front);
// put Virt db filter in router
yp2::filter::Virt_db filter_virt_db;
filter_virt_db.add_map_db2vhost("Default", "indexdata.dk/gils");
filter_virt_db.add_map_db2vhost("Local", "localhost:9999/Default");
- router.rule(filter_virt_db);
+ router.append(filter_virt_db);
yp2::filter::Log filter_log_back("BACK");
- router.rule(filter_log_back);
+ router.append(filter_log_back);
// put HTTP backend filter in router
HTTPFilter filter_init;
- router.rule(filter_init);
+ router.append(filter_init);
// put Z39.50 backend filter in router
yp2::filter::Z3950Client z3950_client;
- router.rule(z3950_client);
+ router.append(z3950_client);
yp2::Session session;
yp2::Origin origin;
--- /dev/null
+/* $Id: router_chain.cpp,v 1.1 2005-10-26 10:55:26 marc Exp $
+ Copyright (c) 2005, Index Data.
+
+%LICENSE%
+ */
+
+
+#include "router_chain.hpp"
+
+
+const yp2::filter::Base * yp2::RouterChain::move(const filter::Base *filter, const Package *package) const {
+ std::list<const filter::Base *>::const_iterator it;
+ it = m_filter_list.begin();
+ if (filter)
+ {
+ for (; it != m_filter_list.end(); it++)
+ if (*it == filter)
+ {
+ it++;
+ break;
+ }
+ }
+ if (it == m_filter_list.end())
+ {
+ //throw RouterException("no routing rules known");
+ return 0;
+ }
+ return *it;
+ };
+
+ yp2::RouterChain & yp2::RouterChain::append(const filter::Base &filter){
+ m_filter_list.push_back(&filter);
+ return *this;
+ };
+
+
+
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * c-file-style: "stroustrup"
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
-/* $Id: router_chain.hpp,v 1.1 2005-10-26 10:21:03 marc Exp $
+/* $Id: router_chain.hpp,v 1.2 2005-10-26 10:55:26 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
namespace yp2 {
- namespace filter {
- class Base;
- }
- class Package;
+ //namespace filter {
+ // class Base;
+ //}
+ //class Package;
class RouterChain : public Router {
RouterChain(){};
virtual ~RouterChain(){};
virtual const filter::Base *move(const filter::Base *filter,
- const Package *package) const {
- std::list<const filter::Base *>::const_iterator it;
- it = m_filter_list.begin();
- if (filter)
- {
- for (; it != m_filter_list.end(); it++)
- if (*it == filter)
- {
- it++;
- break;
- }
- }
- if (it == m_filter_list.end())
- {
- //throw RouterException("no routing rules known");
- return 0;
- }
- return *it;
- };
- virtual void configure(){};
- RouterChain & rule(const filter::Base &filter){
- m_filter_list.push_back(&filter);
- return *this;
- }
+ const Package *package) const;
+
+ RouterChain & append(const filter::Base &filter);
+
protected:
std::list<const filter::Base *> m_filter_list;
private:
-/* $Id: test_filter2.cpp,v 1.12 2005-10-26 10:21:03 marc Exp $
+/* $Id: test_filter2.cpp,v 1.13 2005-10-26 10:55:26 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
yp2::RouterChain router1;
// test filter set/get/exception
- router1.rule(fc);
+ router1.append(fc);
- router1.rule(fd);
+ router1.append(fd);
yp2::Session session;
yp2::Origin origin;
{
yp2::RouterChain router2;
- router2.rule(fd);
- router2.rule(fc);
+ router2.append(fd);
+ router2.append(fc);
yp2::Session session;
yp2::Origin origin;
-/* $Id: test_filter_backend_test.cpp,v 1.2 2005-10-26 10:21:03 marc Exp $
+/* $Id: test_filter_backend_test.cpp,v 1.3 2005-10-26 10:55:26 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
yp2::RouterChain router;
yp2::filter::Backend_test btest;
- router.rule(btest);
+ router.append(btest);
yp2::Package pack;
yp2::RouterChain router;
yp2::filter::Backend_test btest;
- router.rule(btest);
+ router.append(btest);
yp2::Package pack;
yp2::RouterChain router;
yp2::filter::Backend_test btest;
- router.rule(btest);
+ router.append(btest);
yp2::Package pack;
-/* $Id: test_filter_frontend_net.cpp,v 1.9 2005-10-26 10:21:03 marc Exp $
+/* $Id: test_filter_frontend_net.cpp,v 1.10 2005-10-26 10:55:26 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
FilterInit tf;
- router.rule(tf);
+ router.append(tf);
// Create package with Z39.50 init request in it
yp2::Package pack;
ports.insert(ports.begin(), "unix:socket");
filter_front.ports() = ports;
filter_front.listen_duration() = 1; // listen a short time only
- router.rule(filter_front);
+ router.append(filter_front);
// put in a backend
FilterInit filter_init;
- router.rule(filter_init);
+ router.append(filter_init);
yp2::Package pack;
-/* $Id: test_filter_log.cpp,v 1.3 2005-10-26 10:21:03 marc Exp $
+/* $Id: test_filter_log.cpp,v 1.4 2005-10-26 10:55:26 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
yp2::filter::Log lf;
FilterBounceInit bf;
- router.rule(lf);
- router.rule(bf);
+ router.append(lf);
+ router.append(bf);
// Create package with Z39.50 init request in it
yp2::Package pack;
-/* $Id: test_filter_virt_db.cpp,v 1.5 2005-10-26 10:21:03 marc Exp $
+/* $Id: test_filter_virt_db.cpp,v 1.6 2005-10-26 10:55:26 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
yp2::filter::Virt_db vdb;
- router.rule(vdb);
+ router.append(vdb);
// Create package with Z39.50 init request in it
// Since there is not vhost given, the virt will make its
yp2::filter::Log filter_log1("FRONT");
#if 0
- router.rule(filter_log1);
+ router.append(filter_log1);
#endif
yp2::filter::Virt_db vdb;
- router.rule(vdb);
+ router.append(vdb);
vdb.add_map_db2vhost("Default", "localhost:210");
yp2::filter::Log filter_log2("BACK");
#if 0
- router.rule(filter_log2);
+ router.append(filter_log2);
#endif
yp2::filter::Backend_test btest;
- router.rule(btest);
+ router.append(btest);
yp2::Session session1;
yp2::Origin origin1;
-/* $Id: test_filter_z3950_client.cpp,v 1.4 2005-10-26 10:21:03 marc Exp $
+/* $Id: test_filter_z3950_client.cpp,v 1.5 2005-10-26 10:55:26 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
yp2::filter::Z3950Client zc;
- router.rule(zc);
+ router.append(zc);
// Create package with Z39.50 init request in it
yp2::Package pack;
yp2::filter::Z3950Client zc;
- router.rule(zc);
+ router.append(zc);
// Create package with Z39.50 present request in it
yp2::Package pack;
yp2::filter::Z3950Client zc;
- router.rule(zc);
+ router.append(zc);
// Create package with Z39.50 init request in it
yp2::Package pack;