1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file src/visualizer/ArtisanWrapper.cpp
12 #include "visualizer/ArtisanWrapper.h"
13 #include "config/GlobalVault.h"
14 #include "util/MessageSystem.h"
16 namespace Visualizer
{
18 ArtisanWrapper::ArtisanWrapper(Artisan::Interface
*interface
) : m_interface(interface
) {
22 ArtisanWrapper::ArtisanWrapper(const std::string
&name
) : m_interface(NULL
) {
26 ArtisanWrapper::~ArtisanWrapper() {
30 void ArtisanWrapper::load(const std::string
&name
) {
31 std::string modulePath
= Config::GlobalVault::instance()->get(name
+ ":root") +
32 Config::GlobalVault::instance()->get(name
+ ":artisanPath");
34 m_handle
= dlopen(modulePath
.c_str(), RTLD_NOW
| RTLD_LOCAL
);
35 if(m_handle
== NULL
) {
36 Message(Warning
, "Could not open artisan library for module \"" << name
<< "\":" << dlerror());
39 Artisan::Interface
*(*instantiate
)();
41 *(void **) (&instantiate
) = dlsym(m_handle
, "AA_Instantiate");
43 if(instantiate
== NULL
) {
44 Message(Warning
, "Could not find AA_Instantiate in " << name
<< "'s artisan.");
48 m_interface
= instantiate();
51 } // namespace Visualizer