Fixed bug #1341: MetaProxy returning different results. Problem was that
[metaproxy-moved-to-github.git] / src / factory_filter.cpp
index 8b69ae1..a7516bb 100644 (file)
@@ -1,7 +1,22 @@
-/* $Id: factory_filter.cpp,v 1.3 2006-01-19 09:41:01 adam Exp $
-   Copyright (c) 2005, Index Data.
+/* $Id: factory_filter.cpp,v 1.8 2007-05-09 21:23:09 adam Exp $
+   Copyright (c) 2005-2007, Index Data.
 
-%LICENSE%
+This file is part of Metaproxy.
+
+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 Metaproxy; see the file LICENSE.  If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
  */
 
 #include "config.hpp"
@@ -16,7 +31,9 @@
 #include <string>
 #include <map>
 
-namespace yp2 {
+namespace mp = metaproxy_1;
+
+namespace metaproxy_1 {
     class FactoryFilter::Rep {
         typedef std::map<std::string, CreateFilterCallback> CallbackMap;
         typedef std::map<std::string, CreateFilterCallback>::iterator 
@@ -29,42 +46,42 @@ namespace yp2 {
     };
 }
 
-yp2::FactoryFilter::NotFound::NotFound(const std::string message)
+mp::FactoryFilter::NotFound::NotFound(const std::string message)
     : std::runtime_error(message)
 {
 }
 
-yp2::FactoryFilter::Rep::Rep()
+mp::FactoryFilter::Rep::Rep()
 {
 }
 
-yp2::FactoryFilter::Rep::~Rep()
+mp::FactoryFilter::Rep::~Rep()
 {
 }
 
-yp2::FactoryFilter::FactoryFilter() : m_p(new yp2::FactoryFilter::Rep)
+mp::FactoryFilter::FactoryFilter() : m_p(new mp::FactoryFilter::Rep)
 {
 
 }
 
-yp2::FactoryFilter::~FactoryFilter()
+mp::FactoryFilter::~FactoryFilter()
 {
 
 }
 
-bool yp2::FactoryFilter::add_creator(std::string fi,
+bool mp::FactoryFilter::add_creator(std::string fi,
                                      CreateFilterCallback cfc)
 {
     return m_p->m_fcm.insert(Rep::CallbackMap::value_type(fi, cfc)).second;
 }
 
 
-bool yp2::FactoryFilter::drop_creator(std::string fi)
+bool mp::FactoryFilter::drop_creator(std::string fi)
 {
     return m_p->m_fcm.erase(fi) == 1;
 }
 
-bool yp2::FactoryFilter::exist(std::string fi)
+bool mp::FactoryFilter::exist(std::string fi)
 {
     Rep::CallbackMap::const_iterator it = m_p->m_fcm.find(fi);
     
@@ -75,7 +92,7 @@ bool yp2::FactoryFilter::exist(std::string fi)
     return true;
 }
 
-yp2::filter::Base* yp2::FactoryFilter::create(std::string fi)
+mp::filter::Base* mp::FactoryFilter::create(std::string fi)
 {
     Rep::CallbackMap::const_iterator it = m_p->m_fcm.find(fi);
     
@@ -87,7 +104,7 @@ yp2::filter::Base* yp2::FactoryFilter::create(std::string fi)
     return (it->second());
 }
 
-bool yp2::FactoryFilter::have_dl_support()
+bool mp::FactoryFilter::have_dl_support()
 {
 #if HAVE_DLFCN_H
     return true;
@@ -96,7 +113,7 @@ bool yp2::FactoryFilter::have_dl_support()
 #endif
 }
 
-bool yp2::FactoryFilter::add_creator_dl(const std::string &fi,
+bool mp::FactoryFilter::add_creator_dl(const std::string &fi,
                                         const std::string &path)
 {
 #if HAVE_DLFCN_H
@@ -105,7 +122,7 @@ bool yp2::FactoryFilter::add_creator_dl(const std::string &fi,
         return true;
     }
 
-    std::string full_path = path + "/yp2_filter_" + fi + ".so";
+    std::string full_path = path + "/metaproxy_filter_" + fi + ".so";
     void *dl_handle = dlopen(full_path.c_str(), RTLD_GLOBAL|RTLD_NOW);
     if (!dl_handle)
     {
@@ -115,7 +132,7 @@ bool yp2::FactoryFilter::add_creator_dl(const std::string &fi,
         return false;
     }
 
-    std::string full_name = "yp2_filter_" + fi;
+    std::string full_name = "metaproxy_1_filter_" + fi;
     
     void *dlsym_ptr = dlsym(dl_handle, full_name.c_str());
     if (!dlsym_ptr)
@@ -123,7 +140,7 @@ bool yp2::FactoryFilter::add_creator_dl(const std::string &fi,
         std::cout << "dlsym " << full_name << " failed\n";
         return false;
     }
-    struct yp2_filter_struct *s = (struct yp2_filter_struct *) dlsym_ptr;
+    struct metaproxy_1_filter_struct *s = (struct metaproxy_1_filter_struct *) dlsym_ptr;
     return add_creator(fi, s->creator);
 #else
     return false;