Minor changes here and there.
[aesalon.git] / src / monitor / MarshalList.cpp
bloba399dd6850db5ce425d10f199587c8894bb99885
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/monitor/MarshalList.cpp
8 */
10 #include "monitor/MarshalList.h"
11 #include "util/MessageSystem.h"
12 #include "monitor/InformerMarshal.h"
13 #include "config/GlobalVault.h"
14 #include "util/StringTo.h"
16 namespace Monitor {
18 MarshalList::MarshalList() {
19 MarshalWrapper *marshal = new MarshalWrapper(new InformerMarshal());
20 m_marshalVector.push_back(marshal);
23 MarshalList::~MarshalList() {
27 MarshalWrapper *MarshalList::marshal(ModuleID moduleID) {
28 if(moduleID >= m_marshalVector.size()) {
29 return NULL;
31 return m_marshalVector[moduleID];
34 void MarshalList::loadMarshal(const std::string &name) {
35 /* Check to see if the marshal has already been loaded. */
36 ModuleID moduleID = Util::StringTo<ModuleID>(Config::GlobalVault::instance()->get(name + ":moduleID"));
37 if(moduleID < m_marshalVector.size() && m_marshalVector[moduleID] != NULL) return;
39 MarshalWrapper *marshal = new MarshalWrapper(name);
40 if(marshal->interface() == NULL) {
41 Message(Warning, "Could not load marshal for module " << name << ".");
42 delete marshal;
44 else {
45 if(moduleID >= m_marshalVector.size()) m_marshalVector.resize(moduleID+1);
46 m_marshalVector[moduleID] = marshal;
50 } // namespace Monitor