summaryrefslogtreecommitdiff
path: root/project2/common/library.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/common/library.cpp')
-rw-r--r--project2/common/library.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/project2/common/library.cpp b/project2/common/library.cpp
new file mode 100644
index 0000000..b1e0b9b
--- /dev/null
+++ b/project2/common/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*)
+{
+}
+
+STORAGEOF(Library) libraries;
+class LibraryLoader : public ElementLoaderImpl<Library> {
+ public:
+ void onIteration()
+ {
+ libraries.clear();
+ }
+};
+
+DECLARE_CUSTOM_LOADER("library", LibraryLoader);
+
+