*************/
xbt::signal<void(Container const&)> Container::on_creation;
xbt::signal<void(Container const&)> Container::on_destruction;
-xbt::signal<void(Type const&, e_event_type)> Type::on_creation;
+xbt::signal<void(Type const&, PajeEventType)> Type::on_creation;
xbt::signal<void(LinkType const&, Type const&, Type const&)> LinkType::on_creation;
xbt::signal<void(PajeEvent&)> PajeEvent::on_creation;
xbt::signal<void(PajeEvent const&)> PajeEvent::on_destruction;
double timestamp = SIMIX_get_clock();
std::stringstream stream;
- XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_CreateContainer, timestamp);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, static_cast<unsigned>(PajeEventType::CreateContainer),
+ timestamp);
- stream << std::fixed << std::setprecision(trace_precision) << PAJE_CreateContainer << " ";
+ stream << std::fixed << std::setprecision(trace_precision) << PajeEventType::CreateContainer << " ";
stream << timestamp << " " << c.get_id() << " " << c.type_->get_id() << " " << c.father_->get_id() << " \"";
if (c.get_name().find("rank-") != 0)
stream << c.get_name() << "\"";
std::stringstream stream;
double timestamp = SIMIX_get_clock();
- XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_DestroyContainer, timestamp);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, static_cast<unsigned>(PajeEventType::DestroyContainer),
+ timestamp);
- stream << std::fixed << std::setprecision(trace_precision) << PAJE_DestroyContainer << " ";
+ stream << std::fixed << std::setprecision(trace_precision) << PajeEventType::DestroyContainer << " ";
stream << timestamp << " " << c.type_->get_id() << " " << c.get_id();
XBT_DEBUG("Dump %s", stream.str().c_str());
tracing_file << stream.str() << std::endl;
static void on_container_creation_ti(const Container& c)
{
- XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_CreateContainer, SIMIX_get_clock());
+ XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, static_cast<unsigned>(PajeEventType::CreateContainer),
+ SIMIX_get_clock());
// if we are in the mode with only one file
static std::ofstream* ti_unique_file = nullptr;
static void on_entity_value_creation(const EntityValue& value)
{
std::stringstream stream;
- XBT_DEBUG("%s: event_type=%u", __func__, PAJE_DefineEntityValue);
- stream << std::fixed << std::setprecision(trace_precision) << PAJE_DefineEntityValue;
+ XBT_DEBUG("%s: event_type=%u", __func__, static_cast<unsigned>(PajeEventType::DefineEntityValue));
+ stream << std::fixed << std::setprecision(trace_precision) << PajeEventType::DefineEntityValue;
stream << " " << value.get_id() << " " << value.get_father()->get_id() << " " << value.get_name();
if (not value.get_color().empty())
stream << " \"" << value.get_color() << "\"";
static void on_event_creation(PajeEvent& event)
{
- XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, event.eventType_, trace_precision, event.timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, static_cast<unsigned>(event.eventType_), trace_precision,
+ event.timestamp_);
event.stream_ << std::fixed << std::setprecision(trace_precision);
event.stream_ << event.eventType_ << " " << event.timestamp_ << " ";
event.stream_ << event.get_type()->get_id() << " " << event.get_container()->get_id();
*tracing_files.at(event.get_container()) << event.stream_.str() << std::endl;
}
-static void on_type_creation(const Type& type, e_event_type event_type)
+static void on_type_creation(const Type& type, PajeEventType event_type)
{
- if (event_type == PAJE_DefineLinkType)
+ if (event_type == PajeEventType::DefineLinkType)
return; // this kind of type has to be handled differently
std::stringstream stream;
stream << std::fixed << std::setprecision(trace_precision);
- XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, event_type, trace_precision, 0.);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, static_cast<unsigned>(event_type), trace_precision, 0.);
stream << event_type << " " << type.get_id() << " " << type.get_father()->get_id() << " " << type.get_name();
if (type.is_colored())
stream << " \"" << type.get_color() << "\"";
static void on_link_type_creation(const Type& type, const Type& source, const Type& dest)
{
std::stringstream stream;
- XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, PAJE_DefineLinkType, trace_precision, 0.);
- stream << PAJE_DefineLinkType << " " << type.get_id() << " " << type.get_father()->get_id();
+ XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, static_cast<unsigned>(PajeEventType::DefineLinkType),
+ trace_precision, 0.);
+ stream << PajeEventType::DefineLinkType << " " << type.get_id() << " " << type.get_father()->get_id();
stream << " " << source.get_id() << " " << dest.get_id() << " " << type.get_name();
XBT_DEBUG("Dump %s", stream.str().c_str());
tracing_file << stream.str() << std::endl;
namespace simgrid {
namespace instr {
-PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, e_event_type eventType)
+PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, PajeEventType eventType)
: container_(container), type_(type), timestamp_(timestamp), eventType_(eventType)
{
on_creation(*this);
on_destruction(*this);
}
-StateEvent::StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra)
+StateEvent::StateEvent(Container* container, Type* type, PajeEventType event_type, EntityValue* value, TIData* extra)
: PajeEvent::PajeEvent(container, type, SIMIX_get_clock(), event_type), value(value), extra_(extra)
{
#if HAVE_SMPI
void StateEvent::print()
{
if (trace_format == TraceFormat::Paje) {
- if (value != nullptr) // PAJE_PopState Event does not need to have a value
+ if (value != nullptr) // PajeEventType::PopState Event does not need to have a value
stream_ << " " << value->get_id();
if (TRACE_display_sizes())
class EntityValue;
class TIData;
-enum e_event_type : unsigned int {
- PAJE_DefineContainerType,
- PAJE_DefineVariableType,
- PAJE_DefineStateType,
- PAJE_DefineEventType,
- PAJE_DefineLinkType,
- PAJE_DefineEntityValue,
- PAJE_CreateContainer,
- PAJE_DestroyContainer,
- PAJE_SetVariable,
- PAJE_AddVariable,
- PAJE_SubVariable,
- PAJE_SetState,
- PAJE_PushState,
- PAJE_PopState,
- PAJE_ResetState,
- PAJE_StartLink,
- PAJE_EndLink,
- PAJE_NewEvent
+enum class PajeEventType : unsigned int {
+ DefineContainerType,
+ DefineVariableType,
+ DefineStateType,
+ DefineEventType,
+ DefineLinkType,
+ DefineEntityValue,
+ CreateContainer,
+ DestroyContainer,
+ SetVariable,
+ AddVariable,
+ SubVariable,
+ SetState,
+ PushState,
+ PopState,
+ ResetState,
+ StartLink,
+ EndLink,
+ NewEvent
};
+inline std::ostream& operator<<(std::ostream& os, PajeEventType event)
+{
+ return os << static_cast<std::underlying_type<PajeEventType>::type>(event);
+}
+
class PajeEvent {
Container* container_;
Type* type_;
static xbt::signal<void(PajeEvent const&)> on_destruction;
double timestamp_;
- e_event_type eventType_;
+ PajeEventType eventType_;
std::stringstream stream_;
- PajeEvent(Container* container, Type* type, double timestamp, e_event_type eventType);
+ PajeEvent(Container* container, Type* type, double timestamp, PajeEventType eventType);
virtual ~PajeEvent();
Container* get_container() const { return container_; }
double value_;
public:
- VariableEvent(double timestamp, Container* container, Type* type, e_event_type event_type, double value)
+ VariableEvent(double timestamp, Container* container, Type* type, PajeEventType event_type, double value)
: PajeEvent::PajeEvent(container, type, timestamp, event_type), value_(value)
{
}
public:
static xbt::signal<void(StateEvent const&)> on_destruction;
- StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra);
+ StateEvent(Container* container, Type* type, PajeEventType event_type, EntityValue* value, TIData* extra);
~StateEvent() override { on_destruction(*this); }
bool has_extra() const { return extra_ != nullptr; }
void print() override;
int size_ = -1;
public:
- LinkEvent(Container* container, Type* type, e_event_type event_type, Container* sourceContainer,
+ LinkEvent(Container* container, Type* type, PajeEventType event_type, Container* sourceContainer,
const std::string& value, const std::string& key, int size)
: PajeEvent(container, type, SIMIX_get_clock(), event_type)
, endpoint_(sourceContainer)
public:
NewEvent(double timestamp, Container* container, Type* type, EntityValue* value)
- : PajeEvent::PajeEvent(container, type, timestamp, PAJE_NewEvent), value(value)
+ : PajeEvent::PajeEvent(container, type, timestamp, PajeEventType::NewEvent), value(value)
{
}
void print() override;
void dump_header(bool basic, bool display_sizes)
{
// Types
- tracing_file << "%EventDef PajeDefineContainerType " << PAJE_DefineContainerType << std::endl;
+ tracing_file << "%EventDef PajeDefineContainerType " << PajeEventType::DefineContainerType << std::endl;
tracing_file << "% Alias string" << std::endl;
if (basic)
tracing_file << "% ContainerType string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeDefineVariableType " << PAJE_DefineVariableType << std::endl;
+ tracing_file << "%EventDef PajeDefineVariableType " << PajeEventType::DefineVariableType << std::endl;
tracing_file << "% Alias string" << std::endl;
tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "% Color color" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeDefineStateType " << PAJE_DefineStateType << std::endl;
+ tracing_file << "%EventDef PajeDefineStateType " << PajeEventType::DefineStateType << std::endl;
tracing_file << "% Alias string" << std::endl;
tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeDefineEventType " << PAJE_DefineEventType << std::endl;
+ tracing_file << "%EventDef PajeDefineEventType " << PajeEventType::DefineEventType << std::endl;
tracing_file << "% Alias string" << std::endl;
tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeDefineLinkType " << PAJE_DefineLinkType << std::endl;
+ tracing_file << "%EventDef PajeDefineLinkType " << PajeEventType::DefineLinkType << std::endl;
tracing_file << "% Alias string" << std::endl;
tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl;
tracing_file << "% " << (basic ? "Source" : "Start") << "ContainerType string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
// EntityValue
- tracing_file << "%EventDef PajeDefineEntityValue " << PAJE_DefineEntityValue << std::endl;
+ tracing_file << "%EventDef PajeDefineEntityValue " << PajeEventType::DefineEntityValue << std::endl;
tracing_file << "% Alias string" << std::endl;
tracing_file << "% " << (basic ? "Entity" : "") << "Type string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
// Container
- tracing_file << "%EventDef PajeCreateContainer " << PAJE_CreateContainer << std::endl;
+ tracing_file << "%EventDef PajeCreateContainer " << PajeEventType::CreateContainer << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Alias string" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeDestroyContainer " << PAJE_DestroyContainer << std::endl;
+ tracing_file << "%EventDef PajeDestroyContainer " << PajeEventType::DestroyContainer << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
// Variable
- tracing_file << "%EventDef PajeSetVariable " << PAJE_SetVariable << std::endl;
+ tracing_file << "%EventDef PajeSetVariable " << PajeEventType::SetVariable << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "% Value double" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeAddVariable " << PAJE_AddVariable << std::endl;
+ tracing_file << "%EventDef PajeAddVariable " << PajeEventType::AddVariable << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "% Value double" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeSubVariable " << PAJE_SubVariable << std::endl;
+ tracing_file << "%EventDef PajeSubVariable " << PajeEventType::SubVariable << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
// State
- tracing_file << "%EventDef PajeSetState " << PAJE_SetState << std::endl;
+ tracing_file << "%EventDef PajeSetState " << PajeEventType::SetState << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "% Value string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajePushState " << PAJE_PushState << std::endl;
+ tracing_file << "%EventDef PajePushState " << PajeEventType::PushState << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
#endif
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajePopState " << PAJE_PopState << std::endl;
+ tracing_file << "%EventDef PajePopState " << PajeEventType::PopState << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
if (not basic) {
- tracing_file << "%EventDef PajeResetState " << PAJE_ResetState << std::endl;
+ tracing_file << "%EventDef PajeResetState " << PajeEventType::ResetState << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
}
// Link
- tracing_file << "%EventDef PajeStartLink " << PAJE_StartLink << std::endl;
+ tracing_file << "%EventDef PajeStartLink " << PajeEventType::StartLink << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "% Size int" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeEndLink " << PAJE_EndLink << std::endl;
+ tracing_file << "%EventDef PajeEndLink " << PajeEventType::EndLink << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
// Event
- tracing_file << "%EventDef PajeNewEvent " << PAJE_NewEvent << std::endl;
+ tracing_file << "%EventDef PajeNewEvent " << PajeEventType::NewEvent << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
/* internal do the instrumentation module */
void PajeEvent::insert_into_buffer()
{
- XBT_DEBUG("%s: insert event_type=%u, timestamp=%f, buffersize=%zu)", __func__, eventType_, timestamp_, buffer.size());
+ XBT_DEBUG("%s: insert event_type=%u, timestamp=%f, buffersize=%zu)", __func__, static_cast<unsigned>(eventType_),
+ timestamp_, buffer.size());
std::vector<PajeEvent*>::reverse_iterator i;
for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
PajeEvent* e1 = *i;
- XBT_DEBUG("compare to %p is of type %u; timestamp:%f", e1, e1->eventType_, e1->timestamp_);
+ XBT_DEBUG("compare to %p is of type %u; timestamp:%f", e1, static_cast<unsigned>(e1->eventType_), e1->timestamp_);
if (e1->timestamp_ <= timestamp_)
break;
}
return type_id++;
}
-Type::Type(e_event_type event_type, const std::string& name, const std::string& alias, const std::string& color,
+Type::Type(PajeEventType event_type, const std::string& name, const std::string& alias, const std::string& color,
Type* father)
: name_(name), color_(color), father_(father)
{
void StateType::set_event(const std::string& value_name)
{
- events_.push_back(new StateEvent(get_issuer(), this, PAJE_SetState, get_entity_value(value_name), nullptr));
+ events_.push_back(new StateEvent(get_issuer(), this, PajeEventType::SetState, get_entity_value(value_name), nullptr));
}
void StateType::push_event(const std::string& value_name, TIData* extra)
{
- events_.push_back(new StateEvent(get_issuer(), this, PAJE_PushState, get_entity_value(value_name), extra));
+ events_.push_back(new StateEvent(get_issuer(), this, PajeEventType::PushState, get_entity_value(value_name), extra));
}
void StateType::push_event(const std::string& value_name)
{
- events_.push_back(new StateEvent(get_issuer(), this, PAJE_PushState, get_entity_value(value_name), nullptr));
+ events_.push_back(
+ new StateEvent(get_issuer(), this, PajeEventType::PushState, get_entity_value(value_name), nullptr));
}
void StateType::pop_event()
void StateType::pop_event(TIData* extra)
{
- events_.push_back(new StateEvent(get_issuer(), this, PAJE_PopState, nullptr, extra));
+ events_.push_back(new StateEvent(get_issuer(), this, PajeEventType::PopState, nullptr, extra));
}
void VariableType::instr_event(double now, double delta, const char* resource, double value)
void VariableType::set_event(double timestamp, double value)
{
- events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PAJE_SetVariable, value));
+ events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PajeEventType::SetVariable, value));
}
void VariableType::add_event(double timestamp, double value)
{
- events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PAJE_AddVariable, value));
+ events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PajeEventType::AddVariable, value));
}
void VariableType::sub_event(double timestamp, double value)
{
- events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PAJE_SubVariable, value));
+ events_.push_back(new VariableEvent(timestamp, get_issuer(), this, PajeEventType::SubVariable, value));
}
void LinkType::start_event(Container* startContainer, const std::string& value, const std::string& key)
void LinkType::start_event(Container* startContainer, const std::string& value, const std::string& key, int size)
{
- new LinkEvent(get_issuer(), this, PAJE_StartLink, startContainer, value, key, size);
+ new LinkEvent(get_issuer(), this, PajeEventType::StartLink, startContainer, value, key, size);
}
void LinkType::end_event(Container* endContainer, const std::string& value, const std::string& key)
{
- new LinkEvent(get_issuer(), this, PAJE_EndLink, endContainer, value, key, -1);
+ new LinkEvent(get_issuer(), this, PajeEventType::EndLink, endContainer, value, key, -1);
}
Type* Type::by_name(const std::string& name)
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;
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);
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)
+ 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);
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);
}
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);