summaryrefslogtreecommitdiff
path: root/project2/xmlObjectLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/xmlObjectLoader.cpp')
-rw-r--r--project2/xmlObjectLoader.cpp25
1 files changed, 25 insertions, 0 deletions
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()