changed call to RouterChain.append instead of RouterChain.rule
authorMarc Cromme <marc@indexdata.dk>
Wed, 26 Oct 2005 10:55:26 +0000 (10:55 +0000)
committerMarc Cromme <marc@indexdata.dk>
Wed, 26 Oct 2005 10:55:26 +0000 (10:55 +0000)
src/Makefile.am
src/ex_filter_frontend_net.cpp
src/router_chain.cpp [new file with mode: 0644]
src/router_chain.hpp
src/test_filter2.cpp
src/test_filter_backend_test.cpp
src/test_filter_frontend_net.cpp
src/test_filter_log.cpp
src/test_filter_virt_db.cpp
src/test_filter_z3950_client.cpp

index 783bf71..ebbc962 100644 (file)
@@ -1,4 +1,4 @@
-## $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
 
@@ -11,7 +11,7 @@ libyp2_la_LDFLAGS = -version-info 0:0:0
 
 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 \
index 55c7919..cace494 100644 (file)
@@ -1,4 +1,4 @@
-/* $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%
@@ -94,29 +94,29 @@ int main(int argc, char **argv)
             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;
diff --git a/src/router_chain.cpp b/src/router_chain.cpp
new file mode 100644 (file)
index 0000000..346028c
--- /dev/null
@@ -0,0 +1,46 @@
+/* $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
+ */
index a965dd0..294222e 100644 (file)
@@ -1,4 +1,4 @@
-/* $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 {
@@ -25,30 +25,10 @@ namespace yp2 {
         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:
index b92d043..9325f05 100644 (file)
@@ -1,4 +1,4 @@
-/* $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%
@@ -130,9 +130,9 @@ BOOST_AUTO_TEST_CASE( testfilter2_1 )
            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;
@@ -147,8 +147,8 @@ BOOST_AUTO_TEST_CASE( testfilter2_1 )
         {
            yp2::RouterChain router2;
            
-           router2.rule(fd);
-           router2.rule(fc);
+           router2.append(fd);
+           router2.append(fc);
            
             yp2::Session session;
             yp2::Origin origin;
index f3db9ee..93903ed 100644 (file)
@@ -1,4 +1,4 @@
-/* $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%
@@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE( test_filter_backend_test_2 )
         yp2::RouterChain router;
         
         yp2::filter::Backend_test btest;
-        router.rule(btest);
+        router.append(btest);
         
         yp2::Package pack;
         
@@ -81,7 +81,7 @@ BOOST_AUTO_TEST_CASE( test_filter_backend_test_3 )
         yp2::RouterChain router;
         
         yp2::filter::Backend_test btest;
-        router.rule(btest);
+        router.append(btest);
         
         yp2::Package pack;
         
@@ -129,7 +129,7 @@ BOOST_AUTO_TEST_CASE( test_filter_backend_test_4 )
         yp2::RouterChain router;
         
         yp2::filter::Backend_test btest;
-        router.rule(btest);
+        router.append(btest);
         
         yp2::Package pack;
         
index 9b36c66..fa6c641 100644 (file)
@@ -1,4 +1,4 @@
-/* $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%
@@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE( test_filter_frontend_net_2 )
 
             FilterInit tf;
 
-           router.rule(tf);
+           router.append(tf);
 
             // Create package with Z39.50 init request in it
            yp2::Package pack;
@@ -112,11 +112,11 @@ BOOST_AUTO_TEST_CASE( test_filter_frontend_net_3 )
             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;
            
index dcafc61..8a7fc66 100644 (file)
@@ -1,4 +1,4 @@
-/* $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%
@@ -65,8 +65,8 @@ BOOST_AUTO_TEST_CASE( test_filter_log_2 )
         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;
index 56e82ed..3c9a3d6 100644 (file)
@@ -1,4 +1,4 @@
-/* $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%
@@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE( test_filter_virt_db_2 )
         
         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
@@ -203,18 +203,18 @@ BOOST_AUTO_TEST_CASE( test_filter_virt_db_3 )
 
         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;
index 4f93e38..37f64a7 100644 (file)
@@ -1,4 +1,4 @@
-/* $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%
@@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE( test_filter_z3950_client_2 )
         
         yp2::filter::Z3950Client zc;
         
-        router.rule(zc);
+        router.append(zc);
         
         // Create package with Z39.50 init request in it
         yp2::Package pack;
@@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE( test_filter_z3950_client_3 )
         
         yp2::filter::Z3950Client zc;
 
-        router.rule(zc);
+        router.append(zc);
         
         // Create package with Z39.50 present request in it
         yp2::Package pack;
@@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE( test_filter_z3950_client_4 )
         
         yp2::filter::Z3950Client zc;
         
-        router.rule(zc);
+        router.append(zc);
         
         // Create package with Z39.50 init request in it
         yp2::Package pack;