can be specified as CDATA in element dlpath in XML config, i.e.
<yp2 xmlns="http://indexdata.dk/yp2/config/1">
<dlpath>../src/.libs</dlpath>
<start route="start"/>
..
-/* $Id: factory_filter.cpp,v 1.2 2006-01-05 16:39:37 adam Exp $
+/* $Id: factory_filter.cpp,v 1.3 2006-01-19 09:41:01 adam Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
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);
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:
-/* $Id: factory_filter.hpp,v 1.2 2006-01-05 16:39:37 adam Exp $
+/* $Id: factory_filter.hpp,v 1.3 2006-01-19 09:41:01 adam Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
bool drop_creator(std::string fi);
yp2::filter::Base* create(std::string fi);
+ bool exist(std::string fi);
+
+ bool add_creator_dl(const std::string &fi, const std::string &path);
- bool add_creator_dyn(const std::string &fi, const std::string &path);
-
+ bool have_dl_support();
class NotFound : public std::runtime_error {
public:
-/* $Id: router_flexml.cpp,v 1.15 2006-01-18 10:30:58 adam Exp $
+/* $Id: router_flexml.cpp,v 1.16 2006-01-19 09:41:01 adam Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
std::string m_start_route;
+ std::string m_dl_path;
+
void parse_xml_config_dom(xmlDocPtr doc);
void parse_xml_filters(xmlDocPtr doc, const xmlNode *node);
" in filter element. Got " + name);
}
+ if (!m_factory->exist(type_value))
+ {
+ std::cout << "about to load " << type_value << ", path=" <<
+ m_dl_path << "\n";
+ m_factory->add_creator_dl(type_value, m_dl_path);
+ }
yp2::filter::Base* filter_base = m_factory->create(type_value);
filter_base->configure(node);
id_value = value;
else
throw yp2::XMLError("Only attribute 'id' allowed for"
- " element 'route'."
- " Got " + name);
+ " element 'route'."
+ " Got " + name);
}
Route route;
}
else if (type_value.length())
{
+ if (!m_factory->exist(type_value))
+ {
+ std::cout << "about to load " << type_value << ", path=" <<
+ m_dl_path << "\n";
+ m_factory->add_creator_dl(type_value, m_dl_path);
+ }
yp2::filter::Base* filter_base = m_factory->create(type_value);
filter_base->configure(node3);
yp2::xml::check_element_yp2(root, "yp2");
- // process <start> node which is expected first element node
const xmlNode* node = yp2::xml::jump_to_children(root, XML_ELEMENT_NODE);
+
+ if (yp2::xml::is_element_yp2(node, "dlpath"))
+ {
+ m_dl_path = yp2::xml::get_text(node);
+ node = yp2::xml::jump_to_next(node, XML_ELEMENT_NODE);
+ }
+ // process <start> node which is expected first element node
if (yp2::xml::check_element_yp2(node, "start"))
{
const struct _xmlAttr *attr;
-/* $Id: test_filter_factory.cpp,v 1.10 2006-01-04 14:30:51 adam Exp $
+/* $Id: test_filter_factory.cpp,v 1.11 2006-01-19 09:41:01 adam Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
-
*/
#include <iostream>
const std::string id = "dl";
// first load
- BOOST_CHECK(ffactory.add_creator_dyn(id, ".libs"));
+ BOOST_CHECK(ffactory.add_creator_dl(id, ".libs"));
// test double load
- BOOST_CHECK(ffactory.add_creator_dyn(id, ".libs"));
+ BOOST_CHECK(ffactory.add_creator_dl(id, ".libs"));
yp2::filter::Base* filter = 0;
filter = ffactory.create(id);