Commit a839ea5c authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Remove those useless check that were causing problem on simgrid traces

parent 03a65cdb
/*
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
** This file is part of the ViTE project.
**
** This software is governed by the CeCILL-A license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
** - JAZEIX Johnny
** - LAGRASSE Olivier
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
**
*/
#include <iostream>
#include <string>
#include <map>
......@@ -110,14 +110,14 @@ Trace::Trace(): _max_date(0.0) {
else
#endif
Session::_palette = NULL;
#ifndef WITHOUT_QT
if(Session::get_use_palette("link_types"))
Session::_link_types = Session::get_palette("link_types", Session::get_current_palette("link_types"));
else
#endif
Session::_link_types = NULL;
#ifndef WITHOUT_QT
if(Session::get_use_palette("event_types"))
Session::_event_types = Session::get_palette("event_types", Session::get_current_palette("event_types"));
......@@ -128,11 +128,11 @@ Trace::Trace(): _max_date(0.0) {
template <class T>
void MyDelete(T *ptr){
delete ptr;
delete ptr;
};
Trace::~Trace()
Trace::~Trace()
{
//delete _palette;
......@@ -142,51 +142,51 @@ Trace::~Trace()
}
// Delete containers
for_each(_root_containers.begin(),
_root_containers.end(),
MyDelete<Container>);
for_each(_root_containers.begin(),
_root_containers.end(),
MyDelete<Container>);
_root_containers.clear();
_root_containers.resize(0);
// while (!_root_containers.empty()){
// delete _root_containers.front();
// _root_containers.pop_front();
// }
// Delete container types
while (!_root_container_types.empty()){
delete _root_container_types.front();
_root_container_types.pop_front();
}
// Delete state types
for(std::map<Name, StateType* >::iterator it=_state_types.begin(); it !=_state_types.end(); it++)
// Delete state types
for(std::map<Name, StateType* >::iterator it=_state_types.begin(); it !=_state_types.end(); it++)
delete (*it).second;
// Delete event types
for(std::map<Name, EventType* >::iterator it=_event_types.begin(); it !=_event_types.end(); it++)
for(std::map<Name, EventType* >::iterator it=_event_types.begin(); it !=_event_types.end(); it++)
delete (*it).second;
// Delete link types
for(std::map<Name, LinkType* >::iterator it=_link_types.begin(); it !=_link_types.end(); it++)
for(std::map<Name, LinkType* >::iterator it=_link_types.begin(); it !=_link_types.end(); it++)
delete (*it).second;
// Delete variable types
for(std::map<Name, VariableType* >::iterator it=_variable_types.begin(); it !=_variable_types.end(); it++)
for(std::map<Name, VariableType* >::iterator it=_variable_types.begin(); it !=_variable_types.end(); it++)
delete (*it).second;
_state_types.clear();
_event_types.clear();
_link_types.clear();
_variable_types.clear();
_state_types.clear();
_event_types.clear();
_link_types.clear();
_variable_types.clear();
}
static void delete_opt(map<string, Value *> &opt) {
for (map<string, Value *>::iterator i = opt.begin();
i != opt.end();
i++) {
i != opt.end();
i++) {
delete (*i).second;
}
}
......@@ -197,24 +197,24 @@ void Trace::define_container_type(Name &name, ContainerType *parent, map<string,
parent->add_child(type);
else
_root_container_types.push_back(type);
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
Serializer<ContainerType>::Instance().setUid(type);
#endif
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
Serializer<ContainerType>::Instance().setUid(type);
#endif
// Delete unused extra fields
delete_opt(opt);
}
Container* Trace::create_container(Date &time,
Name &name,
ContainerType *type,
Container *parent,
map<string, Value *> &opt)
Container* Trace::create_container(Date &time,
Name &name,
ContainerType *type,
Container *parent,
map<string, Value *> &opt)
{
if (!type) {
vite_error("Trace::get_container : Type undefined");
vite_error("Trace::get_container : Type undefined");
return NULL;
}
Container *cont = new Container(name, time, type, parent, opt);
if (parent){
parent->add_child(cont);
......@@ -224,86 +224,84 @@ Container* Trace::create_container(Date &time,
/* Update the trace depth */
if (cont->get_depth() > _depth) {
_depth = cont->get_depth();
Info::Trace::depth = _depth; /* Dirty method. Should be remove */
_depth = cont->get_depth();
Info::Trace::depth = _depth; /* Dirty method. Should be remove */
}
if (time > _max_date)
_max_date = time;
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
Serializer<Container>::Instance().setUid(cont);
#endif
return cont;
// Delete unused extra fields
//delete_opt(opt);
}
void Trace::destroy_container(Date &time,
Container *cont,
ContainerType *type,
map<string, Value *> &opt)
void Trace::destroy_container(Date &time,
Container *cont,
ContainerType *type,
map<string, Value *> &opt)
{
if (cont && type)
cont->destroy(time);
if (time > _max_date)
_max_date = time;
// Delete unused extra fields
delete_opt(opt);
}
void Trace::define_event_type(Name &name, ContainerType *container_type, map<string, Value *> &opt) {
if (container_type){
EventType* et=new EventType(name, container_type, opt);
_event_types.insert ( pair<Name , EventType*>(name,et));
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
Serializer<EntityType>::Instance().setUid(et);
#endif
//_event_types.push_back(new EventType(name, container_type, opt));
}
EventType* et=new EventType(name, container_type, opt);
_event_types.insert ( pair<Name , EventType*>(name,et));
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
Serializer<EntityType>::Instance().setUid(et);
#endif
//_event_types.push_back(new EventType(name, container_type, opt));
}
void Trace::define_state_type(Name &name, ContainerType *container_type, map<string, Value *> &opt) {
if (container_type){
StateType* st=new StateType(name, container_type, opt);
_state_types.insert ( pair<Name , StateType*>(name,st));
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
Serializer<EntityType>::Instance().setUid(st);
#endif
}
// _state_types.push_back(new StateType(name, container_type, opt));
StateType* st=new StateType(name, container_type, opt);
_state_types.insert ( pair<Name , StateType*>(name,st));
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
Serializer<EntityType>::Instance().setUid(st);
#endif
// _state_types.push_back(new StateType(name, container_type, opt));
}
void Trace::define_variable_type(Name &name, ContainerType *container_type, map<string, Value *> &opt) {
if (container_type){
VariableType* vt=new VariableType(name, container_type, opt);
_variable_types.insert ( pair<Name , VariableType*>(name,vt));
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
VariableType* vt=new VariableType(name, container_type, opt);
_variable_types.insert ( pair<Name , VariableType*>(name,vt));
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
Serializer<EntityType>::Instance().setUid(vt);
#endif
}
//_variable_types.push_back(new VariableType(name, container_type, opt));
#endif
}
//_variable_types.push_back(new VariableType(name, container_type, opt));
}
void Trace::define_link_type(Name &name, ContainerType *ancestor, ContainerType *source, ContainerType *destination, map<string, Value *> &opt) {
if (ancestor && source && destination){
LinkType * lt= new LinkType(name, ancestor, source, destination, opt);
_link_types.insert ( pair<Name , LinkType*>(name,lt));
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
void Trace::define_link_type(Name &name,
ContainerType *ancestor,
ContainerType *source,
ContainerType *destination,
map<string, Value *> &opt)
{
// TODO: make a clean error message if source or destination is undefined
if (source && destination){
LinkType * lt= new LinkType(name, ancestor, source, destination, opt);
_link_types.insert ( pair<Name , LinkType*>(name,lt));
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
Serializer<EntityType>::Instance().setUid(lt);
#endif
#endif
//_link_types.push_back(new LinkType(name, ancestor, source, destination, opt));
}
}
}
void Trace::define_entity_value(Name &name, EntityType *entity_type, map<string, Value *> &opt) {
......@@ -311,15 +309,15 @@ void Trace::define_entity_value(Name &name, EntityType *entity_type, map<string,
//don't alter the trace, reloading initial colors won't be possible after that.
// The palettes are applied ine DrawTrace or DrawTree after that
/*if(Session::_palette) {
Color *c = Session::_palette->get_color(name.to_string());
if(c != NULL) { // We set the palette color first
if(opt.find("Color") != opt.end()) {
delete opt["Color"];
}
opt["Color"] = new Color(*c);
}
}*/
Color *c = Session::_palette->get_color(name.to_string());
if(c != NULL) { // We set the palette color first
if(opt.find("Color") != opt.end()) {
delete opt["Color"];
}
opt["Color"] = new Color(*c);
}
}*/
entity_type->add_value(new EntityValue(name, entity_type, opt));
}
......@@ -328,7 +326,7 @@ void Trace::define_entity_value(Name &name, EntityType *entity_type, map<string,
void Trace::set_state(Date &time, StateType *type, Container *container, EntityValue *value, map<string, Value *> &opt) {
if (container && type)
container->set_state(time, type, value, opt);
if (time > _max_date)
_max_date = time;
}
......@@ -336,7 +334,7 @@ void Trace::set_state(Date &time, StateType *type, Container *container, EntityV
void Trace::push_state(Date &time, StateType *type, Container *container, EntityValue *value, map<string, Value *> &opt) {
if (container && type)
container->push_state(time, type, value, opt);
if (time > _max_date)
_max_date = time;
}
......@@ -344,10 +342,10 @@ void Trace::push_state(Date &time, StateType *type, Container *container, Entity
void Trace::pop_state(Date &time, StateType *type, Container *container, map<string, Value *> &opt) {
if (container && type)
container->pop_state(time);
if (time > _max_date)
_max_date = time;
// Delete unused extra fields
delete_opt(opt);
}
......@@ -355,7 +353,7 @@ void Trace::pop_state(Date &time, StateType *type, Container *container, map<str
void Trace::new_event(Date &time, EventType *type, Container *container, EntityValue *value, map<string, Value *> &opt) {
if (container && type)
container->new_event(time, type, value, opt);
if (time > _max_date)
_max_date = time;
}
......@@ -363,10 +361,10 @@ void Trace::new_event(Date &time, EventType *type, Container *container, EntityV
void Trace::set_variable(Date &time, VariableType *type, Container *container, Double value, map<string, Value *> &opt) {
if (container && type)
container->set_variable(time, type, value);
if (time > _max_date)
_max_date = time;
// Delete unused extra fields
delete_opt(opt);
}
......@@ -374,10 +372,10 @@ void Trace::set_variable(Date &time, VariableType *type, Container *container, D
void Trace::add_variable(Date &time, VariableType *type, Container *container, Double value, map<string, Value *> &opt) {
if (container && type)
container->add_variable(time, type, value);
if (time > _max_date)
_max_date = time;
// Delete unused extra fields
delete_opt(opt);
}
......@@ -385,10 +383,10 @@ void Trace::add_variable(Date &time, VariableType *type, Container *container, D
void Trace::sub_variable(Date &time, VariableType *type, Container *container, Double value, map<string, Value *> &opt) {
if (container && type)
container->sub_variable(time, type, value);
if (time > _max_date)
_max_date = time;
// Delete unused extra fields
delete_opt(opt);
}
......@@ -396,7 +394,7 @@ void Trace::sub_variable(Date &time, VariableType *type, Container *container, D
void Trace::start_link(Date &time, LinkType *type, Container *ancestor, Container *source, EntityValue *value, String key, map<string, Value *> &opt) {
if (ancestor && type && source)
ancestor->start_link(time, type, source, value, key, opt);
if (time > _max_date)
_max_date = time;
}
......@@ -404,7 +402,7 @@ void Trace::start_link(Date &time, LinkType *type, Container *ancestor, Containe
void Trace::end_link(Date &time, LinkType *type, Container *ancestor, Container *destination, EntityValue * /*value*/, String key, map<string, Value *> &opt) {
if (ancestor && type && destination)
ancestor->end_link(time, destination, key, opt);
if (time > _max_date)
_max_date = time;
}
......@@ -412,31 +410,31 @@ void Trace::end_link(Date &time, LinkType *type, Container *ancestor, Container
void Trace::finish() {
stack<Container *> containers;
const Container::Vector* root_containers =&_view_root_containers;
if(root_containers->empty())root_containers=&_root_containers;
const Container::Vector* root_containers =&_view_root_containers;
if(root_containers->empty())root_containers=&_root_containers;
Container::VectorIt i = root_containers->begin();
Container::VectorIt const &end = root_containers->end();
for (; i != end; i++)
containers.push(*i);
while (!containers.empty()) {
Container * c = containers.top();
containers.pop();
c->finish(_max_date);
{
const Container::Vector* children =c->get_view_children();
if (children->empty())children=c->get_children();
{
const Container::Vector* children =c->get_view_children();
if (children->empty())children=c->get_children();
Container::VectorIt it = children->begin();
Container::VectorIt const &it_end = children->end();
Container::VectorIt it = children->begin();
Container::VectorIt const &it_end = children->end();
for (; it != it_end; it++)
containers.push(*it);
}
for (; it != it_end; it++)
containers.push(*it);
}
}
}
......@@ -444,15 +442,15 @@ void Trace::finish() {
#if defined(USE_ITC) && defined(BOOST_SERIALIZE)
void Trace::updateTrace(Interval* interval){
if(Info::Splitter::load_splitted==true){
if(Info::Splitter::preview==false){
loadTraceInside(interval);
finish();
}else{
loadPreview();
if(Info::Splitter::load_splitted==true){
if(Info::Splitter::preview==false){
loadTraceInside(interval);
finish();
}else{
loadPreview();
}
}
}
}
......@@ -460,63 +458,63 @@ void Trace::loadTraceInside(Interval* interval){
SerializerDispatcher::Instance().init();
stack<Container *> containers;
const Container::Vector* root_containers =&_view_root_containers;
if(root_containers->empty())root_containers=&_root_containers;
if(root_containers->empty())root_containers=&_root_containers;
Container::VectorIt i = root_containers->begin();
Container::VectorIt const &end = root_containers->end();
for (; i != end; i++)
containers.push(*i);
while (!containers.empty()) {
Container * c = containers.top();
c->loadItcInside(interval);
containers.pop();
{
const Container::Vector* children =c->get_view_children();
if (children->empty())children=c->get_children();
{
const Container::Vector* children =c->get_view_children();
if (children->empty())children=c->get_children();
Container::VectorIt it = children->begin();
Container::VectorIt const &it_end = children->end();
Container::VectorIt it = children->begin();
Container::VectorIt const &it_end = children->end();
for (; it != it_end; it++)
containers.push(*it);
}
for (; it != it_end; it++)
containers.push(*it);
}
}
//wait for loading to finish
SerializerDispatcher::Instance().kill_all_threads();
}
//wait for loading to finish
SerializerDispatcher::Instance().kill_all_threads();
}
void Trace::loadPreview (){
stack<Container *> containers;
stack<Container *> containers;
const Container::Vector* root_containers =&_view_root_containers;
if(root_containers->empty())root_containers=&_root_containers;
if(root_containers->empty())root_containers=&_root_containers;
Container::VectorIt i = root_containers->begin();
Container::VectorIt const &end = root_containers->end();
for (; i != end; i++)
containers.push(*i);
while (!containers.empty()) {
Container * c = containers.top();
c->loadPreview();
containers.pop();
{
const Container::Vector* children =c->get_view_children();
if (children->empty())children=c->get_children();
{
const Container::Vector* children =c->get_view_children();
if (children->empty())children=c->get_children();
Container::VectorIt it = children->begin();
Container::VectorIt const &it_end = children->end();
Container::VectorIt it = children->begin();
Container::VectorIt const &it_end = children->end();
for (; it != it_end; it++)
containers.push(*it);
}
}
for (; it != it_end; it++)
containers.push(*it);
}
}
}