31 namespace mp = metaproxy_1;
33 namespace metaproxy_1 {
35 typedef std::map<std::string, CreateFilterCallback>
CallbackMap;
36 typedef std::map<std::string, CreateFilterCallback>::iterator
46 mp::FactoryFilter::NotFound::NotFound(
const std::string message)
47 : std::runtime_error(message)
51 mp::FactoryFilter::Rep::Rep()
55 mp::FactoryFilter::Rep::~Rep()
70 CreateFilterCallback cfc)
72 return m_p->m_fcm.insert(Rep::CallbackMap::value_type(fi, cfc)).second;
78 return m_p->m_fcm.erase(fi) == 1;
83 Rep::CallbackMap::const_iterator it = m_p->m_fcm.find(fi);
85 if (it == m_p->m_fcm.end())
94 Rep::CallbackMap::const_iterator it = m_p->m_fcm.find(fi);
96 if (it == m_p->m_fcm.end()){
97 std::string msg =
"filter type '" + fi +
"' not found";
101 return (it->second());
114 const std::string &path)
117 if (m_p->m_fcm.find(fi) != m_p->m_fcm.end())
122 std::string full_path = path +
"/metaproxy_filter_" + fi +
".so";
123 void *dl_handle = dlopen(full_path.c_str(), RTLD_GLOBAL|RTLD_NOW);
126 const char *dl = dlerror();
127 std::cout <<
"dlopen " << full_path <<
" failed. dlerror=" << dl <<
132 std::string full_name =
"metaproxy_1_filter_" + fi;
134 void *dlsym_ptr = dlsym(dl_handle, full_name.c_str());
137 std::cout <<
"dlsym " << full_name <<
" failed\n";
140 struct metaproxy_1_filter_struct *s = (
struct metaproxy_1_filter_struct *) dlsym_ptr;
141 return add_creator(fi, s->creator);