From: Marc Cromme Date: Mon, 31 Oct 2005 09:40:18 +0000 (+0000) Subject: std::string type() function taken out of all filter classes again X-Git-Tag: YP2.0.0.2~158 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=474111be67deb87130a5f0add13df89c89df346a;p=metaproxy-moved-to-github.git std::string type() function taken out of all filter classes again --- diff --git a/src/ex_filter_frontend_net.cpp b/src/ex_filter_frontend_net.cpp index fbe608b..3edde7b 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.16 2005-10-30 17:13:36 adam Exp $ +/* $Id: ex_filter_frontend_net.cpp,v 1.17 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -49,9 +49,6 @@ public: } return package.move(); }; - const std::string type() const { - return "HTTPFilter"; - }; }; int main(int argc, char **argv) diff --git a/src/filter.cpp b/src/filter.cpp index 14f6e37..1b5ef43 100644 --- a/src/filter.cpp +++ b/src/filter.cpp @@ -1,4 +1,4 @@ -/* $Id: filter.cpp,v 1.1 2005-10-29 22:23:36 marc Exp $ +/* $Id: filter.cpp,v 1.2 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -10,7 +10,6 @@ // defining and initializing static members - // std::string yp2::filter::Base:m_type("Base"); diff --git a/src/filter.hpp b/src/filter.hpp index b71e85f..92a2392 100644 --- a/src/filter.hpp +++ b/src/filter.hpp @@ -1,4 +1,4 @@ -/* $Id: filter.hpp,v 1.7 2005-10-29 22:23:36 marc Exp $ +/* $Id: filter.hpp,v 1.8 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -23,19 +23,21 @@ namespace yp2 { virtual void process(Package & package) const = 0; virtual void configure(const xmlNode * ptr = 0) { }; - - - virtual const std::string type() const = 0; }; - } - - class FilterException : public std::runtime_error { - public: - FilterException(const std::string message) - : std::runtime_error("FilterException: " + message){ + + struct Creator { + const char* type; + yp2::filter::Base* (*creator)(); }; - }; + class FilterException : public std::runtime_error { + public: + FilterException(const std::string message) + : std::runtime_error("FilterException: " + message){ + }; + }; + + } } diff --git a/src/filter_backend_test.hpp b/src/filter_backend_test.hpp index 6442d43..66afcee 100644 --- a/src/filter_backend_test.hpp +++ b/src/filter_backend_test.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_backend_test.hpp,v 1.3 2005-10-29 22:23:36 marc Exp $ +/* $Id: filter_backend_test.hpp,v 1.4 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -21,9 +21,6 @@ namespace yp2 { ~Backend_test(); Backend_test(); void process(yp2::Package & package) const; - const std::string type() const { - return "Backend_test"; - }; private: boost::scoped_ptr m_p; }; diff --git a/src/filter_factory.hpp b/src/filter_factory.hpp index 8c10bed..7ad4e19 100644 --- a/src/filter_factory.hpp +++ b/src/filter_factory.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_factory.hpp,v 1.3 2005-10-29 22:51:11 marc Exp $ +/* $Id: filter_factory.hpp,v 1.4 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -19,9 +19,6 @@ namespace yp2 { namespace filter { - - - class FilterFactoryException : public std::runtime_error { public: diff --git a/src/filter_frontend_net.hpp b/src/filter_frontend_net.hpp index 2a68a91..31becaa 100644 --- a/src/filter_frontend_net.hpp +++ b/src/filter_frontend_net.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_frontend_net.hpp,v 1.6 2005-10-29 22:23:36 marc Exp $ +/* $Id: filter_frontend_net.hpp,v 1.7 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -18,9 +18,6 @@ namespace yp2 { public: FrontendNet::FrontendNet(); void process(yp2::Package & package) const; - const std::string type() const { - return "FrontendNet"; - }; private: int m_no_threads; std::vector m_ports; diff --git a/src/filter_log.hpp b/src/filter_log.hpp index 58cb266..d7ad4ed 100644 --- a/src/filter_log.hpp +++ b/src/filter_log.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_log.hpp,v 1.8 2005-10-29 22:23:36 marc Exp $ +/* $Id: filter_log.hpp,v 1.9 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -22,9 +22,6 @@ namespace yp2 { Log(const std::string &msg); Log(); void process(yp2::Package & package) const; - const std::string type() const { - return "Log"; - }; private: /// static mutex to lock Ostream during logging operation static boost::mutex m_log_mutex; diff --git a/src/filter_virt_db.hpp b/src/filter_virt_db.hpp index e33b74e..8c514f6 100644 --- a/src/filter_virt_db.hpp +++ b/src/filter_virt_db.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_virt_db.hpp,v 1.3 2005-10-29 22:23:36 marc Exp $ +/* $Id: filter_virt_db.hpp,v 1.4 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -21,9 +21,6 @@ namespace yp2 { ~Virt_db(); Virt_db(); void process(yp2::Package & package) const; - const std::string type() const { - return "Virt_db"; - }; void add_map_db2vhost(std::string db, std::string vhost); private: boost::scoped_ptr m_p; diff --git a/src/filter_z3950_client.hpp b/src/filter_z3950_client.hpp index b55dd37..81633ad 100644 --- a/src/filter_z3950_client.hpp +++ b/src/filter_z3950_client.hpp @@ -1,4 +1,4 @@ -/* $Id: filter_z3950_client.hpp,v 1.3 2005-10-29 22:23:36 marc Exp $ +/* $Id: filter_z3950_client.hpp,v 1.4 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -22,9 +22,6 @@ namespace yp2 { ~Z3950Client(); Z3950Client(); void process(yp2::Package & package) const; - const std::string type() const { - return "Z3950Client"; - }; private: boost::scoped_ptr m_p; }; diff --git a/src/test_filter1.cpp b/src/test_filter1.cpp index 1c3ff81..91912ea 100644 --- a/src/test_filter1.cpp +++ b/src/test_filter1.cpp @@ -1,4 +1,4 @@ -/* $Id: test_filter1.cpp,v 1.12 2005-10-29 22:23:36 marc Exp $ +/* $Id: test_filter1.cpp,v 1.13 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -18,9 +18,6 @@ using namespace boost::unit_test; class TFilter: public yp2::filter::Base { public: void process(yp2::Package & package) const {}; - const std::string type() const { - return "TFilter"; - }; }; @@ -30,7 +27,7 @@ BOOST_AUTO_TEST_CASE( test_filter1 ) TFilter filter; - BOOST_CHECK (filter.type() == "TFilter"); + BOOST_CHECK (sizeof(filter) > 0); } catch ( ... ) { BOOST_CHECK (false); diff --git a/src/test_filter2.cpp b/src/test_filter2.cpp index 14aa299..c6295b8 100644 --- a/src/test_filter2.cpp +++ b/src/test_filter2.cpp @@ -1,4 +1,4 @@ -/* $Id: test_filter2.cpp,v 1.14 2005-10-29 22:23:36 marc Exp $ +/* $Id: test_filter2.cpp,v 1.15 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -27,9 +27,6 @@ public: package.data() = m_constant; package.move(); }; - const std::string type() const { - return "FilterConstant"; - }; void configure(const xmlNode* ptr = 0); int get_constant() const { return m_constant; }; private: @@ -118,9 +115,6 @@ public: package.data() = package.data() * 2; package.move(); }; - const std::string type() const { - return "FilterConstant"; - }; }; diff --git a/src/test_filter_factory.cpp b/src/test_filter_factory.cpp index 3b982f1..a426867 100644 --- a/src/test_filter_factory.cpp +++ b/src/test_filter_factory.cpp @@ -1,4 +1,4 @@ -/* $Id: test_filter_factory.cpp,v 1.3 2005-10-29 22:23:36 marc Exp $ +/* $Id: test_filter_factory.cpp,v 1.4 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -22,9 +22,6 @@ using namespace boost::unit_test; class XFilter: public yp2::filter::Base { public: void process(yp2::Package & package) const {}; - const std::string type() const{ - return "XFilter"; - }; }; @@ -35,9 +32,6 @@ yp2::filter::Base* xfilter_creator(){ class YFilter: public yp2::filter::Base { public: void process(yp2::Package & package) const {}; - const std::string type() const{ - return "YFilter"; - }; }; yp2::filter::Base* yfilter_creator(){ @@ -56,8 +50,8 @@ BOOST_AUTO_TEST_CASE( test_filter_factory_1 ) XFilter xf; YFilter yf; - const std::string xfid = xf.type(); - const std::string yfid = yf.type(); + const std::string xfid = "XFilter"; + const std::string yfid = "YFilter"; //std::cout << "Xfilter name: " << xfid << std::endl; //std::cout << "Yfilter name: " << yfid << std::endl; @@ -71,15 +65,16 @@ BOOST_AUTO_TEST_CASE( test_filter_factory_1 ) BOOST_CHECK_EQUAL(ffactory.add_creator(yfid, yfilter_creator), true); - yp2::filter::Base* xfilter = ffactory.create(xfid); - yp2::filter::Base* yfilter = ffactory.create(yfid); + yp2::filter::Base* xfilter = 0; + xfilter = ffactory.create(xfid); + yp2::filter::Base* yfilter = 0; + yfilter = ffactory.create(yfid); - BOOST_CHECK_EQUAL(xf.type(), xfilter->type()); - BOOST_CHECK_EQUAL(yf.type(), yfilter->type()); + //BOOST_CHECK_EQUAL(sizeof(xf), sizeof(*xfilter)); + //BOOST_CHECK_EQUAL(sizeof(yf), sizeof(*yfilter)); - //std::cout << "Xfilter pointer name: " << xfilter->type() << std::endl; - //std::cout << "Yfilter pointer name: " << yfilter->type() << std::endl; - + BOOST_CHECK(0 != xfilter); + BOOST_CHECK(0 != yfilter); } catch ( ... ) { diff --git a/src/test_filter_frontend_net.cpp b/src/test_filter_frontend_net.cpp index ce53512..2eb88b8 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.12 2005-10-30 17:13:36 adam Exp $ +/* $Id: test_filter_frontend_net.cpp,v 1.13 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -42,9 +42,6 @@ public: } return package.move(); }; - const std::string type() const { - return "FilterInit"; - }; }; diff --git a/src/test_filter_log.cpp b/src/test_filter_log.cpp index b449417..d896995 100644 --- a/src/test_filter_log.cpp +++ b/src/test_filter_log.cpp @@ -1,4 +1,4 @@ -/* $Id: test_filter_log.cpp,v 1.6 2005-10-30 17:13:36 adam Exp $ +/* $Id: test_filter_log.cpp,v 1.7 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -41,9 +41,6 @@ public: } return package.move(); }; - const std::string type() const { - return "FilterBounceInit"; - }; }; diff --git a/src/test_router_flexml.cpp b/src/test_router_flexml.cpp index 2aac9e5..c082be3 100644 --- a/src/test_router_flexml.cpp +++ b/src/test_router_flexml.cpp @@ -1,4 +1,4 @@ -/* $Id: test_router_flexml.cpp,v 1.2 2005-10-29 22:23:36 marc Exp $ +/* $Id: test_router_flexml.cpp,v 1.3 2005-10-31 09:40:18 marc Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -19,9 +19,6 @@ using namespace boost::unit_test; class TFilter: public yp2::filter::Base { public: void process(yp2::Package & package) const {}; - const std::string type() const { - return "TFilter"; - }; };