Commit cdd7ed44 authored by Kevin Coulomb's avatar Kevin Coulomb
Browse files

Les stats sur les etats sont disponibles.

Il reste a faire une joli sortie graphique
parent 77e9be00
......@@ -211,51 +211,49 @@ void Container::finish(const Date &time) {
void Container::fill_stat( Statistic * stat, Interval I){
bool is_first_added = false;
// If the container is a proc -> no child container
if(this->get_children()->empty()) {
browse_stat_link(this,stat,I);
}
Node<StateChange> * node = this->get_states()->get_root();
browse_stat_state(node,stat,I,is_first_added);
browse_stat_state(node,stat,I);
stat->set_nb_event(this->get_event_number());
}
void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I, bool& is_displayed){
void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I){
if( ! node ||
! node->get_element())
return;
// If the node is in the interval
if(node->get_element()->get_time() < I._right &&
node->get_element()->get_time() > I._left){
if(node->get_element()->get_time() <= I._right &&
node->get_element()->get_time() >= I._left){
if(node->get_left_child())
browse_stat_state(node->get_left_child(),stats,I,is_displayed);
browse_stat_state(node->get_left_child(),stats,I);
if(node->get_right_child())
browse_stat_state(node->get_right_child(),stats,I,is_displayed);
browse_stat_state(node->get_right_child(),stats,I);
if(!is_displayed &&
node->get_element()->get_left_state()){// To add the first state
stats->add_state(node->get_element()->get_left_state()->get_value(),node->get_element()->get_left_state()->get_duration());
is_displayed = true;
}
//Add the right state of the state change
if(node->get_element()->get_right_state())
stats->add_state(node->get_element()->get_right_state()->get_value(),node->get_element()->get_right_state()->get_duration());
}
// Else if after the interval
else if(node->get_element()->get_time() > I._right ){
if(node->get_left_child()){
browse_stat_state(node->get_left_child(),stats,I,is_displayed);
browse_stat_state(node->get_left_child(),stats,I);
}
}
else{
// Else node is before the interval
if(node->get_right_child()){
browse_stat_state(node->get_right_child(),stats,I,is_displayed);
browse_stat_state(node->get_right_child(),stats,I);
}
}
......
......@@ -274,14 +274,14 @@ public:
};
/*!
* \fn browse_stat_state(Node<StateChange> * node, Statistic * stat, Interval I, bool & is_made)
* \fn browse_stat_state(Node<StateChange> * node, Statistic * stat, Interval I)
* \brief Recursive function that browses the tree
* \param node : The node that is currently added
* \param stat : The Statistic class that is filled
* \param I : The interval we want the data in
* \param bool : A boolean used to remember if the first element has been displayed or not
*/
void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I, bool& is_displayed);
void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I);
/*!
* \fn fill_stat(Container * cont, Statistic * stat, Interval I)
* \brief Fill the stat element with the corresponding data to be displayed
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment