projects
/
metaproxy-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update for new PDF rules.
[metaproxy-moved-to-github.git]
/
src
/
factory_filter.cpp
diff --git
a/src/factory_filter.cpp
b/src/factory_filter.cpp
index
d48d2dd
..
9a7231b
100644
(file)
--- a/
src/factory_filter.cpp
+++ b/
src/factory_filter.cpp
@@
-1,7
+1,7
@@
-/* $Id: factory_filter.cpp,v 1.2 2006-01-05 16:39:37 adam Exp $
- Copyright (c) 2005, Index Data.
+/* $Id: factory_filter.cpp,v 1.7 2007-01-25 14:05:54 adam Exp $
+ Copyright (c) 2005-2007, Index Data.
-%LICENSE%
+ See the LICENSE file for details
*/
#include "config.hpp"
*/
#include "config.hpp"
@@
-16,7
+16,9
@@
#include <string>
#include <map>
#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
class FactoryFilter::Rep {
typedef std::map<std::string, CreateFilterCallback> CallbackMap;
typedef std::map<std::string, CreateFilterCallback>::iterator
@@
-29,42
+31,53
@@
namespace yp2 {
};
}
};
}
-yp2::FactoryFilter::NotFound::NotFound(const std::string message)
+mp::FactoryFilter::NotFound::NotFound(const std::string message)
: std::runtime_error(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;
}
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;
}
{
return m_p->m_fcm.erase(fi) == 1;
}
-yp2::filter::Base* yp2::FactoryFilter::create(std::string fi)
+bool mp::FactoryFilter::exist(std::string fi)
+{
+ Rep::CallbackMap::const_iterator it = m_p->m_fcm.find(fi);
+
+ if (it == m_p->m_fcm.end())
+ {
+ return false;
+ }
+ return true;
+}
+
+mp::filter::Base* mp::FactoryFilter::create(std::string fi)
{
Rep::CallbackMap::const_iterator it = m_p->m_fcm.find(fi);
{
Rep::CallbackMap::const_iterator it = m_p->m_fcm.find(fi);
@@
-76,16
+89,25
@@
yp2::filter::Base* yp2::FactoryFilter::create(std::string fi)
return (it->second());
}
return (it->second());
}
+bool mp::FactoryFilter::have_dl_support()
+{
#if HAVE_DLFCN_H
#if HAVE_DLFCN_H
-bool yp2::FactoryFilter::add_creator_dyn(const std::string &fi,
- const std::string &path)
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool mp::FactoryFilter::add_creator_dl(const std::string &fi,
+ const std::string &path)
{
{
+#if HAVE_DLFCN_H
if (m_p->m_fcm.find(fi) != m_p->m_fcm.end())
{
return true;
}
if (m_p->m_fcm.find(fi) != m_p->m_fcm.end())
{
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)
{
void *dl_handle = dlopen(full_path.c_str(), RTLD_GLOBAL|RTLD_NOW);
if (!dl_handle)
{
@@
-95,7
+117,7
@@
bool yp2::FactoryFilter::add_creator_dyn(const std::string &fi,
return false;
}
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)
void *dlsym_ptr = dlsym(dl_handle, full_name.c_str());
if (!dlsym_ptr)
@@
-103,10
+125,12
@@
bool yp2::FactoryFilter::add_creator_dyn(const std::string &fi,
std::cout << "dlsym " << full_name << " failed\n";
return false;
}
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);
return add_creator(fi, s->creator);
-}
+#else
+ return false;
#endif
#endif
+}
/*
* Local variables:
/*
* Local variables: