moved RouterChain class out of router.hpp file into own router_chain.hpp class
authorMarc Cromme <marc@indexdata.dk>
Wed, 26 Oct 2005 10:21:03 +0000 (10:21 +0000)
committerMarc Cromme <marc@indexdata.dk>
Wed, 26 Oct 2005 10:21:03 +0000 (10:21 +0000)
src/Makefile.am
src/ex_filter_frontend_net.cpp
src/router.hpp
src/router_chain.hpp [new file with mode: 0644]
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 e85054a..783bf71 100644 (file)
@@ -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 \
index 4622e36..55c7919 100644 (file)
@@ -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"
 
index b0c238a..aae892c 100644 (file)
@@ -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 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;
-        }
-    protected:
-        std::list<const filter::Base *> 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 (file)
index 0000000..a965dd0
--- /dev/null
@@ -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 <stdexcept>
+#include <list>
+
+#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 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;
+        }
+    protected:
+        std::list<const filter::Base *> 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
+ */
index c1d34b2..b92d043 100644 (file)
@@ -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 <iostream>
index a561258..f3db9ee 100644 (file)
@@ -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"
 
index 8af770d..9b36c66 100644 (file)
@@ -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"
 
index 0c2e6d8..dcafc61 100644 (file)
@@ -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"
 
index 4c14649..56e82ed 100644 (file)
@@ -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"
 
index 7090d4c..4f93e38 100644 (file)
@@ -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"