IVGCVSW-4595 Add IFileOnlyPacketHandlers to file only profiling connection

Change-Id: Ib49a8cbbf323da4109cdab9750e6c4d276e484b7
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
diff --git a/include/armnn/IRuntime.hpp b/include/armnn/IRuntime.hpp
index 06d249e..48ad7c4 100644
--- a/include/armnn/IRuntime.hpp
+++ b/include/armnn/IRuntime.hpp
@@ -10,6 +10,7 @@
 #include "Tensor.hpp"
 #include "Types.hpp"
 #include "TypesUtils.hpp"
+#include "profiling/ILocalPacketHandler.hpp"
 
 #include <memory>
 
@@ -61,21 +62,23 @@
         {
             ExternalProfilingOptions()
                 : m_EnableProfiling(false)
+                , m_TimelineEnabled(false)
                 , m_OutgoingCaptureFile("")
                 , m_IncomingCaptureFile("")
                 , m_FileOnly(false)
                 , m_CapturePeriod(LOWEST_CAPTURE_PERIOD)
                 , m_FileFormat("binary")
-                , m_TimelineEnabled(false)
+                , m_LocalPacketHandlers()
             {}
 
             bool        m_EnableProfiling;
+            bool        m_TimelineEnabled;
             std::string m_OutgoingCaptureFile;
             std::string m_IncomingCaptureFile;
             bool        m_FileOnly;
             uint32_t    m_CapturePeriod;
             std::string m_FileFormat;
-            bool        m_TimelineEnabled;
+            std::vector<armnn::profiling::ILocalPacketHandlerSharedPtr> m_LocalPacketHandlers;
         };
         ExternalProfilingOptions m_ProfilingOptions;
 
diff --git a/include/armnn/profiling/ILocalPacketHandler.hpp b/include/armnn/profiling/ILocalPacketHandler.hpp
new file mode 100644
index 0000000..a2b9d5f
--- /dev/null
+++ b/include/armnn/profiling/ILocalPacketHandler.hpp
@@ -0,0 +1,48 @@
+//
+// Copyright © 2020 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+
+#include <armnn/utility/IgnoreUnused.hpp>
+
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+namespace armnn
+{
+
+namespace profiling
+{
+// forward declare to prevent a circular dependency
+class Packet;
+class IProfilingConnection;
+
+class ILocalPacketHandler
+{
+public:
+    virtual ~ILocalPacketHandler() {};
+
+    /// @return lists the headers of the packets that this handler accepts
+    ///         only these packets will get sent to this handler.
+    ///         If this function returns an empty list then ALL packets
+    ///         will be sent to the PacketHandler i.e. a universal handler.
+    virtual std::vector<uint32_t> GetHeadersAccepted() = 0;
+
+    /// process the packet
+    virtual void HandlePacket(const Packet& packet) = 0;
+
+    /// Set a profiling connection on the handler. Only need to implement this
+    /// function if the handler will be writing data back to the profiled application.
+    virtual void SetConnection(IProfilingConnection* profilingConnection) {armnn::IgnoreUnused(profilingConnection);}
+};
+
+using ILocalPacketHandlerPtr = std::unique_ptr<ILocalPacketHandler>;
+using ILocalPacketHandlerSharedPtr = std::shared_ptr<ILocalPacketHandler>;
+
+} // namespace profiling
+
+} // namespace armnn
\ No newline at end of file
diff --git a/include/armnn/profiling/ITimelineDecoder.hpp b/include/armnn/profiling/ITimelineDecoder.hpp
index 3a02bb5..5d22ad8 100644
--- a/include/armnn/profiling/ITimelineDecoder.hpp
+++ b/include/armnn/profiling/ITimelineDecoder.hpp
@@ -27,6 +27,18 @@
         LabelLink      /// Head uses label Tail (Tail MUST be a guid of a label).
     };
 
+    static char const* GetRelationshipAsCString(RelationshipType rType)
+    {
+        switch (rType)
+        {
+            case RelationshipType::RetentionLink: return "RetentionLink";
+            case RelationshipType::ExecutionLink: return "ExecutionLink";
+            case RelationshipType::DataLink: return "DataLink";
+            case RelationshipType::LabelLink: return "LabelLink";
+            default: return "Unknown";
+        }
+    }
+
     struct Entity
     {
         uint64_t m_Guid;