X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6d3020209fdad39e81987f91d375f482be14dee6..8fb33d38a40ca0d377aa543a401d34309514e542:/src/instr/instr_paje_containers.cpp diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index c0ef9ad310..ce918634bc 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -10,28 +10,22 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_containers, instr, "Paje tracing event system (containers)"); -static container_t rootContainer = nullptr; /* the root container */ -static std::map allContainers; /* all created containers indexed by name */ - -long long int instr_new_paje_id () -{ - static long long int type_id = 0; - return type_id++; -} - namespace simgrid { namespace instr { -Container* Container::get_root() +Container* Container::root_container_ = nullptr; /* the root container */ +std::map Container::all_containers_; /* all created containers indexed by name */ + +long long int new_paje_id() { - return rootContainer; + static long long int type_id = 0; + return type_id++; } NetZoneContainer::NetZoneContainer(const std::string& name, unsigned int level, NetZoneContainer* father) : Container::Container(name, "", father) { - netpoint_ = s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()); - xbt_assert(netpoint_, "Element '%s' not found", get_cname()); + xbt_assert(s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()), "Element '%s' not found", get_cname()); if (father_) { std::string type_name = std::string("L") + std::to_string(level); type_ = father_->type_->by_name_or_create(type_name); @@ -39,7 +33,7 @@ NetZoneContainer::NetZoneContainer(const std::string& name, unsigned int level, on_creation(*this); } else { type_ = new ContainerType("0"); - rootContainer = this; + set_root(this); } } @@ -47,18 +41,14 @@ RouterContainer::RouterContainer(const std::string& name, Container* father) : Container::Container(name, "ROUTER", father) { xbt_assert(father, "Only the Root container has no father"); - - netpoint_ = s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()); - xbt_assert(netpoint_, "Element '%s' not found", get_cname()); + xbt_assert(s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()), "Element '%s' not found", get_cname()); } HostContainer::HostContainer(s4u::Host const& host, NetZoneContainer* father) : Container::Container(host.get_name(), "HOST", father) { xbt_assert(father, "Only the Root container has no father"); - - netpoint_ = host.get_netpoint(); - xbt_assert(netpoint_, "Element '%s' not found", host.get_cname()); + xbt_assert(host.get_netpoint(), "Element '%s' not found", host.get_cname()); } Container::Container(const std::string& name, const std::string& type_name, Container* father) @@ -79,9 +69,9 @@ Container::Container(const std::string& name, const std::string& type_name, Cont } //register all kinds by name - if (not allContainers.emplace(name_, this).second) + if (not all_containers_.emplace(name_, this).second) throw TracingError(XBT_THROW_POINT, - xbt::string_printf("container %s already present in allContainers data structure", get_cname())); + xbt::string_printf("container %s already present in all_containers_", get_cname())); XBT_DEBUG("Add container name '%s'", get_cname()); } @@ -93,8 +83,12 @@ Container::~Container() for (auto child : children_) delete child.second; - // remove me from the allContainers data structure - allContainers.erase(name_); + // remove me from the all_containers_ data structure + all_containers_.erase(name_); + + // obligation to dump previous events because they might reference the container that is about to be destroyed + last_timestamp_to_dump = SIMIX_get_clock(); + dump_buffer(true); on_destruction(*this); } @@ -106,8 +100,8 @@ void Container::create_child(const std::string& name, const std::string& type_na Container* Container::by_name_or_null(const std::string& name) { - auto cont = allContainers.find(name); - return cont == allContainers.end() ? nullptr : cont->second; + auto cont = all_containers_.find(name); + return cont == all_containers_.end() ? nullptr : cont->second; } Container* Container::by_name(const std::string& name) @@ -141,5 +135,13 @@ VariableType* Container::get_variable(const std::string& name) { return static_cast(type_->by_name(name)->set_calling_container(this)); } + +EntityValue::EntityValue(const std::string& name, const std::string& color, Type* father) + : name_(name), color_(color), father_(father) +{ + id_ = simgrid::instr::new_paje_id(); + on_creation(*this); +} + } // namespace instr } // namespace simgrid