The R-tree appears to split the nodes properly, but a basic search fails . . .
[aesalon.git] / src / monitor / Coordinator.cpp
blobc40d780455fe606cd34366c0213c3fec25638dae
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 "util/PathSanitizer.h"
19 #include "util/MessageSystem.h"
21 namespace Monitor {
23 Coordinator *Coordinator::m_instance = NULL;
25 Coordinator::Coordinator(char **argv) : m_argv(argv) {
26 m_instance = this;
29 Coordinator::~Coordinator() {
33 void Coordinator::run() {
34 parseConfigs();
36 if(m_vault->get("::list-attributes") == "true") {
37 Message(Log, "Listing all configuration keys and values.");
38 Message(Log, "Some auto-generated values may have non-canonical values.");
39 std::vector<Config::Vault::KeyPair> list;
40 m_vault->match("*", list);
41 for(std::vector<Config::Vault::KeyPair>::iterator i = list.begin(); i != list.end(); ++i) {
42 if(i->first[0] == ':' && i->first[1] == ':') continue;
44 Message(Log, " * \"" << i->first << "\" ==> \"" << i->second << "\"");
47 else if(m_vault->get("::version") == "true") {
48 usage(false);
50 else if(m_argv[m_argcOffset] == NULL || m_vault->get("::help") == "true") {
51 usage(true);
53 else {
54 Launcher launcher(m_argv + m_argcOffset);
56 launcher.launch();
60 void Coordinator::parseConfigs() {
61 Config::Parser parser;
62 m_vault = new Config::Vault();
64 parser.parse(m_vault, Util::PathSanitizer::sanitize(AesalonMonitorGlobalConfig));
65 parser.parse(m_vault, Util::PathSanitizer::sanitize(AesalonMonitorUserConfig));
66 parser.parse(m_vault, Util::PathSanitizer::sanitize(AesalonMonitorLocalConfig));
68 m_argcOffset = ArgumentParser::parse(m_vault, m_argv);
71 void Coordinator::usage(bool displayHelp) {
72 std::cout << "Aesalon version " << AesalonVersion << ". Copyright (C) 2010 Aesalon Development Team." << std::endl;
73 std::cout << "Aesalon is released under the GNU General Public License, version 3." << std::endl;
75 if(!displayHelp) return;
76 std::cout << std::endl;
77 std::cout << "Usage: " << m_argv[0] << " [options] [--] executable [arguments]" << std::endl;
78 std::cout << "Options:" << std::endl;
79 std::cout << "\t--help\n\t\tDisplays this usage message." << std::endl;
80 std::cout << "\t--version\n\t\tDisplays version information." << std::endl;
81 std::cout << "\t--search <path>\n\t\tSearches <path> for modules." << std::endl;
82 std::cout << "\t--use-module <module>\n\t\tPrepares <module> for loading." << std::endl;
83 std::cout << "\t--set <attribute>[=value]\n\t\tSets a module attribute." << std::endl;
84 std::cout << "\t--list-attributes\n\t\tLists all the available attributes." << std::endl;
87 } // namespace Monitor