hacking filter factory, need to go to meeting and stop here, does not work yet
authorMarc Cromme <marc@indexdata.dk>
Fri, 28 Oct 2005 10:35:30 +0000 (10:35 +0000)
committerMarc Cromme <marc@indexdata.dk>
Fri, 28 Oct 2005 10:35:30 +0000 (10:35 +0000)
src/Makefile.am
src/filter_factory.hpp [new file with mode: 0644]
src/router_flexml.hpp
src/test_filter_factory.cpp [new file with mode: 0644]

index 30286b2..527da10 100644 (file)
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.29 2005-10-26 18:53:49 adam Exp $
+## $Id: Makefile.am,v 1.30 2005-10-28 10:35:30 marc Exp $
 
 MAINTAINERCLEANFILES = Makefile.in config.in config.hpp
 
@@ -14,6 +14,7 @@ libyp2_la_SOURCES = \
        router.hpp router_chain.hpp router_chain.cpp \
         router_flexml.hpp router_flexml.cpp \
        thread_pool_observer.cpp thread_pool_observer.hpp \
+       filter_factory.hpp \
        filter_frontend_net.cpp filter_frontend_net.hpp \
        filter_log.cpp filter_log.hpp \
        filter_virt_db.cpp filter_virt_db.hpp \
@@ -39,6 +40,7 @@ check_PROGRAMS = \
        test_session1 test_session2 \
        test_thread_pool_observer \
        test_boost_threads test_boost_time \
+       test_filter_factory \
        test_filter_frontend_net \
        test_filter_log \
        test_filter_z3950_client \
@@ -57,6 +59,7 @@ test_session2_SOURCES=test_session2.cpp
 test_boost_threads_SOURCES=test_boost_threads.cpp
 test_boost_time_SOURCES=test_boost_time.cpp
 test_thread_pool_observer_SOURCES = test_thread_pool_observer.cpp
+test_filter_factory_SOURCES = test_filter_factory.cpp
 test_filter_frontend_net_SOURCES = test_filter_frontend_net.cpp
 test_filter_log_SOURCES = test_filter_log.cpp
 test_filter_z3950_client_SOURCES = test_filter_z3950_client.cpp
@@ -75,6 +78,7 @@ test_boost_threads_LDADD = $(TESTLDADD)
 test_boost_time_LDADD = $(TESTLDADD)
 test_thread_pool_observer_LDADD = $(TESTLDADD)
 test_package1_LDADD = $(TESTLDADD)
+test_filter_factory_LDADD = $(TESTLDADD)
 test_filter_frontend_net_LDADD = $(TESTLDADD)
 test_filter_log_LDADD = $(TESTLDADD)
 test_filter_z3950_client_LDADD = $(TESTLDADD)
diff --git a/src/filter_factory.hpp b/src/filter_factory.hpp
new file mode 100644 (file)
index 0000000..0ac8b67
--- /dev/null
@@ -0,0 +1,60 @@
+/* $Id: filter_factory.hpp,v 1.1 2005-10-28 10:35:30 marc Exp $
+   Copyright (c) 2005, Index Data.
+
+%LICENSE%
+ */
+
+#ifndef FILTER_FACTORY_HPP
+#define FILTER_FACTORY_HPP
+
+#include <stdexcept>
+#include <iostream>
+#include <string>
+#include <map>
+
+#include "config.hpp"
+#include "filter.hpp"
+
+
+namespace yp2 {
+
+    namespace filter {
+        class FilterFactory {
+
+#if 0
+        public:
+            typedef yp2::filter::Base* (*CreateFilterCallback)();
+            /// true if registration ok
+            bool register_filter(std::string fi, CreateFilterCallback cfc);
+            /// true if unregistration ok
+            bool unregister_filter(std::string fi);
+            /// factory create method
+            yp2::filter::Base* create(std::string fi);
+            
+        private:
+            typedef std::map<std::string, CreateFilterCallback> CallbackMap;
+
+#endif      
+
+        };
+    }
+    
+    class FilterFactoryException : public std::runtime_error {
+    public:
+        FilterFactoryException(const std::string message)
+            : std::runtime_error("FilterException: " + message){
+        };
+    };
+
+  
+}
+
+#endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * c-file-style: "stroustrup"
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
index f3d4e6f..7ef7ddf 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: router_flexml.hpp,v 1.3 2005-10-27 11:36:21 marc Exp $
+/* $Id: router_flexml.hpp,v 1.4 2005-10-28 10:35:30 marc Exp $
    Copyright (c) 2005, Index Data.
 
    %LICENSE%
@@ -142,7 +142,7 @@ namespace yp2
                 if (std::string((const char *)node2->name) 
                     !=  "filter")
                     xml_dom_error(root, "expected  <filter>, got ");
-
+#if 0
                 while(node2 && std::string((const char *)node2->name) ==  "filter"){
                     std::cout << "processing /yp2/filters/filter" << std::endl;
                     for (; node2 && node2->type != XML_ELEMENT_NODE; node2 = node2->next)
@@ -150,7 +150,7 @@ namespace yp2
                     if(node2->type != XML_ELEMENT_NODE)
                         break;
                     }
-
+#endif
                 // process <routes> node which is expected third element node
                 node = node->next;
                 for (; node && node->type != XML_ELEMENT_NODE; node = node->next)
diff --git a/src/test_filter_factory.cpp b/src/test_filter_factory.cpp
new file mode 100644 (file)
index 0000000..37b2a57
--- /dev/null
@@ -0,0 +1,56 @@
+/* $Id: test_filter_factory.cpp,v 1.1 2005-10-28 10:35:30 marc Exp $
+   Copyright (c) 2005, Index Data.
+
+%LICENSE%
+ */
+
+
+#include <iostream>
+#include <stdexcept>
+
+#include "config.hpp"
+#include "filter.hpp"
+#include "filter_factory.hpp"
+
+
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>
+
+using namespace boost::unit_test;
+
+class XFilter: public yp2::filter::Base {
+public:
+    void process(yp2::Package & package) const {};
+};
+
+class YFilter: public yp2::filter::Base {
+public:
+    void process(yp2::Package & package) const {};
+};
+    
+
+BOOST_AUTO_TEST_CASE( test_router_flexml_1 )
+{
+    try{
+        
+        yp2::filter::FilterFactory  ffactory;
+        
+
+        BOOST_CHECK (true);
+
+        //BOOST_CHECK_EQUAL(filter.name(), std::string("filter1"));
+        
+    }
+    catch ( ... ) {
+        BOOST_CHECK (false);
+    }
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * c-file-style: "stroustrup"
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */