ArmNN  NotReleased
TimelineTestFunctions.hpp
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 <algorithm>
7 #include "../TimelineModel.h"
8 
9 void PushEntity(const Entity entity, Model* model)
10 {
11  if(model->m_EntityCount == 0)
12  {
13  model->m_EntityCapacity = 1;
14  model->m_Entities = new Entity*[model->m_EntityCapacity];
15  }
16  else if(model->m_EntityCount >= model->m_EntityCapacity)
17  {
18  Entity** newEntityArray = new Entity*[model->m_EntityCapacity*2];
19 
20  std::copy(model->m_Entities, model->m_Entities + model->m_EntityCapacity, newEntityArray);
21  delete[] model->m_Entities;
22  model->m_Entities = newEntityArray;
23 
24  model->m_EntityCapacity = model->m_EntityCapacity *2;
25  }
26 
27  Entity* newEntity = new Entity;
28 
29  newEntity->m_Guid = entity.m_Guid;
30 
31  model->m_Entities[model->m_EntityCount] = newEntity;
32  model->m_EntityCount++;
33 };
34 
35 void PushEventClass(const EventClass eventClass, Model* model)
36 {
37  if(model->m_EventClassCount == 0)
38  {
39  model->m_EventClassCapacity = 1;
40  model->m_EventClasses = new EventClass*[model->m_EventClassCapacity];
41  }
42  else if(model->m_EventClassCount >= model->m_EventClassCapacity)
43  {
44  EventClass** newEventClassArray = new EventClass*[model->m_EventClassCapacity *2];
45 
46  std::copy(model->m_EventClasses, model->m_EventClasses + model->m_EventClassCapacity, newEventClassArray);
47  delete[] model->m_EventClasses;
48  model->m_EventClasses = newEventClassArray;
49 
50  model->m_EventClassCapacity = model->m_EventClassCapacity *2;
51  }
52 
53  EventClass* newEventClass = new EventClass;
54 
55  newEventClass->m_Guid = eventClass.m_Guid;
56 
57  model->m_EventClasses[model->m_EventClassCount] = newEventClass;
58  model->m_EventClassCount++;
59 };
60 
61 void PushEvent(const Event event, Model* model)
62 {
63  if(model->m_EventCount == 0)
64  {
65  model->m_EventCapacity = 1;
66  model->m_Events = new Event*[model->m_EventCapacity];
67  }
68  else if(model->m_EventCount >= model->m_EventCapacity)
69  {
70  Event** newEventArray = new Event*[model->m_EventCapacity * 2];
71 
72  std::copy(model->m_Events, model->m_Events + model->m_EventCapacity, newEventArray);
73  delete[] model->m_Events;
74  model->m_Events = newEventArray;
75 
76  model->m_EventCapacity = model->m_EventCapacity *2;
77  }
78 
79  Event* newEvent = new Event;
80 
81  newEvent->m_TimeStamp = event.m_TimeStamp;
82  newEvent->m_ThreadId = event.m_ThreadId;
83  newEvent->m_Guid = event.m_Guid;
84 
85  model->m_Events[model->m_EventCount] = newEvent;
86  model->m_EventCount++;
87 };
88 
89 void PushLabel(const Label label, Model* model)
90 {
91  if(model->m_LabelCount == 0)
92  {
93  model->m_LabelCapacity = 1;
94  model->m_Labels = new Label*[model->m_LabelCapacity];
95  }
96  else if(model->m_LabelCount >= model->m_LabelCapacity)
97  {
98  Label** newLabelArray = new Label*[model->m_LabelCapacity *2];
99 
100  std::copy(model->m_Labels, model->m_Labels + model->m_LabelCapacity, newLabelArray);
101  delete[] model->m_Labels;
102  model->m_Labels = newLabelArray;
103 
104  model->m_LabelCapacity = model->m_LabelCapacity *2;
105  }
106 
107  Label* newLabel = new Label;
108 
109  newLabel->m_Guid = label.m_Guid;
110  newLabel->m_Name = label.m_Name;
111 
112  model->m_Labels[model->m_LabelCount] = newLabel;
113  model->m_LabelCount++;
114 };
115 
116 void PushRelationship(const Relationship relationship, Model* model)
117 {
118  if(model->m_RelationshipCount == 0)
119  {
120  model->m_RelationshipCapacity = 1;
122  }
123  else if(model->m_RelationshipCount >= model->m_RelationshipCapacity)
124  {
125  Relationship** newRelationshipArray = new Relationship*[model->m_RelationshipCapacity *2];
126 
127  std::copy(model->m_Relationships, model->m_Relationships + model->m_RelationshipCapacity, newRelationshipArray);
128  delete[] model->m_Relationships;
129  model->m_Relationships = newRelationshipArray;
130 
132  }
133 
134  Relationship* newRelationship = new Relationship;
135 
136  newRelationship->m_Guid = relationship.m_Guid;
137  newRelationship->m_RelationshipType = relationship.m_RelationshipType;
138  newRelationship->m_HeadGuid = relationship.m_HeadGuid;
139  newRelationship->m_TailGuid = relationship.m_TailGuid;
140 
141  model->m_Relationships[model->m_RelationshipCount] = newRelationship;
142  model->m_RelationshipCount++;
143 };
void PushEntity(const Entity entity, Model *model)
uint32_t m_EventClassCapacity
Definition: TimelineModel.h:80
uint32_t m_LabelCapacity
Definition: TimelineModel.h:86
void PushRelationship(const Relationship relationship, Model *model)
EventClass ** m_EventClasses
Definition: TimelineModel.h:71
struct Entity Entity
Event ** m_Events
Definition: TimelineModel.h:72
char * m_Name
Definition: TimelineModel.h:45
uint64_t m_Guid
Definition: TimelineModel.h:27
uint32_t m_EventCapacity
Definition: TimelineModel.h:83
void PushEventClass(const EventClass eventClass, Model *model)
uint32_t m_EntityCapacity
Definition: TimelineModel.h:77
struct Label Label
void PushLabel(const Label label, Model *model)
void PushEvent(const Event event, Model *model)
uint64_t m_Guid
Definition: TimelineModel.h:37
uint32_t m_EventClassCount
Definition: TimelineModel.h:79
struct Relationship Relationship
uint64_t m_TimeStamp
Definition: TimelineModel.h:38
unsigned char * m_ThreadId
Definition: TimelineModel.h:39
uint64_t m_Guid
Definition: TimelineModel.h:44
uint64_t m_TailGuid
Definition: TimelineModel.h:53
RelationshipType m_RelationshipType
Definition: TimelineModel.h:50
struct EventClass EventClass
uint32_t m_RelationshipCapacity
Definition: TimelineModel.h:89
uint32_t m_RelationshipCount
Definition: TimelineModel.h:88
Relationship ** m_Relationships
Definition: TimelineModel.h:74
Entity ** m_Entities
Definition: TimelineModel.h:70
uint32_t m_EventCount
Definition: TimelineModel.h:82
uint64_t m_Guid
Definition: TimelineModel.h:51
uint64_t m_Guid
Definition: TimelineModel.h:32
uint32_t m_EntityCount
Definition: TimelineModel.h:76
uint64_t m_HeadGuid
Definition: TimelineModel.h:52
Label ** m_Labels
Definition: TimelineModel.h:73
uint32_t m_LabelCount
Definition: TimelineModel.h:85