ArmNN
 20.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 18 of file JSONTimelineDecoder.hpp.

Member Function Documentation

◆ CreateEntity()

JSONTimelineDecoder::TimelineStatus CreateEntity ( const Entity entity)
overridevirtual

Definition at line 28 of file JSONTimelineDecoder.cpp.

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

Referenced by RunSimpleModelThroughDecoder().

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

◆ CreateEvent()

JSONTimelineDecoder::TimelineStatus CreateEvent ( const Event event)
overridevirtual

Definition at line 45 of file JSONTimelineDecoder.cpp.

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

Referenced by RunSimpleModelThroughDecoder().

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

◆ CreateEventClass()

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

Definition at line 36 of file JSONTimelineDecoder.cpp.

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

Referenced by RunSimpleModelThroughDecoder().

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

◆ CreateLabel()

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

Definition at line 54 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::Model::labels.

Referenced by RunSimpleModelThroughDecoder().

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

◆ CreateRelationship()

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

Definition at line 60 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().

Referenced by RunSimpleModelThroughDecoder().

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

◆ GetJSONEntityString()

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

Definition at line 270 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().

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

◆ GetJSONString()

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

Definition at line 250 of file JSONTimelineDecoder.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE(), and JSONTimelineDecoder::PrintJSON().

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

◆ GetModel()

const JSONTimelineDecoder::Model & GetModel ( )

Definition at line 372 of file JSONTimelineDecoder.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

373 {
374  return m_Model;
375 }

◆ PrintJSON()

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

Definition at line 244 of file JSONTimelineDecoder.cpp.

References JSONTimelineDecoder::GetJSONString().

Referenced by BOOST_AUTO_TEST_CASE().

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

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