Implemented FilterLog filter
authorAdam Dickmeiss <adam@indexdata.dk>
Sat, 15 Oct 2005 11:02:08 +0000 (11:02 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Sat, 15 Oct 2005 11:02:08 +0000 (11:02 +0000)
src/Makefile.am
src/ex_filter_frontend_net.cpp
src/filter_log.cpp [new file with mode: 0644]
src/filter_log.hpp [new file with mode: 0644]

index cf719f3..0e13dd7 100644 (file)
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.18 2005-10-14 11:18:59 adam Exp $
+## $Id: Makefile.am,v 1.19 2005-10-15 11:02:08 adam Exp $
 
 MAINTAINERCLEANFILES = Makefile.in config.in config.hpp
 
@@ -9,9 +9,11 @@ AM_CXXFLAGS = $(YAZPPINC) $(XSLT_CFLAGS)
 lib_LTLIBRARIES = libyp2.la
 libyp2_la_LDFLAGS = -version-info 0:0:0
 
-libyp2_la_SOURCES = filter_frontend_net.cpp filter_frontend_net.hpp \
+libyp2_la_SOURCES = \
        session.cpp session.hpp package.hpp filter.hpp router.hpp \
-       thread_pool_observer.cpp thread_pool_observer.hpp
+       thread_pool_observer.cpp thread_pool_observer.hpp \
+       filter_frontend_net.cpp filter_frontend_net.hpp \
+       filter_log.cpp filter_log.hpp
 
 # Rules for programs..
 
index 23c5aa1..41813af 100644 (file)
@@ -9,6 +9,7 @@ namespace po = boost::program_options;
 #include "config.hpp"
 
 #include "filter_frontend_net.hpp"
+#include "filter_log.hpp"
 
 #include "router.hpp"
 #include "session.hpp"
@@ -94,7 +95,7 @@ int main(int argc, char **argv)
 
            yp2::RouterChain router;
 
-            // put in frontend first
+            // put frontend filter in router
             yp2::FilterFrontendNet filter_front;
             filter_front.ports() = ports;
 
@@ -104,7 +105,11 @@ int main(int argc, char **argv)
             }
            router.rule(filter_front);
 
-            // put in a backend
+            // put log filter in router
+            yp2::FilterLog filter_log;
+            router.rule(filter_log);
+
+            // put backend init filter in router
             FilterInit filter_init;
            router.rule(filter_init);
 
diff --git a/src/filter_log.cpp b/src/filter_log.cpp
new file mode 100644 (file)
index 0000000..333658b
--- /dev/null
@@ -0,0 +1,40 @@
+
+
+#include "config.hpp"
+
+#include "filter.hpp"
+#include "router.hpp"
+#include "package.hpp"
+
+#include "filter_log.hpp"
+
+#include <yaz/zgdu.h>
+#include <yaz/log.h>
+
+#include <iostream>
+
+yp2::FilterLog::FilterLog() {}
+
+void yp2::FilterLog::process(Package &package) const {
+
+    Z_GDU *gdu;
+
+    gdu = package.request().get();
+    if (gdu)
+    {
+       ODR odr = odr_createmem(ODR_PRINT);
+       z_GDU(odr, &gdu, 0, 0);
+       odr_destroy(odr);
+    }
+    package.move();
+
+    gdu = package.response().get();
+    if (gdu)
+    {
+       ODR odr = odr_createmem(ODR_PRINT);
+       z_GDU(odr, &gdu, 0, 0);
+       odr_destroy(odr);
+    }
+}
+
+
diff --git a/src/filter_log.hpp b/src/filter_log.hpp
new file mode 100644 (file)
index 0000000..84d1491
--- /dev/null
@@ -0,0 +1,25 @@
+
+#ifndef FILTER_LOG_HPP
+#define FILTER_LOG_HPP
+
+#include <stdexcept>
+#include <vector>
+
+#include "filter.hpp"
+
+namespace yp2 {
+    class FilterLog : public yp2::Filter {
+    public:
+       FilterLog::FilterLog();
+       void process(yp2::Package & package) const;
+    };
+}
+
+#endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */