ArmNN
 22.11
JSONTimelineDecoder Class Reference

#include <JSONTimelineDecoder.hpp>

Inheritance diagram for JSONTimelineDecoder:

Classes

struct  JSONEntity
 
struct  Model
 

Public Member Functions

void PrintJSON (JSONEntity &entity, std::ostream &os)
 
std::string GetJSONString (JSONEntity &rootEntity)
 
std::string GetJSONEntityString (JSONEntity &entity, int &counter)
 
virtual TimelineStatus CreateEntity (const Entity &) override
 
virtual TimelineStatus CreateEventClass (const EventClass &) override
 
virtual TimelineStatus CreateEvent (const Event &) override
 
virtual TimelineStatus CreateLabel (const Label &) override
 
virtual TimelineStatus CreateRelationship (const Relationship &) override
 
const ModelGetModel ()
 

Detailed Description

Definition at line 19 of file JSONTimelineDecoder.hpp.

Member Function Documentation

◆ CreateEntity()

JSONTimelineDecoder::TimelineStatus CreateEntity ( const Entity &  entity)
overridevirtual

Definition at line 29 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::Model::jsonEntities, and JSONTimelineDecoder::JSONEntity::SetType().

30 {
31  JSONEntity jsonEntity(entity.m_Guid);
32  jsonEntity.SetType(ENTITY);
33  this->m_Model.jsonEntities.insert({entity.m_Guid, jsonEntity});
34  return TimelineStatus::TimelineStatus_Success;
35 }

◆ CreateEvent()

JSONTimelineDecoder::TimelineStatus CreateEvent ( const Event event)
overridevirtual

Definition at line 46 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::Model::events, JSONTimelineDecoder::JSONEntity::GetGuid(), JSONTimelineDecoder::Model::jsonEntities, and JSONTimelineDecoder::JSONEntity::SetType().

47 {
48  JSONEntity jsonEntity(event.m_Guid);
49  jsonEntity.SetType(EVENT);
50  this->m_Model.events.insert({event.m_Guid, event});
51  this->m_Model.jsonEntities.insert({jsonEntity.GetGuid(), jsonEntity});
52  return TimelineStatus::TimelineStatus_Success;
53 }

◆ CreateEventClass()

JSONTimelineDecoder::TimelineStatus CreateEventClass ( const EventClass &  eventClass)
overridevirtual

Definition at line 37 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::Model::eventClasses, JSONTimelineDecoder::Model::jsonEntities, and JSONTimelineDecoder::JSONEntity::SetType().

38 {
39  JSONEntity jsonEntity(eventClass.m_Guid);
40  jsonEntity.SetType(EVENTCLASS);
41  this->m_Model.eventClasses.insert({eventClass.m_Guid, eventClass});
42  this->m_Model.jsonEntities.insert({eventClass.m_Guid, jsonEntity});
43  return TimelineStatus::TimelineStatus_Success;
44 }

◆ CreateLabel()

JSONTimelineDecoder::TimelineStatus CreateLabel ( const Label &  label)
overridevirtual

Definition at line 55 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::Model::labels.

56 {
57  this->m_Model.labels.insert({label.m_Guid, label});
58  return TimelineStatus::TimelineStatus_Success;
59 }

◆ CreateRelationship()

JSONTimelineDecoder::TimelineStatus CreateRelationship ( const Relationship &  relationship)
overridevirtual

Definition at line 61 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::JSONEntity::AddConnection(), JSONTimelineDecoder::JSONEntity::extendedData, JSONTimelineDecoder::Model::jsonEntities, JSONTimelineDecoder::Model::labels, JSONTimelineDecoder::Model::relationships, JSONTimelineDecoder::JSONEntity::SetName(), JSONTimelineDecoder::JSONEntity::SetParent(), and JSONTimelineDecoder::JSONEntity::SetType().

62 {
63  if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::RetentionLink)
64  {
65  HandleRetentionLink(relationship);
66  }
67  else if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::LabelLink)
68  {
69  HandleLabelLink(relationship);
70  }
71  else if (relationship.m_RelationshipType == ITimelineDecoder::RelationshipType::ExecutionLink)
72  {
73  HandleExecutionLink(relationship);
74  }
75  else
76  {
77  /*
78  * TODO Handle DataLink
79  */
80  m_Model.relationships.insert({relationship.m_Guid, relationship});
81  }
82 
83  return TimelineStatus::TimelineStatus_Success;
84 }

◆ GetJSONEntityString()

std::string GetJSONEntityString ( JSONTimelineDecoder::JSONEntity entity,
int &  counter 
)

Definition at line 271 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::JSONEntity::childEntities, JSONTimelineDecoder::Model::events, JSONTimelineDecoder::JSONEntity::extendedData, JSONTimelineDecoder::JSONEntity::GetGuid(), JSONTimelineDecoder::JSONEntity::GetName(), JSONTimelineDecoder::JSONEntity::GetType(), and JSONTimelineDecoder::Model::jsonEntities.

Referenced by JSONTimelineDecoder::GetJSONString().

272 {
273  std::string jsonEntityString;
274  if(entity.GetType() == LAYER)
275  {
276  return GetLayerJSONString(entity, counter, jsonEntityString);
277  }
278  else if (entity.GetType() == WORKLOAD)
279  {
280  return GetWorkloadJSONString(entity, counter, jsonEntityString);
281  }
282  else if (entity.GetType() == WORKLOAD_EXECUTION)
283  {
284  return GetWorkloadExecutionJSONString(entity, jsonEntityString);
285  }
286  else if (entity.GetType() == INFERENCE)
287  {
288  return jsonEntityString;
289  }
290  else
291  {
292  for (uint64_t child_entity_id : entity.childEntities)
293  {
294  JSONEntity& childEntity = this->m_Model.jsonEntities.at(child_entity_id);
295  jsonEntityString.append(GetJSONEntityString(childEntity, ++counter));
296  }
297  return jsonEntityString;
298  }
299 }
std::string GetJSONEntityString(JSONEntity &entity, int &counter)

◆ GetJSONString()

std::string GetJSONString ( JSONTimelineDecoder::JSONEntity rootEntity)

Definition at line 251 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::JSONEntity::childEntities, JSONTimelineDecoder::GetJSONEntityString(), JSONTimelineDecoder::JSONEntity::GetType(), and JSONTimelineDecoder::Model::jsonEntities.

Referenced by JSONTimelineDecoder::PrintJSON().

252 {
253  int counter = 0;
254  std::string json;
255  json.append("{\n");
256  if(rootEntity.GetType() != "")
257  {
258  json.append("\tArmNN");
259  json.append(": {\n");
260 
261  for (uint64_t childEntityId : rootEntity.childEntities)
262  {
263  JSONEntity& childEntity = this->m_Model.jsonEntities.at(childEntityId);
264  json.append(GetJSONEntityString(childEntity, counter));
265  }
266  }
267  json.append("}\n");
268  return json;
269 }
std::string GetJSONEntityString(JSONEntity &entity, int &counter)

◆ GetModel()

const JSONTimelineDecoder::Model & GetModel ( )

Definition at line 374 of file JSONTimelineDecoder.cpp.

375 {
376  return m_Model;
377 }

◆ PrintJSON()

void PrintJSON ( JSONTimelineDecoder::JSONEntity rootEntity,
std::ostream &  os 
)

Definition at line 245 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::GetJSONString().

246 {
247  std::string jsonString = GetJSONString(rootEntity);
248  os << jsonString;
249 }
std::string GetJSONString(JSONEntity &rootEntity)

The documentation for this class was generated from the following files: