+ delete this;
+}
+
+void Container::log_creation()
+{
+ double timestamp = SIMIX_get_clock();
+ std::stringstream stream;
+
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_CreateContainer, timestamp);
+
+ if (trace_format == simgrid::instr::TraceFormat::Paje) {
+ stream << std::fixed << std::setprecision(TRACE_precision()) << PAJE_CreateContainer << " ";
+ stream << timestamp << " " << id_ << " " << type_->get_id() << " " << father_->id_ << " \"";
+ if (name_.find("rank-") != 0)
+ stream << name_ << "\"";
+ else
+ /* Subtract -1 because this is the process id and we transform it to the rank id */
+ stream << "rank-" << stoi(name_.substr(5)) - 1 << "\"";
+
+ XBT_DEBUG("Dump %s", stream.str().c_str());
+ tracing_file << stream.str() << std::endl;
+ } else if (trace_format == simgrid::instr::TraceFormat::Ti) {
+ // if we are in the mode with only one file
+ static std::ofstream* ti_unique_file = nullptr;
+
+ if (tracing_files.empty()) {
+ // generate unique run id with time
+ prefix = xbt_os_time();
+ }
+
+ if (not simgrid::config::get_value<bool>("tracing/smpi/format/ti-one-file") || ti_unique_file == nullptr) {
+ std::string folder_name = TRACE_get_filename() + "_files";
+ std::string filename = folder_name + "/" + std::to_string(prefix) + "_" + name_ + ".txt";
+#ifdef WIN32
+ _mkdir(folder_name.c_str());
+#else
+ mkdir(folder_name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
+#endif
+ ti_unique_file = new std::ofstream(filename.c_str(), std::ofstream::out);
+ xbt_assert(not ti_unique_file->fail(), "Tracefile %s could not be opened for writing", filename.c_str());
+ tracing_file << filename << std::endl;
+ }
+ tracing_files.insert({this, ti_unique_file});
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+}
+
+void Container::log_destruction()
+{
+ std::stringstream stream;
+ double timestamp = SIMIX_get_clock();
+
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_DestroyContainer, timestamp);
+
+ if (trace_format == simgrid::instr::TraceFormat::Paje) {
+ stream << std::fixed << std::setprecision(TRACE_precision()) << PAJE_DestroyContainer << " ";
+ stream << timestamp << " " << type_->get_id() << " " << id_;
+ XBT_DEBUG("Dump %s", stream.str().c_str());
+ tracing_file << stream.str() << std::endl;
+ } else if (trace_format == simgrid::instr::TraceFormat::Ti) {
+ if (not simgrid::config::get_value<bool>("tracing/smpi/format/ti-one-file") || tracing_files.size() == 1) {
+ tracing_files.at(this)->close();
+ delete tracing_files.at(this);
+ }
+ tracing_files.erase(this);
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+}
+
+StateType* Container::get_state(const std::string& name)
+{
+ StateType* ret = static_cast<StateType*>(type_->by_name(name));
+ ret->set_calling_container(this);
+ return ret;
+}
+
+LinkType* Container::get_link(const std::string& name)
+{
+ LinkType* ret = static_cast<LinkType*>(type_->by_name(name));
+ ret->set_calling_container(this);
+ return ret;
+}
+
+VariableType* Container::get_variable(const std::string& name)
+{
+ VariableType* ret = static_cast<VariableType*>(type_->by_name(name));
+ ret->set_calling_container(this);
+ return ret;