IVGCVSW-4730 Remove the duplication of PIPE_MAGIC in the code base

Change-Id: I41c6e917b29eee33360758b6c5afe5dadba89093
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dba41a3..eefa5e7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -252,7 +252,7 @@
     include/armnn/utility/StringUtils.hpp
     profiling/common/include/ProfilingException.hpp
     profiling/common/include/SocketConnectionException.hpp
-    profiling/common/include/NetworkSockets.hpp
+    profiling/common/include/Constants.hpp
     profiling/common/src/NetworkSockets.cpp
     src/armnn/layers/LayerCloneBase.hpp
     src/armnn/layers/LayerWithParameters.hpp
diff --git a/profiling/common/include/Constants.hpp b/profiling/common/include/Constants.hpp
new file mode 100644
index 0000000..52e0e48
--- /dev/null
+++ b/profiling/common/include/Constants.hpp
@@ -0,0 +1,10 @@
+//
+// Copyright © 2020 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#pragma once
+
+namespace armnnProfiling
+{
+    static const unsigned int PIPE_MAGIC = 0x45495434;
+}
\ No newline at end of file
diff --git a/profiling/server/src/basePipeServer/BasePipeServer.cpp b/profiling/server/src/basePipeServer/BasePipeServer.cpp
index 1d5e0b6..7e8789a 100644
--- a/profiling/server/src/basePipeServer/BasePipeServer.cpp
+++ b/profiling/server/src/basePipeServer/BasePipeServer.cpp
@@ -5,6 +5,8 @@
 
 #include "BasePipeServer.hpp"
 
+#include "common/include/Constants.hpp"
+
 #include <iostream>
 #include <boost/cast.hpp>
 #include <vector>
@@ -65,11 +67,11 @@
     EchoPacket(PacketDirection::ReceivedData, pipeMagic, 4);
 
     // Before we interpret the length we need to read the pipe_magic word to determine endianness.
-    if (ToUint32(&pipeMagic[0], TargetEndianness::BeWire) == PIPE_MAGIC)
+    if (ToUint32(&pipeMagic[0], TargetEndianness::BeWire) == armnnProfiling::PIPE_MAGIC)
     {
         m_Endianness = TargetEndianness::BeWire;
     }
-    else if (ToUint32(&pipeMagic[0], TargetEndianness::LeWire) == PIPE_MAGIC)
+    else if (ToUint32(&pipeMagic[0], TargetEndianness::LeWire) == armnnProfiling::PIPE_MAGIC)
     {
         m_Endianness = TargetEndianness::LeWire;
     }
diff --git a/profiling/server/src/basePipeServer/BasePipeServer.hpp b/profiling/server/src/basePipeServer/BasePipeServer.hpp
index c03774e..4e6e0c0 100644
--- a/profiling/server/src/basePipeServer/BasePipeServer.hpp
+++ b/profiling/server/src/basePipeServer/BasePipeServer.hpp
@@ -107,7 +107,6 @@
     armnnUtils::Sockets::Socket m_ClientConnection;
     bool m_EchoPackets;
     TargetEndianness m_Endianness;
-    static const uint32_t PIPE_MAGIC = 0x45495434;
 
     uint32_t m_StreamMetaDataVersion;
     uint32_t m_StreamMetaDataMaxDataLen;
diff --git a/src/profiling/FileOnlyProfilingConnection.cpp b/src/profiling/FileOnlyProfilingConnection.cpp
index 5947d2c..1d4e23b 100644
--- a/src/profiling/FileOnlyProfilingConnection.cpp
+++ b/src/profiling/FileOnlyProfilingConnection.cpp
@@ -7,6 +7,7 @@
 #include "PacketVersionResolver.hpp"
 
 #include <armnn/Exceptions.hpp>
+#include <common/include/Constants.hpp>
 
 #include <algorithm>
 #include <boost/numeric/conversion/cast.hpp>
@@ -59,11 +60,11 @@
     }
 
     // Before we interpret the length we need to read the pipe_magic word to determine endianness.
-    if (ToUint32(buffer + 8, TargetEndianness::BeWire) == PIPE_MAGIC)
+    if (ToUint32(buffer + 8, TargetEndianness::BeWire) == armnnProfiling::PIPE_MAGIC)
     {
         m_Endianness = TargetEndianness::BeWire;
     }
-    else if (ToUint32(buffer + 8, TargetEndianness::LeWire) == PIPE_MAGIC)
+    else if (ToUint32(buffer + 8, TargetEndianness::LeWire) == armnnProfiling::PIPE_MAGIC)
     {
         m_Endianness = TargetEndianness::LeWire;
     }
diff --git a/src/profiling/FileOnlyProfilingConnection.hpp b/src/profiling/FileOnlyProfilingConnection.hpp
index 12ac273..466f4f1 100644
--- a/src/profiling/FileOnlyProfilingConnection.hpp
+++ b/src/profiling/FileOnlyProfilingConnection.hpp
@@ -94,8 +94,6 @@
     void ForwardPacketToHandlers(Packet& packet);
     void ServiceLocalHandlers();
 
-    static const uint32_t PIPE_MAGIC = 0x45495434;
-
     Runtime::CreationOptions::ExternalProfilingOptions m_Options;
     bool m_QuietOp;
     std::vector<uint16_t> m_IdList;
diff --git a/src/profiling/SendCounterPacket.cpp b/src/profiling/SendCounterPacket.cpp
index f251684..d916dd8 100644
--- a/src/profiling/SendCounterPacket.cpp
+++ b/src/profiling/SendCounterPacket.cpp
@@ -10,6 +10,7 @@
 #include <armnn/Conversion.hpp>
 #include <Processes.hpp>
 #include <armnn/utility/Assert.hpp>
+#include <common/include/Constants.hpp>
 
 #include <boost/format.hpp>
 #include <boost/numeric/conversion/cast.hpp>
@@ -24,8 +25,6 @@
 
 using boost::numeric_cast;
 
-const unsigned int SendCounterPacket::PIPE_MAGIC;
-
 void SendCounterPacket::SendStreamMetaDataPacket()
 {
     const std::string info(GetSoftwareInfo());
@@ -81,7 +80,7 @@
         // Packet body
 
         offset += sizeUint32;
-        WriteUint32(writeBuffer, offset, PIPE_MAGIC); // pipe_magic
+        WriteUint32(writeBuffer, offset, armnnProfiling::PIPE_MAGIC); // pipe_magic
         offset += sizeUint32;
         WriteUint32(writeBuffer, offset, EncodeVersion(1, 0, 0)); // stream_metadata_version
         offset += sizeUint32;
diff --git a/src/profiling/SendCounterPacket.hpp b/src/profiling/SendCounterPacket.hpp
index 1880a2a..4262c93 100644
--- a/src/profiling/SendCounterPacket.hpp
+++ b/src/profiling/SendCounterPacket.hpp
@@ -40,8 +40,6 @@
     void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod,
                                             const std::vector<uint16_t>& selectedCounterIds) override;
 
-    static const unsigned int PIPE_MAGIC = 0x45495434;
-
 private:
     template <typename ExceptionType>
     void CancelOperationAndThrow(const std::string& errorMessage)
diff --git a/src/profiling/test/SendCounterPacketTests.cpp b/src/profiling/test/SendCounterPacketTests.cpp
index dd271c9..9b3a86a 100644
--- a/src/profiling/test/SendCounterPacketTests.cpp
+++ b/src/profiling/test/SendCounterPacketTests.cpp
@@ -18,6 +18,9 @@
 #include <armnn/Conversion.hpp>
 #include <armnn/Utils.hpp>
 
+#include <common/include/Constants.hpp>
+
+
 #include <boost/test/unit_test.hpp>
 #include <boost/numeric/conversion/cast.hpp>
 
@@ -324,7 +327,7 @@
     BOOST_TEST(headerWord1 == totalLength - (2 * sizeUint32)); // data length
 
     uint32_t offset = sizeUint32 * 2;
-    BOOST_TEST(ReadUint32(readBuffer2, offset) == SendCounterPacket::PIPE_MAGIC); // pipe_magic
+    BOOST_TEST(ReadUint32(readBuffer2, offset) == armnnProfiling::PIPE_MAGIC); // pipe_magic
     offset += sizeUint32;
     BOOST_TEST(ReadUint32(readBuffer2, offset) == EncodeVersion(1, 0, 0)); // stream_metadata_version
     offset += sizeUint32;