diff options
-rw-r--r-- | project2/Jamfile.jam | 5 | ||||
-rw-r--r-- | project2/xmlObjectLoader.cpp | 25 |
2 files changed, 30 insertions, 0 deletions
diff --git a/project2/Jamfile.jam b/project2/Jamfile.jam index 575d4f9..24fa691 100644 --- a/project2/Jamfile.jam +++ b/project2/Jamfile.jam @@ -13,6 +13,7 @@ alias libxslt : : : : <cflags>"`pkg-config --cflags libexslt`" <linkflags>"`pkg-config --libs libexslt`" ; +lib dl : : <name>dl ; lib fcgi : : <name>fcgi ; lib fcgi++ : : <name>fcgi++ ; lib boost_regex : : <name>boost_regex ; @@ -63,10 +64,14 @@ lib p2common : : <include>../libmisc <library>libxmlpp + <library>dl <library>boost_system <library>boost_filesystem <library>boost_date_time <library>boost_program_options + : : + <include>. + <include>../libmisc ; lib p2xml : diff --git a/project2/xmlObjectLoader.cpp b/project2/xmlObjectLoader.cpp index e16c9e1..849cfa1 100644 --- a/project2/xmlObjectLoader.cpp +++ b/project2/xmlObjectLoader.cpp @@ -4,6 +4,7 @@ #include "logger.h" #include <boost/shared_ptr.hpp> #include <boost/foreach.hpp> +#include <dlfcn.h> #include <libxml++/nodes/textnode.h> unsigned int LoaderBase::depth = 0; @@ -17,10 +18,34 @@ objLoaders() return _objLoaders; } +SimpleMessageException(LoadLibraryFailed); + +class Library : public SourceObject { + public: + Library(const xmlpp::Element * p) : + SourceObject(p), + handle(dlopen(p->get_attribute_value("path").c_str(), RTLD_NOW)) + { + if (!handle) { + throw LoadLibraryFailed(dlerror()); + } + } + ~Library() { + dlclose(handle); + } + void loadComplete(const CommonObjects*) { + } + private: + void * handle; +}; +Storage<Library>::Objects libraries; +DECLARE_LOADER("library", Library); + LoaderBase::LoaderBase(const Glib::ustring & n, bool r) : recursive(r), ns(n) { + supportedStorers.insert(Storer::into(&libraries)); } LoaderBase::~LoaderBase() |