ArmNN  NotReleased
TimelineDecoder.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ITimelineDecoder.h"
7 
8 ErrorCode CreateEntity(const Entity entity, Model* model)
9 {
10  if (model == nullptr || model->m_EntityCb == nullptr)
11  {
13  }
14  model->m_EntityCb(entity, model);
16 }
17 
18 ErrorCode CreateEventClass(const EventClass eventClass, Model* model)
19 {
20  if (model == nullptr || model->m_EventClassCb == nullptr)
21  {
23  }
24  model->m_EventClassCb(eventClass, model);
26 }
27 
28 ErrorCode CreateEvent(const Event event, Model* model)
29 {
30  if (model == nullptr || model->m_EventCb == nullptr)
31  {
33  }
34  model->m_EventCb(event, model);
36 }
37 
38 ErrorCode CreateLabel(const Label label, Model* model)
39 {
40  if (model == nullptr || model->m_LabelCb == nullptr)
41  {
43  }
44  model->m_LabelCb(label, model);
46 }
47 
49 {
50  if (model == nullptr || model->m_RelationshipCb == nullptr)
51  {
53  }
54  model->m_RelationshipCb(relationship, model);
56 }
57 
59 {
60  if (cb == nullptr || model == nullptr)
61  {
63  }
64  model->m_EntityCb = cb;
66 }
67 
69 {
70  if (cb == nullptr || model == nullptr)
71  {
73  }
74  model->m_EventClassCb = cb;
76 }
77 
79 {
80  if (cb == nullptr || model == nullptr)
81  {
83  }
84  model->m_EventCb = cb;
86 }
87 
89 {
90  if (cb == nullptr || model == nullptr)
91  {
93  }
94  model->m_LabelCb = cb;
96 }
97 
99 {
100  if (cb == nullptr || model == nullptr)
101  {
103  }
104  model->m_RelationshipCb = cb;
106 }
107 
109 {
110  Model* modelPtr = new Model;
111 
112  modelPtr->m_EntityCount = 0;
113  modelPtr->m_EventClassCount = 0;
114  modelPtr->m_EventCount = 0;
115  modelPtr->m_LabelCount = 0;
116  modelPtr->m_RelationshipCount = 0;
117 
118  *model = modelPtr;
120 }
121 
123 {
124  if (*model == nullptr)
125  {
127  }
128 
129  Model* modelPtr = *model;
130 
131  for (uint32_t i = 0; i < modelPtr->m_EntityCount; ++i)
132  {
133  delete modelPtr->m_Entities[i];
134  }
135 
136  for (uint32_t i = 0; i < modelPtr->m_EventClassCount; ++i)
137  {
138  delete modelPtr->m_EventClasses[i];
139  }
140 
141  for (uint32_t i = 0; i < modelPtr->m_EventCount; ++i)
142  {
143  delete[] modelPtr->m_Events[i]->m_ThreadId;
144  delete modelPtr->m_Events[i];
145  }
146 
147  for (uint32_t i = 0; i < modelPtr->m_LabelCount; ++i)
148  {
149  delete[] modelPtr->m_Labels[i]->m_Name;
150  delete modelPtr->m_Labels[i];
151  }
152 
153  for (uint32_t i = 0; i < modelPtr->m_RelationshipCount; ++i)
154  {
155  delete modelPtr->m_Relationships[i];
156  }
157 
158  delete[] modelPtr->m_Entities;
159  delete[] modelPtr->m_EventClasses;
160  delete[] modelPtr->m_Events;
161  delete[] modelPtr->m_Labels;
162  delete[] modelPtr->m_Relationships;
163 
164  delete modelPtr;
166 }
OnNewLabelCallback m_LabelCb
Definition: TimelineModel.h:67
void(* OnNewLabelCallback)(const Label, struct Model *model)
Definition: TimelineModel.h:59
void(* OnNewRelationshipCallback)(const Relationship, struct Model *model)
Definition: TimelineModel.h:60
ErrorCode CreateEvent(const Event event, Model *model)
EventClass ** m_EventClasses
Definition: TimelineModel.h:71
void(* OnNewEntityCallback)(const Entity, struct Model *model)
Definition: TimelineModel.h:56
Event ** m_Events
Definition: TimelineModel.h:72
char * m_Name
Definition: TimelineModel.h:45
ErrorCode CreateEntity(const Entity entity, Model *model)
ErrorCode DestroyModel(Model **model)
ErrorCode SetRelationshipCallback(OnNewRelationshipCallback cb, Model *model)
OnNewEntityCallback m_EntityCb
Definition: TimelineModel.h:64
ErrorCode CreateLabel(const Label label, Model *model)
OnNewEventCallback m_EventCb
Definition: TimelineModel.h:66
uint32_t m_EventClassCount
Definition: TimelineModel.h:79
ErrorCode
unsigned char * m_ThreadId
Definition: TimelineModel.h:39
ErrorCode SetLabelCallback(OnNewLabelCallback cb, Model *model)
void(* OnNewEventCallback)(const Event, struct Model *model)
Definition: TimelineModel.h:58
ErrorCode SetEntityCallback(OnNewEntityCallback cb, Model *model)
ErrorCode SetEventCallback(OnNewEventCallback cb, Model *model)
void(* OnNewEventClassCallback)(const EventClass, struct Model *model)
Definition: TimelineModel.h:57
uint32_t m_RelationshipCount
Definition: TimelineModel.h:88
struct Model Model
Relationship ** m_Relationships
Definition: TimelineModel.h:74
Entity ** m_Entities
Definition: TimelineModel.h:70
uint32_t m_EventCount
Definition: TimelineModel.h:82
ErrorCode CreateEventClass(const EventClass eventClass, Model *model)
uint32_t m_EntityCount
Definition: TimelineModel.h:76
ErrorCode SetEventClassCallback(OnNewEventClassCallback cb, Model *model)
Label ** m_Labels
Definition: TimelineModel.h:73
uint32_t m_LabelCount
Definition: TimelineModel.h:85
OnNewRelationshipCallback m_RelationshipCb
Definition: TimelineModel.h:68
ErrorCode CreateModel(Model **model)
OnNewEventClassCallback m_EventClassCb
Definition: TimelineModel.h:65
ErrorCode CreateRelationship(Relationship relationship, Model *model)