~ubuntu-branches/ubuntu/oneiric/dammit/oneiric

« back to all changes in this revision

Viewing changes to dammit/print_visitor.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Simon Richter
  • Date: 2008-05-25 18:09:39 UTC
  • Revision ID: james.westby@ubuntu.com-20080525180939-iguzr0jb41w5s1oe
Tags: upstream-0~preview1
ImportĀ upstreamĀ versionĀ 0~preview1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2008 Simon Richter <Simon.Richter@hogyros.de>
 
2
 *
 
3
 * Released under the GNU General Public Licence version 3.
 
4
 */
 
5
 
 
6
#ifdef HAVE_CONFIG_H
 
7
#include <config.h>
 
8
#endif
 
9
 
 
10
#include "print_visitor.hpp"
 
11
 
 
12
#include "parallel_node.hpp"
 
13
#include "project_node.hpp"
 
14
#include "configuration_node.hpp"
 
15
#include "input_node.hpp"
 
16
#include "temporary_node.hpp"
 
17
#include "output_node.hpp"
 
18
#include "tool_node.hpp"
 
19
#include "environment_node.hpp"
 
20
#include "action_node.hpp"
 
21
 
 
22
#include <iostream>
 
23
#include <iomanip>
 
24
 
 
25
namespace dammit {
 
26
 
 
27
intrusive_ptr<node> print_visitor::visit(parallel_node &n)
 
28
{
 
29
        out << std::setw(depth*2+11) << "- parallel" << std::endl;
 
30
        ++depth;
 
31
        for(parallel_node::node_iterator i = n.nodes.begin();
 
32
                        i != n.nodes.end(); ++i)
 
33
                *i = (**i).apply(*this);
 
34
        --depth;
 
35
        return &n;
 
36
}
 
37
 
 
38
intrusive_ptr<node> print_visitor::visit(project_node &n)
 
39
{
 
40
        out << std::setw(depth*2+12) << "- project: " << n.project_name << " (" << n.project_type << ")" << std::endl;
 
41
        ++depth;
 
42
        for(project_node::node_iterator i = n.nodes.begin();
 
43
                        i != n.nodes.end(); ++i)
 
44
                *i = (**i).apply(*this);
 
45
        --depth;
 
46
        return &n;
 
47
}
 
48
 
 
49
intrusive_ptr<node> print_visitor::visit(configuration_node &n)
 
50
{
 
51
        out << std::setw(depth*2+18) << "- configuration: " << n.platform << std::endl;
 
52
        ++depth;
 
53
        for(configuration_node::node_iterator i = n.nodes.begin();
 
54
                        i != n.nodes.end(); ++i)
 
55
                *i = (**i).apply(*this);
 
56
        --depth;
 
57
        return &n;
 
58
}
 
59
 
 
60
intrusive_ptr<node> print_visitor::visit(input_node &n)
 
61
{
 
62
        out << std::setw(depth*2+10) << "- input: " << n.filename << std::endl;
 
63
        return &n;
 
64
}
 
65
 
 
66
intrusive_ptr<node> print_visitor::visit(temporary_node &n)
 
67
{
 
68
        out << std::setw(depth*2+14) << "- temporary: " << n.filename << std::endl;
 
69
        ++depth;
 
70
        n.action = n.action->apply(*this);
 
71
        --depth;
 
72
        return &n;
 
73
}
 
74
 
 
75
intrusive_ptr<node> print_visitor::visit(output_node &n)
 
76
{
 
77
        out << std::setw(depth*2+11) << "- output: " << n.filename << std::endl;
 
78
        ++depth;
 
79
        for(output_node::input_iterator i = n.inputs.begin();
 
80
                        i != n.inputs.end(); ++i)
 
81
                *i = (**i).apply(*this);
 
82
        if(n.action)
 
83
                n.action->apply(*this);
 
84
        --depth;
 
85
        return &n;
 
86
}
 
87
 
 
88
intrusive_ptr<node> print_visitor::visit(tool_node &n)
 
89
{
 
90
        out << "tool: " << std::endl;
 
91
        return &n;
 
92
}
 
93
 
 
94
intrusive_ptr<node> print_visitor::visit(environment_node &n)
 
95
{
 
96
        out << "environment: " << std::endl;
 
97
        return &n;
 
98
}
 
99
 
 
100
intrusive_ptr<node> print_visitor::visit(action_node &n)
 
101
{
 
102
        out << std::setw(depth*2+11) << "- action: " << n.cmd << std::endl;
 
103
        ++depth;
 
104
        for(action_node::input_iterator i = n.inputs.begin();
 
105
                        i != n.inputs.end(); ++i)
 
106
                *i = (**i).apply(*this);
 
107
        --depth;
 
108
        return &n;
 
109
}
 
110
 
 
111
}