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

Modification du parcours

parent 44fcf9f1
......@@ -216,13 +216,25 @@ void Container::fill_stat( Statistic * stat, Interval I){
if(this->get_children()->empty()) {
browse_stat_link(this,stat,I);
}
Node<StateChange> * prev = NULL;
Node<StateChange> * node = this->get_states()->get_root();
browse_stat_state(node,stat,I);
browse_stat_state(node,stat,I,prev);
// To add the first partial state of the interval
if(prev &&
prev->get_element() &&
prev->get_element()->get_right_state()){
if(prev->get_element()->get_right_state()->get_end_time() >
I._left){
stat->add_state(node->get_element()->get_right_state()->get_value(),
prev->get_element()->get_right_state()->get_end_time()-I._left);
}
}
stat->set_nb_event(this->get_event_number());
}
void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I){
void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I, Node<StateChange>* prev){
if( ! node ||
! node->get_element())
......@@ -233,35 +245,63 @@ void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I){
node->get_element()->get_time() >= I._left){
if(node->get_left_child())
browse_stat_state(node->get_left_child(),stats,I);
browse_stat_state(node->get_left_child(),stats,I,prev);
if(node->get_right_child())
browse_stat_state(node->get_right_child(),stats,I);
browse_stat_state(node->get_right_child(),stats,I,prev);
//Add the right state of the state change
if(node->get_element()->get_right_state())
if(node->get_element()->get_right_state()->get_end_time() < I._right){
stats->add_state(node->get_element()->get_right_state()->get_value(),node->get_element()->get_right_state()->get_duration());
}
else{
stats->add_state(node->get_element()->get_right_state()->get_value(),I._right - node->get_element()->get_right_state()->get_start_time());
}
}
// 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);
browse_stat_state(node->get_left_child(),stats,I,prev);
}
}
else{
// Else node is before the interval
if(node->get_right_child()){
browse_stat_state(node->get_right_child(),stats,I);
if( ! prev ){
prev = node;
}
else if(node->get_element()->get_right_state()){
if(node->get_element()->get_right_state()->get_start_time() >=
prev->get_element()->get_right_state()->get_start_time()){
prev = node;
}
}
browse_stat_state(node->get_right_child(),stats,I,prev);
}
}
}
void browse_stat_link(Container * cont, Statistic * S, Interval I){
//TODO
void browse_stat_link(const Container * cont, Statistic * S, Interval I){
if(!cont)
return;
for(list<Link *>::const_iterator it = cont->get_links()->begin() ;
it != cont->get_links()->end();
it++){
if( (*it)->get_source() == cont &&
(*it)->get_destination() != cont){
S->add_link(cont);
}
else if((*it)->get_source() != cont &&
(*it)->get_destination() == cont){
S->add_link(cont);
}
}
browse_stat_link(cont->get_parent(), S, I);
}
......@@ -280,12 +280,13 @@ public:
* \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
* \param prev : To save the previous state before the interval to be able to count it in the statistic
*/
void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I);
void browse_stat_state(Node<StateChange> * node, Statistic * stats, Interval I, Node<StateChange> * prev);
/*!
* \fn fill_stat(Container * cont, Statistic * stat, Interval I)
* \brief Fill the stat element with the corresponding data to be displayed
*/
void browse_stat_link(Container * cont, Statistic * S, Interval I);
void browse_stat_link(const Container * cont, Statistic * S, Interval I);
#endif
Markdown is supported
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