From: Adam Dickmeiss Date: Wed, 12 Jun 2013 12:08:33 +0000 (+0200) Subject: Add RouterXML in public API MP-450 X-Git-Tag: v1.3.57~4 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=cec05aa8c24b33f36e6aa1c8a00d3ecb58dd5e84;hp=42509e27416325060d28e320ccb92c187859c852;p=metaproxy-moved-to-github.git Add RouterXML in public API MP-450 --- diff --git a/include/metaproxy/Makefile.am b/include/metaproxy/Makefile.am index 0f38914..9c80072 100644 --- a/include/metaproxy/Makefile.am +++ b/include/metaproxy/Makefile.am @@ -2,5 +2,6 @@ ## Copyright (C) 2005-2013 Index Data pkginclude_HEADERS= filter.hpp origin.hpp package.hpp \ - router.hpp session.hpp util.hpp xmlutil.hpp router_chain.hpp + router.hpp router_chain.hpp router_xml.hpp \ + session.hpp util.hpp xmlutil.hpp diff --git a/include/metaproxy/router_xml.hpp b/include/metaproxy/router_xml.hpp new file mode 100644 index 0000000..2792ba7 --- /dev/null +++ b/include/metaproxy/router_xml.hpp @@ -0,0 +1,60 @@ +/* This file is part of Metaproxy. + Copyright (C) 2005-2013 Index Data + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef ROUTER_XML_HPP +#define ROUTER_XML_HPP + +#include + +#include +#include + +namespace metaproxy_1 +{ + class RouterXML : public metaproxy_1::Router + { + class Rep; + class Route; + class Pos; + public: + RouterXML(xmlDocPtr doc, + bool test_only, const char *file_include_path); + RouterXML(std::string xmlconf, + bool test_only); + + ~RouterXML(); + + virtual RoutePos *createpos() const; + void start(); + void stop(); + private: + boost::scoped_ptr m_p; + }; + +}; +#endif + +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/src/Makefile.am b/src/Makefile.am index f3b0500..af16f6b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -58,6 +58,7 @@ libmetaproxy_la_SOURCES = \ url_recipe.cpp \ util.cpp \ router_chain.cpp \ + router_xml.cpp \ xmlutil.cpp libmetaproxy_la_LIBADD = $(YAZPPLALIB) \ diff --git a/src/metaproxy_prog.cpp b/src/metaproxy_prog.cpp index bfa1b77..a4ec7f0 100644 --- a/src/metaproxy_prog.cpp +++ b/src/metaproxy_prog.cpp @@ -30,8 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include -#include "router_flexml.hpp" -#include "factory_static.hpp" +#include #if HAVE_UNISTD_H #include @@ -45,7 +44,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA namespace mp = metaproxy_1; -mp::RouterFleXML *routerp = 0; +mp::RouterXML *routerp = 0; static void set_log_prefix(void) { @@ -84,7 +83,7 @@ static void work_common(void *data) signal(SIGTERM, sig_term_handler); signal(SIGUSR1, sig_usr1_handler); #endif - routerp = (mp::RouterFleXML*) data; + routerp = (mp::RouterXML*) data; routerp->start(); mp::Package pack; @@ -247,9 +246,8 @@ static int sc_main( wrbuf_puts(base_path, "."); ret = 0; try { - mp::FactoryStatic factory; - mp::RouterFleXML *router = - new mp::RouterFleXML(doc, factory, test_config, wrbuf_cstr(base_path)); + mp::RouterXML *router = + new mp::RouterXML(doc, test_config, wrbuf_cstr(base_path)); if (!test_config) { diff --git a/src/router_xml.cpp b/src/router_xml.cpp new file mode 100644 index 0000000..9abba65 --- /dev/null +++ b/src/router_xml.cpp @@ -0,0 +1,92 @@ +/* This file is part of Metaproxy. + Copyright (C) 2005-2013 Index Data + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "config.hpp" +#include +#include "router_flexml.hpp" +#include "factory_static.hpp" + +namespace mp = metaproxy_1; + +namespace metaproxy_1 { + class RouterXML::Rep { + public: + Rep(xmlDocPtr, bool, const char *); + Rep(std::string, bool); + ~Rep(); + FactoryStatic m_factory; + boost::scoped_ptr m_flexml; + }; +} + +mp::RouterXML::Rep::Rep(xmlDocPtr doc, bool test_only, + const char *include_path) + : m_factory(), + m_flexml(new RouterFleXML(doc, m_factory, test_only, include_path)) +{ +} + +mp::RouterXML::Rep::Rep(std::string xmlconf, bool test_only) + : m_factory(), + m_flexml(new RouterFleXML(xmlconf, m_factory, test_only)) +{ +} + +mp::RouterXML::Rep::~Rep() +{ +} + +mp::RouterXML::RouterXML(xmlDocPtr doc, + bool test_only, const char *file_include_path) + : m_p(new Rep(doc, test_only, file_include_path)) +{ +} + +mp::RouterXML::RouterXML(std::string xmlconf, bool test_only) + : m_p(new Rep(xmlconf, test_only)) +{ +} + +mp::RouterXML::~RouterXML() +{ +} + +mp::RoutePos *mp::RouterXML::createpos() const +{ + return m_p->m_flexml->createpos(); +} + +void mp::RouterXML::start() +{ + m_p->m_flexml->start(); +} + +void mp::RouterXML::stop() +{ + m_p->m_flexml->stop(); +} + +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/win/makefile b/win/makefile index 3f9575d..5f1a546 100644 --- a/win/makefile +++ b/win/makefile @@ -245,6 +245,7 @@ PROJECT_DLL_OBJS = \ $(OBJDIR)\plainfile.obj \ $(OBJDIR)\router_chain.obj \ $(OBJDIR)\router_flexml.obj \ + $(OBJDIR)\router_xml.obj \ $(OBJDIR)\session.obj \ $(OBJDIR)\sru_util.obj \ $(OBJDIR)\thread_pool_observer.obj \