-/* $Id: factory_filter.cpp,v 1.1 2006-01-04 14:30:51 adam Exp $
+/* $Id: factory_filter.cpp,v 1.3 2006-01-19 09:41:01 adam Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
};
}
-yp2::FactoryFilterException::FactoryFilterException(const std::string message)
- : std::runtime_error("FilterException: " + message)
+yp2::FactoryFilter::NotFound::NotFound(const std::string message)
+ : std::runtime_error(message)
{
}
return m_p->m_fcm.erase(fi) == 1;
}
+bool yp2::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;
+}
+
yp2::filter::Base* yp2::FactoryFilter::create(std::string fi)
{
Rep::CallbackMap::const_iterator it = m_p->m_fcm.find(fi);
if (it == m_p->m_fcm.end()){
std::string msg = "filter type '" + fi + "' not found";
- throw yp2::FactoryFilterException(msg);
+ throw NotFound(msg);
}
// call create function
return (it->second());
}
+bool yp2::FactoryFilter::have_dl_support()
+{
#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 yp2::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;
}
struct yp2_filter_struct *s = (struct yp2_filter_struct *) dlsym_ptr;
return add_creator(fi, s->creator);
-}
+#else
+ return false;
#endif
+}
/*
* Local variables: