2 Aesalon, a tool to visualize a program's behaviour at run-time.
3 Copyright (C) 2010, Aesalon Development Team.
5 Aesalon is distributed under the terms of the GNU GPLv3. For more
6 licensing information, see the file LICENSE included with the distribution.
8 @file monitor/src/module/Module.cpp
16 #include "module/Module.h"
17 #include "monitor/Coordinator.h"
18 #include "common/Preprocessor.h"
19 #include "common/StringTo.h"
24 Module::Module(const std::string
&moduleName
) : m_moduleName(moduleName
) {
31 dlclose(m_marshallerHandle
);
34 void Module::loadMarshaller() {
36 Coordinator::instance()->vault()->get(m_moduleName
+ ":root")
37 + Coordinator::instance()->vault()->get(m_moduleName
+ ":marshallerPath");
39 std::cout
<< path
<< std::endl
;
41 m_marshallerHandle
= dlopen(path
.c_str(), RTLD_LOCAL
| RTLD_NOW
);
42 if(m_marshallerHandle
== NULL
) {
46 Common::MarshallerInterface
*(*instantiate
)() = NULL
;
48 *(void **)(&instantiate
) = dlsym(m_marshallerHandle
, "AM_InstantiateMarshaller");
50 if(instantiate
== NULL
) {
51 /* This is an error. */
52 std::cout
<< "Module exists, but does not have exported AM_InstantiateMarshaller() . . ." << std::endl
;
53 std::cout
<< "\tDid you forget to place it in an extern \"C\" block?" << std::endl
;
56 m_instance
= instantiate();
60 void Module::loadPreprocessor() {
61 std::string ppPath
= Coordinator::instance()->vault()->get(m_moduleName
+ ":preprocessorPath");
62 if(ppPath
== "") return;
64 Coordinator::instance()->vault()->get(m_moduleName
+ ":root") + ppPath
;
66 m_preprocessorHandle
= dlopen(path
.c_str(), RTLD_LOCAL
| RTLD_NOW
);
67 if(m_preprocessorHandle
== NULL
) return;
69 Common::Preprocessor preprocessor
;
71 *(void **)(&preprocessor
) = dlsym(m_marshallerHandle
, "AM_Preprocess");
73 if(preprocessor
== NULL
) {
74 /* This is an error. */
75 std::cout
<< "Module exists, but does not have AM_Preprocess() . . ." << std::endl
;
78 preprocessor(Coordinator::instance()->vault());
83 } // namespace Monitor