From d7b1186d1f020678b617e2368415485bffef93f9 Mon Sep 17 00:00:00 2001 From: Marc Cromme Date: Wed, 26 Oct 2005 10:21:03 +0000 Subject: [PATCH] moved RouterChain class out of router.hpp file into own router_chain.hpp class --- src/Makefile.am | 5 +-- src/ex_filter_frontend_net.cpp | 4 +-- src/router.hpp | 52 ++++----------------------- src/router_chain.hpp | 74 ++++++++++++++++++++++++++++++++++++++ src/test_filter2.cpp | 4 +-- src/test_filter_backend_test.cpp | 4 +-- src/test_filter_frontend_net.cpp | 4 +-- src/test_filter_log.cpp | 4 +-- src/test_filter_virt_db.cpp | 4 +-- src/test_filter_z3950_client.cpp | 4 +-- 10 files changed, 97 insertions(+), 62 deletions(-) create mode 100644 src/router_chain.hpp diff --git a/src/Makefile.am b/src/Makefile.am index e85054a..783bf71 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.25 2005-10-25 21:32:01 adam Exp $ +## $Id: Makefile.am,v 1.26 2005-10-26 10:21:03 marc Exp $ MAINTAINERCLEANFILES = Makefile.in config.in config.hpp @@ -10,7 +10,8 @@ lib_LTLIBRARIES = libyp2.la libyp2_la_LDFLAGS = -version-info 0:0:0 libyp2_la_SOURCES = \ - session.cpp session.hpp package.hpp filter.hpp router.hpp \ + session.cpp session.hpp package.hpp filter.hpp\ + router.hpp router_chain.hpp \ thread_pool_observer.cpp thread_pool_observer.hpp \ filter_frontend_net.cpp filter_frontend_net.hpp \ filter_log.cpp filter_log.hpp \ diff --git a/src/ex_filter_frontend_net.cpp b/src/ex_filter_frontend_net.cpp index 4622e36..55c7919 100644 --- a/src/ex_filter_frontend_net.cpp +++ b/src/ex_filter_frontend_net.cpp @@ -1,4 +1,4 @@ -/* $Id: ex_filter_frontend_net.cpp,v 1.11 2005-10-25 22:44:39 adam Exp $ +/* $Id: ex_filter_frontend_net.cpp,v 1.12 2005-10-26 10:21:03 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -18,7 +18,7 @@ namespace po = boost::program_options; #include "filter_virt_db.hpp" #include "filter_log.hpp" -#include "router.hpp" +#include "router_chain.hpp" #include "session.hpp" #include "package.hpp" diff --git a/src/router.hpp b/src/router.hpp index b0c238a..aae892c 100644 --- a/src/router.hpp +++ b/src/router.hpp @@ -1,4 +1,4 @@ -/* $Id: router.hpp,v 1.3 2005-10-15 14:09:09 adam Exp $ +/* $Id: router.hpp,v 1.4 2005-10-26 10:21:03 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -35,12 +35,12 @@ namespace yp2 { }; /// re-read configuration of routing tables - virtual void configure(){}; + //virtual void configure(){}; /// add routing rule expressed as Filter to Router - virtual Router & rule(const filter::Base &filter){ - return *this; - } + //virtual Router & rule(const filter::Base &filter){ + // return *this; + //} private: /// disabled because class is singleton Router(const Router &); @@ -49,47 +49,7 @@ namespace yp2 { Router& operator=(const Router &); }; - - class RouterChain : public Router { - public: - RouterChain(){}; - virtual ~RouterChain(){}; - virtual const filter::Base *move(const filter::Base *filter, - const Package *package) const { - std::list::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; - } - protected: - std::list m_filter_list; - private: - /// disabled because class is singleton - RouterChain(const RouterChain &); - - /// disabled because class is singleton - RouterChain& operator=(const RouterChain &); - }; - - + } diff --git a/src/router_chain.hpp b/src/router_chain.hpp new file mode 100644 index 0000000..a965dd0 --- /dev/null +++ b/src/router_chain.hpp @@ -0,0 +1,74 @@ +/* $Id: router_chain.hpp,v 1.1 2005-10-26 10:21:03 marc Exp $ + Copyright (c) 2005, Index Data. + +%LICENSE% + */ + +#ifndef ROUTER_CHAIN_HPP +#define ROUTER_CHAIN_HPP + +#include +#include + +#include "router.hpp" + + +namespace yp2 { + namespace filter { + class Base; + } + class Package; + + + class RouterChain : public Router { + public: + RouterChain(){}; + virtual ~RouterChain(){}; + virtual const filter::Base *move(const filter::Base *filter, + const Package *package) const { + std::list::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; + } + protected: + std::list m_filter_list; + private: + /// disabled because class is singleton + RouterChain(const RouterChain &); + + /// disabled because class is singleton + RouterChain& operator=(const RouterChain &); + }; + + + +} + +#endif +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * c-file-style: "stroustrup" + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ diff --git a/src/test_filter2.cpp b/src/test_filter2.cpp index c1d34b2..b92d043 100644 --- a/src/test_filter2.cpp +++ b/src/test_filter2.cpp @@ -1,4 +1,4 @@ -/* $Id: test_filter2.cpp,v 1.11 2005-10-24 10:16:33 adam Exp $ +/* $Id: test_filter2.cpp,v 1.12 2005-10-26 10:21:03 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -9,7 +9,7 @@ #include "config.hpp" #include "filter.hpp" -#include "router.hpp" +#include "router_chain.hpp" #include "package.hpp" #include diff --git a/src/test_filter_backend_test.cpp b/src/test_filter_backend_test.cpp index a561258..f3db9ee 100644 --- a/src/test_filter_backend_test.cpp +++ b/src/test_filter_backend_test.cpp @@ -1,4 +1,4 @@ -/* $Id: test_filter_backend_test.cpp,v 1.1 2005-10-25 21:32:28 adam Exp $ +/* $Id: test_filter_backend_test.cpp,v 1.2 2005-10-26 10:21:03 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -12,7 +12,7 @@ #include "filter_backend_test.hpp" #include "filter_log.hpp" -#include "router.hpp" +#include "router_chain.hpp" #include "session.hpp" #include "package.hpp" diff --git a/src/test_filter_frontend_net.cpp b/src/test_filter_frontend_net.cpp index 8af770d..9b36c66 100644 --- a/src/test_filter_frontend_net.cpp +++ b/src/test_filter_frontend_net.cpp @@ -1,4 +1,4 @@ -/* $Id: test_filter_frontend_net.cpp,v 1.8 2005-10-16 16:05:44 adam Exp $ +/* $Id: test_filter_frontend_net.cpp,v 1.9 2005-10-26 10:21:03 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -10,7 +10,7 @@ #include "filter_frontend_net.hpp" -#include "router.hpp" +#include "router_chain.hpp" #include "session.hpp" #include "package.hpp" diff --git a/src/test_filter_log.cpp b/src/test_filter_log.cpp index 0c2e6d8..dcafc61 100644 --- a/src/test_filter_log.cpp +++ b/src/test_filter_log.cpp @@ -1,4 +1,4 @@ -/* $Id: test_filter_log.cpp,v 1.2 2005-10-25 11:48:30 adam Exp $ +/* $Id: test_filter_log.cpp,v 1.3 2005-10-26 10:21:03 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -10,7 +10,7 @@ #include "filter_log.hpp" -#include "router.hpp" +#include "router_chain.hpp" #include "session.hpp" #include "package.hpp" diff --git a/src/test_filter_virt_db.cpp b/src/test_filter_virt_db.cpp index 4c14649..56e82ed 100644 --- a/src/test_filter_virt_db.cpp +++ b/src/test_filter_virt_db.cpp @@ -1,4 +1,4 @@ -/* $Id: test_filter_virt_db.cpp,v 1.4 2005-10-25 21:32:01 adam Exp $ +/* $Id: test_filter_virt_db.cpp,v 1.5 2005-10-26 10:21:03 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -13,7 +13,7 @@ #include "filter_backend_test.hpp" #include "filter_log.hpp" -#include "router.hpp" +#include "router_chain.hpp" #include "session.hpp" #include "package.hpp" diff --git a/src/test_filter_z3950_client.cpp b/src/test_filter_z3950_client.cpp index 7090d4c..4f93e38 100644 --- a/src/test_filter_z3950_client.cpp +++ b/src/test_filter_z3950_client.cpp @@ -1,4 +1,4 @@ -/* $Id: test_filter_z3950_client.cpp,v 1.3 2005-10-24 14:33:30 adam Exp $ +/* $Id: test_filter_z3950_client.cpp,v 1.4 2005-10-26 10:21:03 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -10,7 +10,7 @@ #include "filter_z3950_client.hpp" -#include "router.hpp" +#include "router_chain.hpp" #include "session.hpp" #include "package.hpp" -- 1.7.10.4