• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
7 #include "ITimelineDecoder.hpp"
8 
9 #include <vector>
10 
11 namespace arm
12 {
13 
14 namespace pipe
15 {
16 
17 class TimelineDecoder : public ITimelineDecoder
18 {
19 
20 public:
21 
22     struct Model
23     {
24         std::vector<Entity> m_Entities;
25         std::vector<EventClass> m_EventClasses;
26         std::vector<Event> m_Events;
27         std::vector<Label> m_Labels;
28         std::vector<Relationship> m_Relationships;
29     };
30 
31     using OnNewEntityCallback       =  void (*)(Model &, const Entity);
32     using OnNewEventClassCallback   =  void (*)(Model &, const EventClass);
33     using OnNewEventCallback        =  void (*)(Model &, const Event);
34     using OnNewLabelCallback        =  void (*)(Model &, const Label);
35     using OnNewRelationshipCallback =  void (*)(Model &, const Relationship);
36 
37     virtual TimelineStatus CreateEntity(const Entity &) override;
38     virtual TimelineStatus CreateEventClass(const EventClass &) override;
39     virtual TimelineStatus CreateEvent(const Event &) override;
40     virtual TimelineStatus CreateLabel(const Label &) override;
41     virtual TimelineStatus CreateRelationship(const Relationship &) override;
42 
43     const Model& GetModel();
44 
45     TimelineStatus SetEntityCallback(const OnNewEntityCallback);
46     TimelineStatus SetEventClassCallback(const OnNewEventClassCallback);
47     TimelineStatus SetEventCallback(const OnNewEventCallback);
48     TimelineStatus SetLabelCallback(const OnNewLabelCallback);
49     TimelineStatus SetRelationshipCallback(const OnNewRelationshipCallback);
50 
51     void SetDefaultCallbacks();
52 
53     void print();
54 
55 private:
56     Model m_Model;
57 
58     OnNewEntityCallback m_OnNewEntityCallback;
59     OnNewEventClassCallback m_OnNewEventClassCallback;
60     OnNewEventCallback m_OnNewEventCallback;
61     OnNewLabelCallback m_OnNewLabelCallback;
62     OnNewRelationshipCallback m_OnNewRelationshipCallback;
63 
64     void printLabels();
65     void printEntities();
66     void printEventClasses();
67     void printRelationships();
68     void printEvents();
69 };
70 
71 } // namespace pipe
72 } // namespace arm