Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill a C type now that we have a class
[simgrid.git] / src / instr / instr_private.h
index 81be1f4..bc9a49c 100644 (file)
@@ -8,10 +8,11 @@
 
 #include <xbt/base.h>
 
-#include "simgrid/instr.h"
 #include "instr/instr_interface.h"
-#include "src/internal_config.h"
+#include "simgrid/instr.h"
 #include "simgrid_config.h"
+#include "src/internal_config.h"
+#include <set>
 
 SG_BEGIN_DECL()
 
@@ -56,33 +57,41 @@ typedef enum {
 } e_entity_types;
 
 //--------------------------------------------------
-class s_type;
-typedef s_type *type_t;
-class s_type {
-  public:
+
+class Type {
+public:
   char *id;
   char *name;
   char *color;
+
   e_entity_types kind;
-  s_type *father;
+  Type *father;
   xbt_dict_t children;
   xbt_dict_t values; //valid for all types except variable and container
+  Type(const char* typeNameBuff, const char* key, const char* color, e_entity_types kind, Type* father);
+  static Type* getOrNull(const char* name, Type* father);
+  static Type* containerNew(const char* name, Type* father);
+  static Type* eventNew(const char* name, Type* father);
+  static Type* variableNew(const char* name, const char* color, Type* father);
+  static Type* linkNew(const char* name, Type* father, Type* source, Type* dest);
+  static Type* stateNew(const char* name, Type* father);
 };
 
-typedef s_type s_type_t;
-
 //--------------------------------------------------
-class s_val;
-typedef s_val *val_t;
-
-class s_val {
-  public:
-  char *id;
-  char *name;
-  char *color;
-  type_t father;
+class Value {
+public:
+  char* id;
+  char* name;
+  char* color;
+
+  Type* father;
+  Value* ret;
+  Value(const char* name, const char* color, Type* father);
+  ~Value();
+  static Value* get_or_new(const char* name, const char* color, Type* father);
+  static Value* get(const char* name, Type* father);
 };
-typedef s_val s_val_t;
+
 
 //--------------------------------------------------
 typedef enum {
@@ -101,17 +110,16 @@ class s_container;
 typedef s_container *container_t;
 
 class s_container {
-  public: 
+  public:
   sg_netpoint_t netpoint;
   char *name;     /* Unique name of this container */
   char *id;       /* Unique id of this container */
-  type_t type;    /* Type of this container */
+  Type* type;     /* Type of this container */
   int level;      /* Level in the hierarchy, root level is 0 */
   e_container_types kind; /* This container is of what kind */
   s_container *father;
   xbt_dict_t children;
 };
-typedef s_container s_container_t;
 
 //--------------------------------------------------
 class PajeEvent {
@@ -123,198 +131,155 @@ class PajeEvent {
   virtual ~PajeEvent();
 };
 
-class DefineContainerEvent : public PajeEvent
-{
-  public:
-  type_t type;
-  void print() override;
-  DefineContainerEvent(type_t);
-};
-
 //--------------------------------------------------
 
-
-//--------------------------------------------------
-
-class DefineVariableTypeEvent : public PajeEvent 
+class DefineVariableTypeEvent : public PajeEvent
 {
   public:
-  type_t type;
-   DefineVariableTypeEvent(type_t type);
-   void print() override;
+    Type* type;
+    DefineVariableTypeEvent(Type* type);
+    void print() override;
 };
 //--------------------------------------------------
 
 class DefineStateTypeEvent : public PajeEvent  {
-  type_t type;
-  public:
-  DefineStateTypeEvent(type_t type);
-  void print() override;
-};
-
-class DefineEventTypeEvent : public PajeEvent  {
-  type_t type;
-  public: 
-  DefineEventTypeEvent(type_t type);
-  void print() override;
-};
-
-class DefineLinkTypeEvent : public PajeEvent  {
-  type_t type;
-  type_t source;
-  type_t dest;
-  public:
-  DefineLinkTypeEvent(type_t type, type_t source, type_t dest);
-  void print() override;
-};
-
-class DefineEntityValueEvent : public PajeEvent  {
-  val_t value;
-  public:
-  DefineEntityValueEvent (val_t type);
-  void print() override;
-};
-
-class CreateContainerEvent : public PajeEvent  {
-  public:
-  container_t container;
-  explicit CreateContainerEvent (container_t container);
-  void print() override;
-};
+  Type* type;
 
-class DestroyContainerEvent : public PajeEvent  {
-  public:
-  container_t container;
-  DestroyContainerEvent (container_t container);
+public:
+  DefineStateTypeEvent(Type* type);
   void print() override;
 };
 
 
 class SetVariableEvent : public PajeEvent  {
+  private:
   container_t container;
-  type_t type;
+  Type* type;
   double value;
   public:
-  SetVariableEvent (double timestamp, container_t container, type_t type, double value);
-  void print() override;
+    SetVariableEvent(double timestamp, container_t container, Type* type, double value);
+    void print() override;
 };
 
 
 class AddVariableEvent:public PajeEvent {
+  private:
   container_t container;
-  type_t type;
+  Type* type;
   double value;
   public:
-  AddVariableEvent (double timestamp, container_t container, type_t type, double value);
-  void print() override;
+    AddVariableEvent(double timestamp, container_t container, Type* type, double value);
+    void print() override;
 };
 
 //--------------------------------------------------
 
 
 class SubVariableEvent : public PajeEvent  {
-  public:
+  private:
   container_t container;
-  type_t type;
-  double value; 
+  Type* type;
+  double value;
   public:
-  SubVariableEvent(double timestamp, container_t container, type_t type, double value);
-  void print() override;
+    SubVariableEvent(double timestamp, container_t container, Type* type, double value);
+    void print() override;
 };
 //--------------------------------------------------
 
 class SetStateEvent : public PajeEvent  {
-  public:
+  private:
   container_t container;
-  type_t type;
-  val_t value;
+  Type* type;
+  Value* val;
   const char* filename;
   int linenumber;
   public:
-  SetStateEvent (double timestamp, container_t container, type_t type, val_t value);
-  void print() override;
+    SetStateEvent(double timestamp, container_t container, Type* type, Value* val);
+    void print() override;
 };
 
 
 class PushStateEvent : public PajeEvent  {
   public:
   container_t container;
-  type_t type;
-  val_t value;
+  Type* type;
+  Value* val;
   int size;
   const char* filename;
   int linenumber;
   void* extra_;
   public:
-  PushStateEvent (double timestamp, container_t container, type_t type, val_t value);
-  PushStateEvent (double timestamp, container_t container, type_t type, val_t value,
-                                             void* extra);
-  void print() override;
+    PushStateEvent(double timestamp, container_t container, Type* type, Value* val);
+    PushStateEvent(double timestamp, container_t container, Type* type, Value* val, void* extra);
+    void print() override;
 };
 
 class PopStateEvent : public PajeEvent  {
   container_t container;
-  type_t type;
-  xbt_dynar_t extra;
-  public:
-  PopStateEvent (double timestamp, container_t container, type_t type);
+  Type* type;
+
+public:
+  PopStateEvent(double timestamp, container_t container, Type* type);
   void print() override;
 };
 
 class ResetStateEvent : public PajeEvent  {
   container_t container;
-  type_t type;
-  public:
-  ResetStateEvent (double timestamp, container_t container, type_t type);
+  Type* type;
+
+public:
+  ResetStateEvent(double timestamp, container_t container, Type* type);
   void print() override;
 };
 
 class StartLinkEvent : public PajeEvent  {
   public:
   container_t container;
-  type_t type;
+  Type* type;
   container_t sourceContainer;
   char *value;
   char *key;
   int size;
   public:
-  StartLinkEvent (double timestamp, container_t container, type_t type, container_t sourceContainer,
-                                    const char *value, const char *key);
-  StartLinkEvent (double timestamp, container_t container, type_t type,
-                                            container_t sourceContainer, const char *value, const char *key, int size);
-  void print() override;
+    ~StartLinkEvent();
+    StartLinkEvent(double timestamp, container_t container, Type* type, container_t sourceContainer, const char* value,
+                   const char* key);
+    StartLinkEvent(double timestamp, container_t container, Type* type, container_t sourceContainer, const char* value,
+                   const char* key, int size);
+    void print() override;
 };
 
 class EndLinkEvent : public PajeEvent  {
   container_t container;
-  type_t type;
+  Type* type;
   container_t destContainer;
   char *value;
   char *key;
   public:
-  EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer,
-                                  const char *value, const char *key);
-  void print() override;
+    EndLinkEvent(double timestamp, container_t container, Type* type, container_t destContainer, const char* value,
+                 const char* key);
+    ~EndLinkEvent();
+    void print() override;
 };
 
 
 class NewEvent : public PajeEvent  {
   public:
   container_t container;
-  type_t type;
-  val_t value;
-  public:
-  NewEvent (double timestamp, container_t container, type_t type, val_t value);
+  Type* type;
+  Value* val;
+
+public:
+  NewEvent(double timestamp, container_t container, Type* type, Value* val);
   void print() override;
 
 };
 
-
-extern XBT_PRIVATE xbt_dict_t created_categories;
-extern XBT_PRIVATE xbt_dict_t declared_marks;
-extern XBT_PRIVATE xbt_dict_t user_host_variables;
-extern XBT_PRIVATE xbt_dict_t user_vm_variables;
-extern XBT_PRIVATE xbt_dict_t user_link_variables;
+extern XBT_PRIVATE std::set<std::string> created_categories;
+extern XBT_PRIVATE std::set<std::string> declared_marks;
+extern XBT_PRIVATE std::set<std::string> user_host_variables;
+extern XBT_PRIVATE std::set<std::string> user_vm_variables;
+extern XBT_PRIVATE std::set<std::string> user_link_variables;
 extern XBT_PRIVATE double TRACE_last_timestamp_to_dump;
 
 /* instr_paje_header.c */
@@ -369,8 +334,8 @@ XBT_PRIVATE void TRACE_surf_link_set_utilization(const char *resource,const char
 XBT_PUBLIC(void) TRACE_surf_resource_utilization_alloc();
 
 /* instr_paje.c */
-extern XBT_PRIVATE xbt_dict_t trivaNodeTypes;
-extern XBT_PRIVATE xbt_dict_t trivaEdgeTypes;
+extern XBT_PRIVATE std::set<std::string> trivaNodeTypes;
+extern XBT_PRIVATE std::set<std::string> trivaEdgeTypes;
 XBT_PRIVATE long long int instr_new_paje_id ();
 XBT_PRIVATE void PJ_container_alloc ();
 XBT_PRIVATE void PJ_container_release ();
@@ -384,73 +349,21 @@ XBT_PUBLIC(void) PJ_container_free_all (void);
 XBT_PUBLIC(void) PJ_container_remove_from_parent (container_t container);
 
 /* instr_paje_types.c */
-XBT_PRIVATE void PJ_type_alloc ();
 XBT_PRIVATE void PJ_type_release ();
-XBT_PUBLIC(type_t)  PJ_type_get_root ();
-XBT_PRIVATE type_t PJ_type_container_new (const char *name, type_t father);
-XBT_PRIVATE type_t PJ_type_event_new (const char *name, type_t father);
-type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest);
-XBT_PRIVATE XBT_PRIVATE type_t PJ_type_variable_new (const char *name, const char *color, type_t father);
-XBT_PRIVATE type_t PJ_type_state_new (const char *name, type_t father);
-XBT_PUBLIC(type_t)  PJ_type_get (const char *name, const type_t father);
-XBT_PUBLIC(type_t)  PJ_type_get_or_null (const char *name, type_t father);
-void PJ_type_free_all ();
-XBT_PRIVATE XBT_PRIVATE void PJ_type_free (type_t type);
-
-/* instr_paje_values.c */
-XBT_PUBLIC(val_t)  PJ_value_new (const char *name, const char *color, type_t father);
-XBT_PUBLIC(val_t)  PJ_value_get_or_new (const char *name, const char *color, type_t father);
-XBT_PUBLIC(val_t)  PJ_value_get (const char *name, const type_t father);
-XBT_PRIVATE void PJ_value_free (val_t value);
-
-XBT_PRIVATE void print_pajeDefineContainerType(PajeEvent* event);
-XBT_PRIVATE void print_pajeDefineVariableType(PajeEvent* event);
-XBT_PRIVATE void print_pajeDefineStateType(PajeEvent* event);
-XBT_PRIVATE void print_pajeDefineEventType(PajeEvent* event);
-XBT_PRIVATE void print_pajeDefineLinkType(PajeEvent* event);
-XBT_PRIVATE void print_pajeDefineEntityValue (PajeEvent* event);
-XBT_PRIVATE void print_pajeCreateContainer(PajeEvent* event);
-XBT_PRIVATE void print_pajeDestroyContainer(PajeEvent* event);
-XBT_PRIVATE void print_pajeSetVariable(PajeEvent* event);
-XBT_PRIVATE void print_pajeAddVariable(PajeEvent* event);
-XBT_PRIVATE void print_pajeSubVariable(PajeEvent* event);
-XBT_PRIVATE void print_pajeSetState(PajeEvent* event);
-XBT_PRIVATE void print_pajePushState(PajeEvent* event);
-XBT_PRIVATE void print_pajePopState(PajeEvent* event);
-XBT_PRIVATE void print_pajeResetState(PajeEvent* event);
-XBT_PRIVATE void print_pajeStartLink(PajeEvent* event);
-XBT_PRIVATE void print_pajeEndLink(PajeEvent* event);
-XBT_PRIVATE void print_pajeNewEvent (PajeEvent* event);
+XBT_PUBLIC(Type*) PJ_type_get_root();
+XBT_PUBLIC(Type*) PJ_type_get(const char* name, Type* father);
+XBT_PRIVATE XBT_PRIVATE void PJ_type_free(Type* type);
+
+/* instr_config.c */
+XBT_PRIVATE void recursiveDestroyType(Type* type);
 
 XBT_PRIVATE void TRACE_TI_start();
 XBT_PRIVATE void TRACE_TI_end();
 
-XBT_PRIVATE void print_NULL (PajeEvent* event);
 XBT_PRIVATE void TRACE_paje_dump_buffer (int force);
 XBT_PRIVATE void dump_comment_file (const char *filename);
 XBT_PRIVATE void dump_comment (const char *comment);
 
-typedef struct instr_trace_writer {
-  void (*print_DefineContainerType) (PajeEvent* event);
-  void (*print_DefineVariableType)(PajeEvent* event);
-  void (*print_DefineStateType)(PajeEvent* event);
-  void (*print_DefineEventType)(PajeEvent* event);
-  void (*print_DefineLinkType)(PajeEvent* event);
-  void (*print_DefineEntityValue)(PajeEvent* event);
-  void (*print_CreateContainer)(PajeEvent* event);
-  void (*print_DestroyContainer)(PajeEvent* event);
-  void (*print_SetVariable)(PajeEvent* event);
-  void (*print_AddVariable)(PajeEvent* event);
-  void (*print_SubVariable)(PajeEvent* event);
-  void (*print_SetState)(PajeEvent* event);
-  void (*print_PushState)(PajeEvent* event);
-  void (*print_PopState)(PajeEvent* event);
-  void (*print_ResetState)(PajeEvent* event);
-  void (*print_StartLink)(PajeEvent* event);
-  void (*print_EndLink)(PajeEvent* event);
-  void (*print_NewEvent) (PajeEvent* event);
-} s_instr_trace_writer_t;
-
 struct s_instr_extra_data;
 typedef struct s_instr_extra_data *instr_extra_data;
 
@@ -516,4 +429,13 @@ extern instr_fmt_type_t instr_fmt_type;
 
 SG_END_DECL()
 
+void DefineContainerEvent(Type* type);
+void LogVariableTypeDefinition(Type* type);
+void LogStateTypeDefinition(Type* type);
+void LogLinkTypeDefinition(Type* type, Type* source, Type* dest);
+void LogEntityValue(Value* val);
+void LogContainerCreation (container_t container);
+void LogContainerDestruction (container_t container);
+void LogDefineEventType(Type* type);
+
 #endif