Fixed buildsystem slightly, started re=implementation of the RTree.
[aesalon.git] / src / monitor / Coordinator.cpp
blob45c5b2ff16645553f0732a039aebda445a8a59aa
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/Coordinator.cpp
8 */
10 #include <iostream>
12 #include "Config.h"
14 #include "monitor/Coordinator.h"
15 #include "monitor/ArgumentParser.h"
16 #include "monitor/Launcher.h"
17 #include "config/Parser.h"
18 #include "config/GlobalVault.h"
19 #include "util/PathSanitizer.h"
20 #include "util/MessageSystem.h"
22 namespace Monitor {
24 Coordinator *Coordinator::m_instance = NULL;
26 Coordinator::Coordinator(char **argv) : m_argv(argv) {
27 m_instance = this;
30 Coordinator::~Coordinator() {
34 void Coordinator::run() {
35 Config::Vault *vault = Config::GlobalVault::instance();
36 m_argcOffset = ArgumentParser::parse(vault, m_argv);
38 if(vault->get("::list-attributes") == "true") {
39 Message(Log, "Listing all configuration keys and values.");
40 Message(Log, "Some auto-generated values may have non-canonical values.");
41 std::vector<Config::Vault::KeyPair> list;
42 vault->match("*", list);
43 for(std::vector<Config::Vault::KeyPair>::iterator i = list.begin(); i != list.end(); ++i) {
44 if(i->first[0] == ':' && i->first[1] == ':') continue;
46 Message(Log, " * \"" << i->first << "\" ==> \"" << i->second << "\"");
49 else if(vault->get("::version") == "true") {
50 usage(false);
52 else if(m_argv[m_argcOffset] == NULL || vault->get("::help") == "true") {
53 usage(true);
55 else {
56 setupModuleIDs();
57 m_resolver = new SymbolResolver();
58 MarshalList marshalList;
59 DataOutputController doc;
60 m_marshalList = &marshalList;
61 m_dataOutputController = &doc;
62 Launcher launcher(m_argv + m_argcOffset);
64 launcher.launch();
66 delete m_resolver;
70 void Coordinator::usage(bool displayHelp) {
71 std::cout << "Aesalon version " << AesalonVersion << ". Copyright (C) 2009-2011 Aesalon Development Team."
72 << std::endl;
73 std::cout << "Aesalon is released under the GNU General Public License, version 3." << std::endl;
74 std::cout << "See the file LICENSE included with the distribution for more details." << std::endl;
76 if(!displayHelp) return;
77 std::cout << std::endl;
78 std::cout << "Usage: " << m_argv[0] << " [options] [--] executable [arguments]" << std::endl;
79 std::cout << "Options:" << std::endl;
80 std::cout << "\t--help/--usage\n\t\tDisplays this usage message." << std::endl;
81 std::cout << "\t--version\n\t\tDisplays version information." << std::endl;
82 std::cout << "\t--search <path>\n\t\tSearches <path> for modules." << std::endl;
83 std::cout << "\t--use-module <module>\n\t\tPrepares <module> for loading." << std::endl;
84 std::cout << "\t--set <attribute>[[+]=value]\n\t\tSets an attribute." << std::endl;
85 std::cout << "\t--list-attributes\n\t\tLists all the available attributes." << std::endl;
88 void Coordinator::setupModuleIDs() {
89 Config::Vault *vault = Config::GlobalVault::instance();
90 std::vector<std::string> moduleList;
91 vault->get("::modules", moduleList);
93 ModuleID nextID = 1;
95 for(std::vector<std::string>::iterator i = moduleList.begin(); i != moduleList.end(); ++i) {
96 vault->set(Util::StreamAsString() << *i << ":moduleID", Util::StreamAsString() << nextID++);
100 } // namespace Monitor