From 349c7da1d51fc13c35a03c0be3fd6b2b63af8875 Mon Sep 17 00:00:00 2001 From: Marc Cromme Date: Fri, 28 Oct 2005 10:35:30 +0000 Subject: [PATCH] hacking filter factory, need to go to meeting and stop here, does not work yet --- src/Makefile.am | 6 ++++- src/filter_factory.hpp | 60 +++++++++++++++++++++++++++++++++++++++++++ src/router_flexml.hpp | 6 ++--- src/test_filter_factory.cpp | 56 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 src/filter_factory.hpp create mode 100644 src/test_filter_factory.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 30286b2..527da10 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 index 0000000..0ac8b67 --- /dev/null +++ b/src/filter_factory.hpp @@ -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 +#include +#include +#include + +#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 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 + */ diff --git a/src/router_flexml.hpp b/src/router_flexml.hpp index f3d4e6f..7ef7ddf 100644 --- a/src/router_flexml.hpp +++ b/src/router_flexml.hpp @@ -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 , 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 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 index 0000000..37b2a57 --- /dev/null +++ b/src/test_filter_factory.cpp @@ -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 +#include + +#include "config.hpp" +#include "filter.hpp" +#include "filter_factory.hpp" + + +#define BOOST_AUTO_TEST_MAIN +#include + +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 + */ -- 1.7.10.4