-/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2019. 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. */
#define INSTR_PAJE_TYPES_HPP
#include "src/instr/instr_private.hpp"
+#include <sstream>
#include <string>
#include <vector>
namespace simgrid {
namespace instr {
-enum e_event_type : unsigned int;
-class EntityValue;
class ContainerType;
class EventType;
-class LinkType;
-class StateType;
-class VariableType;
-class StateEvent;
class Type {
long long int id_;
public:
std::map<std::string, Type*> children_;
+ Container* issuer_ = nullptr;
+ std::stringstream stream_;
- Type(std::string name, std::string alias, std::string color, Type* father);
+ Type(const std::string& name, const std::string& alias, const std::string& color, Type* father);
virtual ~Type();
- std::string getName() { return name_; }
- const char* getCname() { return name_.c_str(); }
- long long int getId() { return id_; }
- bool isColored() { return not color_.empty(); }
+ const std::string& get_name() const { return name_; }
+ const char* get_cname() { return name_.c_str(); }
+ long long int get_id() { return id_; }
+ bool is_colored() { return not color_.empty(); }
- Type* byName(std::string name);
+ Type* by_name(const std::string& name);
+ LinkType* by_name_or_create(const std::string& name, Type* source, Type* dest);
+ VariableType* by_name_or_create(const std::string& name, const std::string& color);
- ContainerType* getOrCreateContainerType(std::string name);
- EventType* getOrCreateEventType(std::string name);
- LinkType* getOrCreateLinkType(std::string name, Type* source, Type* dest);
- StateType* getOrCreateStateType(std::string name);
- VariableType* getOrCreateVariableType(std::string name, std::string color);
+ template <class T> T* by_name_or_create(const std::string& name)
+ {
+ auto cont = children_.find(name);
+ return cont == children_.end() ? new T(name, this) : static_cast<T*>(cont->second);
+ }
- void logDefinition(e_event_type event_type);
- void logDefinition(Type* source, Type* dest);
+ void set_calling_container(Container* container) { issuer_ = container; }
- static ContainerType* createRootType();
- static ContainerType* getRootType();
+ void log_definition(e_event_type event_type);
+ void log_definition(Type* source, Type* dest);
};
class ContainerType : public Type {
public:
- ContainerType(std::string name, Type* father);
+ explicit ContainerType(const std::string& name) : Type(name, name, "", nullptr){};
+ ContainerType(const std::string& name, Type* father);
};
class VariableType : public Type {
+ std::vector<VariableEvent*> events_;
public:
- VariableType(std::string name, std::string color, Type* father);
+ VariableType(const std::string& name, const std::string& color, Type* father);
+ ~VariableType();
+ void instr_event(double now, double delta, const char* resource, double value);
+ void set_event(double timestamp, double value);
+ void add_event(double timestamp, double value);
+ void sub_event(double timestamp, double value);
};
class ValueType : public Type {
public:
std::map<std::string, EntityValue*> values_;
- ValueType(std::string name, std::string alias, Type* father) : Type(name, alias, "", father){};
- ValueType(std::string name, Type* father) : Type(name, name, "", father){};
+ ValueType(const std::string& name, const std::string& alias, Type* father) : Type(name, alias, "", father){};
+ ValueType(const std::string& name, Type* father) : Type(name, name, "", father){};
virtual ~ValueType();
- void addEntityValue(std::string name, std::string color);
- void addEntityValue(std::string name);
- EntityValue* getEntityValue(std::string name);
+ 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);
};
class LinkType : public ValueType {
public:
- LinkType(std::string name, std::string alias, Type* father);
+ LinkType(const std::string& name, const std::string& alias, Type* father);
+ 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 end_event(Container* endContainer, const std::string& value, const std::string& key);
};
class EventType : public ValueType {
public:
- EventType(std::string name, Type* father);
+ EventType(const std::string& name, Type* father);
};
class StateType : public ValueType {
std::vector<StateEvent*> events_;
-
public:
- StateType(std::string name, Type* father);
+ StateType(const std::string& name, Type* father);
~StateType();
- void setEvent(double timestamp, Container* container, std::string value_name);
- void pushEvent(double timestamp, Container* container, std::string value_name);
- void pushEvent(double timestamp, Container* container, std::string value_name, void* extra);
- void popEvent(double timestamp, Container* container);
+ 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);
+ void pop_event();
+ void pop_event(TIData* extra);
};
}
}