summaryrefslogtreecommitdiff
path: root/project2/library.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-03-31 16:18:22 +0000
committerrandomdan <randomdan@localhost>2011-03-31 16:18:22 +0000
commit7487d564d30d954e483a559a438a3f0a1ebc327b (patch)
treee4693efbfd2bdbbefb97789a065f4b13cee2806f /project2/library.cpp
parentPass XML node to XML storer (diff)
downloadproject2-7487d564d30d954e483a559a438a3f0a1ebc327b.tar.bz2
project2-7487d564d30d954e483a559a438a3f0a1ebc327b.tar.xz
project2-7487d564d30d954e483a559a438a3f0a1ebc327b.zip
Add conditional execution from sqlTask
And a good tidy up in a few other places
Diffstat (limited to 'project2/library.cpp')
-rw-r--r--project2/library.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/project2/library.cpp b/project2/library.cpp
new file mode 100644
index 0000000..1941254
--- /dev/null
+++ b/project2/library.cpp
@@ -0,0 +1,41 @@
+#include <dlfcn.h>
+#include "xmlStorage.h"
+#include "exceptions.h"
+#include "library.h"
+
+SimpleMessageException(LoadLibraryFailed);
+SimpleMessageException(UnloadLibraryFailed);
+
+Library::Library(const xmlpp::Element * p) :
+ SourceObject(p),
+ handle(dlopen(p->get_attribute_value("path").c_str(), RTLD_NOW))
+{
+ if (!handle) {
+ throw LoadLibraryFailed(dlerror());
+ }
+}
+
+Library::~Library()
+{
+ if (dlclose(handle)) {
+ throw UnloadLibraryFailed(dlerror());
+ }
+}
+
+void
+Library::loadComplete(const CommonObjects*)
+{
+}
+
+Storage<Library>::Objects libraries;
+class LibraryLoader : public ElementLoaderImpl<Library> {
+ public:
+ void onIteration()
+ {
+ libraries.clear();
+ }
+};
+
+DECLARE_CUSTOM_LOADER("library", LibraryLoader);
+
+