+
+void Container::logCreation()
+{
+ double timestamp = SIMIX_get_clock();
+ std::stringstream stream;
+
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, PAJE_CreateContainer, timestamp);
+
+ if (instr_fmt_type == instr_fmt_paje) {
+ stream << std::fixed << std::setprecision(TRACE_precision()) << PAJE_CreateContainer << " ";
+ /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
+ if (timestamp < 1e-12)
+ stream << 0;
+ else
+ stream << timestamp;
+ stream << " " << id_ << " " << type_->getId() << " " << father_->id_ << " \"" << name_ << "\"";
+ XBT_DEBUG("Dump %s", stream.str().c_str());
+ fprintf(tracing_file, "%s\n", stream.str().c_str());
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ // if we are in the mode with only one file
+ static FILE* ti_unique_file = nullptr;
+
+ if (tracing_files.empty()) {
+ // generate unique run id with time
+ prefix = xbt_os_time();
+ }
+
+ if (not xbt_cfg_get_boolean("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 = fopen(filename.c_str(), "w");
+ xbt_assert(ti_unique_file, "Tracefile %s could not be opened for writing: %s", filename.c_str(), strerror(errno));
+ fprintf(tracing_file, "%s\n", filename.c_str());
+ }
+ tracing_files.insert({this, ti_unique_file});
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+}
+
+void Container::logDestruction()
+{
+ std::stringstream stream;
+ double timestamp = SIMIX_get_clock();
+
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, PAJE_DestroyContainer, timestamp);
+
+ if (instr_fmt_type == instr_fmt_paje) {
+ stream << std::fixed << std::setprecision(TRACE_precision()) << PAJE_DestroyContainer << " ";
+ /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
+ if (timestamp < 1e-12)
+ stream << 0 << " " << type_->getId() << " " << id_;
+ else
+ stream << timestamp << " " << type_->getId() << " " << id_;
+ XBT_DEBUG("Dump %s", stream.str().c_str());
+ fprintf(tracing_file, "%s\n", stream.str().c_str());
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || tracing_files.size() == 1) {
+ fclose(tracing_files.at(this));
+ }
+ tracing_files.erase(this);
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+}
+
+StateType* Container::getState(std::string name)
+{
+ StateType* ret = dynamic_cast<StateType*>(type_->byName(name));
+ ret->setCallingContainer(this);
+ return ret;
+}
+
+LinkType* Container::getLink(std::string name)
+{
+ LinkType* ret = dynamic_cast<LinkType*>(type_->byName(name));
+ ret->setCallingContainer(this);
+ return ret;
+}
+
+VariableType* Container::getVariable(std::string name)
+{
+ VariableType* ret = dynamic_cast<VariableType*>(type_->byName(name));
+ ret->setCallingContainer(this);
+ return ret;
+}