Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

TraceInfos.cpp 4.21 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <QTextEdit>
#include <QHBoxLayout>
#include <set>
#include <stack>
#include "plugin/Plugin.hpp"
#include "trace/EntityTypes.hpp"
#include "trace/EntityValue.hpp"
#include "trace/Entitys.hpp"
#include "trace/Container.hpp"
#include "trace/tree/Node.hpp"
#include "trace/tree/BinaryTree.hpp"
#include "trace/Trace.hpp"
#include "TraceInfos.hpp"

using namespace std;

Trace_infos::Trace_infos() {
    QHBoxLayout *horizontalLayout = new QHBoxLayout(this);
    _text_info = new QTextEdit();
    horizontalLayout->addWidget(_text_info);
}

Trace_infos::~Trace_infos() {
}

void Trace_infos::set_container_infos(QString &text) const {
    /* count */
    list <Container *> container_list;
    _trace->get_all_containers(container_list);
        
    text += "<h2>Containers:</h2>";
    text += QString("count: %1").arg(container_list.size());
}

void Trace_infos::set_states_infos(QString &text) const {

    list <Container *> container_list;
    BinaryTree<StateChange> *states;
    _trace->get_all_containers(container_list);

    set<string> state_list;

    for(list<Container *>::const_iterator it = container_list.begin();
        it != container_list.end();
        ++ it) {
        states = (*it)->get_states();
        if(states && states->get_root()) {
            get_states_name_rec(states->get_root(), state_list);
        }
    }
    
    text += "<h2>States:</h2>";
    text += QString("count: %1").arg(state_list.size());
}

void Trace_infos::get_states_name_rec(Node<StateChange> *parent, set<string> &state_list) const {

    if(!parent)
        return;
    const StateChange *top_state = parent->get_element();
    const State *left_state = top_state->get_left_state();
    const State *right_state = top_state->get_right_state();
    if(left_state && left_state->get_value()) {
Johnny Jazeix's avatar
Johnny Jazeix committed
64
65
        state_list.insert(left_state->get_value()->get_name());
        //cout << left_state->get_value()->get_name() << endl;
66
67
68
        get_states_name_rec(parent->get_left_child(), state_list);
    }
    if(right_state && right_state->get_value()) {
Johnny Jazeix's avatar
Johnny Jazeix committed
69
70
        state_list.insert(right_state->get_value()->get_name());
        //cout << right_state->get_value()->get_name() << endl;
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
        get_states_name_rec(parent->get_right_child(), state_list);
    }
}

void Trace_infos::set_events_infos(QString &text) const {
    /* count */
    int count = 0;
    list <Container *> container_list;
    _trace->get_all_containers(container_list);
        
    for(list<Container *>::const_iterator it = container_list.begin();
        it != container_list.end();
        ++ it) {
        count += (*it)->get_event_number();
    }
    text += "<h2>Events:</h2>";
    text += QString("count: %1").arg(count);
}

void Trace_infos::set_variables_infos(QString &text) const {
    /* count */
    int count = 0;
    list <Container *> container_list;
    _trace->get_all_containers(container_list);
        
    for(list<Container *>::const_iterator it = container_list.begin();
        it != container_list.end();
        ++ it) {
        count += (*it)->get_variable_number();
    }
    text += "<h2>Variables:</h2>";        
    text += QString("count: %1").arg(count);
}

void Trace_infos::set_links_infos(QString &text) const {
    /* count */
    int nb_of_links = 0;

    list <Container *> containers;
    _trace->get_all_containers(containers);

    // Look for the values now
    for(list<Container *>::const_iterator it = containers.begin() ; it != containers.end() ; ++ it) {
        const Link::Vector *links = (*it)->get_links();
        for(Link::VectorIt it = links->begin() ; it != links->end() ; ++ it) {
            nb_of_links ++;
        }
    }

    text += "<h2>Links:</h2>";
    text += QString("count: %1").arg(nb_of_links);
}

void Trace_infos::init() {
    //_text_info->clear();
}

void Trace_infos::clear() {
    _text_info->clear();
}

void Trace_infos::set_arguments(map<string /*argname*/, QVariant */*argValue*/>) {}

string Trace_infos::get_name() {
    return "Trace informations";
}

void Trace_infos::execute() {
    _text_info->clear();
    QString text ("<center><h1> Trace informations </h1></center>");

    set_container_infos(text);

    set_states_infos(text);

    set_events_infos(text);

    set_variables_infos(text);

    set_links_infos(text);

    _text_info->setHtml(text);
}