Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Convert int -> size_t for TRACE_smpi_send (and below).
[simgrid.git] / src / instr / instr_paje_types.hpp
index f4dae73..a5e31d4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,21 +16,23 @@ namespace instr {
 class ContainerType;
 class EventType;
 
+long long int new_paje_id();
+
 class Type {
-  long long int id_;
+  long long int id_ = new_paje_id();
   std::string name_;
   std::string color_;
   Type* father_;
-  std::map<std::string, std::unique_ptr<Type>> children_;
+  std::map<std::string, std::unique_ptr<Type>, std::less<>> children_;
   Container* issuer_ = nullptr;
 
 protected:
   Container* get_issuer() const { return issuer_; }
 
 public:
-  static xbt::signal<void(Type const&, e_event_type event_type)> on_creation;
+  static xbt::signal<void(Type const&, PajeEventType event_type)> on_creation;
 
-  Type(e_event_type event_type, const std::string& name, const std::string& alias, const std::string& color,
+  Type(PajeEventType event_type, const std::string& name, const std::string& alias, const std::string& color,
        Type* father);
   virtual ~Type() = default;
 
@@ -39,7 +41,7 @@ public:
   const char* get_cname() const { return name_.c_str(); }
   const std::string& get_color() const { return color_; }
   Type* get_father() const { return father_; }
-  const std::map<std::string, std::unique_ptr<Type>>& get_children() const { return children_; }
+  const std::map<std::string, std::unique_ptr<Type>, std::less<>>& get_children() const { return children_; }
   bool is_colored() const { return not color_.empty(); }
 
   Type* by_name(const std::string& name);
@@ -61,15 +63,16 @@ public:
 
 class ContainerType : public Type {
 public:
-  explicit ContainerType(const std::string& name) : Type(PAJE_DefineContainerType, name, name, "", nullptr){};
-  ContainerType(const std::string& name, Type* father) : Type(PAJE_DefineContainerType, name, name, "", father){};
+  explicit ContainerType(const std::string& name) : Type(PajeEventType::DefineContainerType, name, name, "", nullptr){};
+  ContainerType(const std::string& name, Type* father)
+      : Type(PajeEventType::DefineContainerType, name, name, "", father){};
 };
 
 class VariableType : public Type {
   std::vector<VariableEvent*> events_;
 public:
   VariableType(const std::string& name, const std::string& color, Type* father)
-      : Type(PAJE_DefineVariableType, name, name, color, father)
+      : Type(PajeEventType::DefineVariableType, name, name, color, father)
   {
   }
   void instr_event(double now, double delta, const char* resource, double value);
@@ -80,12 +83,11 @@ public:
 
 class ValueType : public Type {
 public:
-  std::map<std::string, EntityValue> values_;
-  ValueType(e_event_type event_type, const std::string& name, const std::string& alias, Type* father)
+  std::map<std::string, EntityValue, std::less<>> values_;
+  ValueType(PajeEventType event_type, const std::string& name, const std::string& alias, Type* father)
       : Type(event_type, name, alias, "", father){};
-  ValueType(e_event_type event_type, const std::string& name, Type* father)
+  ValueType(PajeEventType event_type, const std::string& name, Type* father)
       : Type(event_type, name, name, "", father){};
-  ~ValueType() override = default;
   void add_entity_value(const std::string& name, const std::string& color);
   void add_entity_value(const std::string& name);
   EntityValue* get_entity_value(const std::string& name);
@@ -95,24 +97,24 @@ class LinkType : public ValueType {
 public:
   static xbt::signal<void(LinkType const&, Type const&, Type const&)> on_creation;
   LinkType(const std::string& name, const Type* source, const Type* dest, const std::string& alias, Type* father)
-      : ValueType(PAJE_DefineLinkType, name, alias, father)
+      : ValueType(PajeEventType::DefineLinkType, name, alias, father)
   {
     on_creation(*this, *source, *dest);
   }
-  void start_event(Container* startContainer, const std::string& value, const std::string& key);
-  void start_event(Container* startContainer, const std::string& value, const std::string& key, int size);
+  void start_event(Container* startContainer, const std::string& value, const std::string& key,
+                   size_t size = static_cast<size_t>(-1));
   void end_event(Container* endContainer, const std::string& value, const std::string& key);
 };
 
 class EventType : public ValueType {
 public:
-  EventType(const std::string& name, Type* father) : ValueType(PAJE_DefineEventType, name, father) {}
+  EventType(const std::string& name, Type* father) : ValueType(PajeEventType::DefineEventType, name, father) {}
 };
 
 class StateType : public ValueType {
   std::vector<StateEvent*> events_;
 public:
-  StateType(const std::string& name, Type* father) : ValueType(PAJE_DefineStateType, name, father) {}
+  StateType(const std::string& name, Type* father) : ValueType(PajeEventType::DefineStateType, name, father) {}
   void set_event(const std::string& value_name);
   void push_event(const std::string& value_name);
   void push_event(const std::string& value_name, TIData* extra);