- return ret;
-}
-
-/** \ingroup TRACE_category
- * \brief Declare a new category with a random color.
- *
- * This function should be used to define a user category. The category can be used to differentiate the tasks that
- * are created during the simulation (for example, tasks from server1, server2, or request tasks, computation tasks,
- * communication tasks). All resource utilization (host power and link bandwidth) will be classified according to the
- * task category. Tasks that do not belong to a category are not traced. The color for the category that is being
- * declared is random. This function has no effect if a category with the same name has been already declared.
- *
- * See \ref outcomes_vizu for details on how to trace the (categorized) resource utilization.
- *
- * \param category The name of the new tracing category to be created.
- *
- * \see TRACE_category_with_color, MSG_task_set_category, SD_task_set_category
- */
-void TRACE_category(const char *category)
-{
- TRACE_category_with_color (category, nullptr);
-}
-
-/** \ingroup TRACE_category
- * \brief Declare a new category with a color.
- *
- * Same as #TRACE_category, but let user specify a color encoded as a RGB-like string with three floats from 0 to 1.
- * So, to specify a red color, pass "1 0 0" as color parameter. A light-gray color can be specified using "0.7 0.7 0.7"
- * as color. This function has no effect if a category with the same name has been already declared.
- *
- * See \ref outcomes_vizu for details on how to trace the (categorized) resource utilization.
- *
- * \param category The name of the new tracing category to be created.
- * \param color The color of the category (see \ref outcomes_vizu to
- * know how to correctly specify the color)
- *
- * \see MSG_task_set_category, SD_task_set_category
- */
-void TRACE_category_with_color (const char *category, const char *color)
-{
- /* safe switches. tracing has to be activated and if platform is not traced, we can't deal with categories */
- if (not TRACE_is_enabled() || not TRACE_needs_platform())
- return;
-
- if (not(TRACE_categorized() && category != nullptr))
- return;
-
- //check if category is already created
- if (created_categories.find(category) != created_categories.end())
- return;
- else
- created_categories.insert(category);
-
- //define final_color
- std::string final_color;
- if (not color) {
- //generate a random color
- double red = drand48();
- double green = drand48();
- double blue = drand48();
- final_color = std::to_string(red) + " " + std::to_string(green) + " " + std::to_string(blue);
- }else{
- final_color = std::string(color);
- }
-
- XBT_DEBUG("CAT,declare %s, \"%s\" \"%s\"", category, color, final_color.c_str());
-
- //define the type of this category on top of hosts and links
- instr_new_variable_type (category, final_color);
-}
-
-/** \ingroup TRACE_category
- * \brief Get declared categories
- *
- * This function should be used to get categories that were already declared with #TRACE_category or with
- * #TRACE_category_with_color.
- *
- * See \ref outcomes_vizu for details on how to trace the (categorized) resource utilization.
- *
- * \return A dynar with the declared categories, must be freed with xbt_dynar_free.
- *
- * \see MSG_task_set_category, SD_task_set_category
- */
-xbt_dynar_t TRACE_get_categories ()
-{
- if (not TRACE_is_enabled() || not TRACE_categorized())
- return nullptr;
- return instr_set_to_dynar(&created_categories);
-}
-
-/** \ingroup TRACE_mark
- * \brief Declare a new type for tracing mark.
- *
- * This function declares a new Paje event type in the trace file that can be used by simulators to declare
- * application-level marks. This function is independent of which API is used in SimGrid.
- *
- * \param mark_type The name of the new type.
- *
- * \see TRACE_mark
- */
-void TRACE_declare_mark(const char *mark_type)
-{
- /* safe switchs. tracing has to be activated and if platform is not traced, we can't deal with marks */
- if (not TRACE_is_enabled() || not TRACE_needs_platform())
- return;
-
- if (not mark_type)
- THROWF (tracing_error, 1, "mark_type is nullptr");
-
- //check if mark_type is already declared
- if (declared_marks.find(mark_type) != declared_marks.end()) {
- THROWF (tracing_error, 1, "mark_type with name (%s) is already declared", mark_type);
- }
-
- XBT_DEBUG("MARK,declare %s", mark_type);
- simgrid::instr::Container::getRoot()->type_->getOrCreateEventType(mark_type);
- declared_marks.insert(mark_type);
-}
-
-/** \ingroup TRACE_mark
- * \brief Declare a new colored value for a previously declared mark type.
- *
- * This function declares a new colored value for a Paje event type in the trace file that can be used by simulators to
- * declare application-level marks. This function is independent of which API is used in SimGrid. The color needs to be
- * a string with three numbers separated by spaces in the range [0,1].
- * A light-gray color can be specified using "0.7 0.7 0.7" as color. If a nullptr color is provided, the color used will
- * be white ("1 1 1").
- *
- * \param mark_type The name of the new type.
- * \param mark_value The name of the new value for this type.
- * \param mark_color The color of the new value for this type.
- *
- * \see TRACE_mark
- */
-void TRACE_declare_mark_value_with_color (const char *mark_type, const char *mark_value, const char *mark_color)
-{
- /* safe switches. tracing has to be activated and if platform is not traced, we can't deal with marks */
- if (not TRACE_is_enabled() || not TRACE_needs_platform())
- return;
-
- if (not mark_type)
- THROWF (tracing_error, 1, "mark_type is nullptr");
- if (not mark_value)
- THROWF (tracing_error, 1, "mark_value is nullptr");
-
- simgrid::instr::EventType* type =
- static_cast<simgrid::instr::EventType*>(simgrid::instr::Container::getRoot()->type_->byName(mark_type));
- if (not type) {
- THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type);
- } else {
- if (not mark_color)
- mark_color = "1.0 1.0 1.0" /*white*/;
-
- XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color);
- type->addEntityValue(mark_value, mark_color);
- }
-}
-
-/** \ingroup TRACE_mark
- * \brief Declare a new value for a previously declared mark type.
- *
- * This function declares a new value for a Paje event type in the trace file that can be used by simulators to declare
- * application-level marks. This function is independent of which API is used in SimGrid. Calling this function is the
- * same as calling \ref TRACE_declare_mark_value_with_color with a nullptr color.
- *
- * \param mark_type The name of the new type.
- * \param mark_value The name of the new value for this type.
- *
- * \see TRACE_mark
- */
-void TRACE_declare_mark_value (const char *mark_type, const char *mark_value)
-{
- TRACE_declare_mark_value_with_color (mark_type, mark_value, nullptr);
-}
-
-/**
- * \ingroup TRACE_mark
- * \brief Create a new instance of a tracing mark type.
- *
- * This function creates a mark in the trace file. The first parameter had to be previously declared using
- * #TRACE_declare_mark, the second is the identifier for this mark instance. We recommend that the mark_value is a
- * unique value for the whole simulation. Nevertheless, this is not a strong requirement: the trace will be valid even
- * if there are multiple mark identifiers for the same trace.
- *
- * \param mark_type The name of the type for which the new instance will belong.
- * \param mark_value The name of the new instance mark.
- *
- * \see TRACE_declare_mark
- */
-void TRACE_mark(const char *mark_type, const char *mark_value)
-{
- /* safe switches. tracing has to be activated and if platform is not traced, we can't deal with marks */
- if (not TRACE_is_enabled() || not TRACE_needs_platform())
- return;
-
- if (not mark_type)
- THROWF (tracing_error, 1, "mark_type is nullptr");
- if (not mark_value)
- THROWF (tracing_error, 1, "mark_value is nullptr");
-
- //check if mark_type is already declared
- simgrid::instr::EventType* type =
- static_cast<simgrid::instr::EventType*>(simgrid::instr::Container::getRoot()->type_->byName(mark_type));
- if (not type) {
- THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type);
- } else {
- XBT_DEBUG("MARK %s %s", mark_type, mark_value);
- new simgrid::instr::NewEvent(MSG_get_clock(), simgrid::instr::Container::getRoot(), type,
- type->getEntityValue(mark_value));
- }
-}
-
-/** \ingroup TRACE_mark
- * \brief Get declared marks
- *
- * This function should be used to get marks that were already declared with #TRACE_declare_mark.
- *
- * \return A dynar with the declared marks, must be freed with xbt_dynar_free.
- */
-xbt_dynar_t TRACE_get_marks ()
-{
- if (not TRACE_is_enabled())
- return nullptr;
-
- return instr_set_to_dynar(&declared_marks);
-}
-
-static void instr_user_variable(double time, const char* resource, const char* variable_name, const char* father_type,
- double value, InstrUserVariable what, const char* color, std::set<std::string>* filter)