From 2f7f6f61c6474eb11de84a19e780b9d7a41b7ad9 Mon Sep 17 00:00:00 2001
From: Andrea Zoli <zoli@iasfbo.inaf.it>
Date: Fri, 10 Jan 2014 15:45:45 +0100
Subject: [PATCH] Expose ByteStream instead of byte* in InputPacketStream.

---
 include/InputPacketStream.h |  8 ++++----
 src/InputPacketStream.cpp   | 12 ++++++------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/InputPacketStream.h b/include/InputPacketStream.h
index 34a2e05..38a2548 100644
--- a/include/InputPacketStream.h
+++ b/include/InputPacketStream.h
@@ -49,12 +49,12 @@ public:
 
     ///It returns the index of the packet type contained in the stream. The stream* contains also the prefix (if present)
     /// \return The index of packet type if it's recognized. 0 if packet isn't recognized.
-    /// \param packet A byte* that contains the packet.
-    int detPacketType(byte* packet);
+    /// \param packet A ByteStream pointer that contains the packet.
+    int detPacketType(ByteStreamPtr packet);
 
 	///It returns the total dimension of the packet contained in the stream (without prefix). The stream* contains also the prefix (if present)
 	///\param The stream with the prefix (if present)
-    dword getPacketDimension(byte* stream);
+    dword getPacketDimension(ByteStreamPtr stream);
 
     /// This method sets the generic input of the stream
     /// \param in An input.
@@ -65,7 +65,7 @@ public:
     /// \return A pointer telemetry packet. Make attention: the object returned is one of the TM packet object of the array of this object. Don't delete it!
     Packet* readPacket() throw(PacketExceptionIO*);
 
-    Packet* decodePacket(byte* stream);
+    Packet* decodePacket(ByteStreamPtr stream);
 
 protected:
 
diff --git a/src/InputPacketStream.cpp b/src/InputPacketStream.cpp
index 3edb07d..e6c3231 100644
--- a/src/InputPacketStream.cpp
+++ b/src/InputPacketStream.cpp
@@ -69,14 +69,14 @@ int InputPacketStream::detPacketType(ByteStreamPtr prefix, ByteStreamPtr packet)
 }
 
 
-int InputPacketStream::detPacketType(byte* packet)
+int InputPacketStream::detPacketType(ByteStreamPtr packet)
 {
     /// Iterate through list and output each element.
     /// The packetType 0 is the packet not recognized
     for (dword i = 1; i<numberOfPacketType; i++)
     {
         Packet* p = getPacketType(i);
-        if(p->verifyPacketValue(packet))
+        if(p->verifyPacketValue(packet->stream))
             return i;
     }
     return 0;
@@ -158,7 +158,7 @@ Packet* InputPacketStream::readPacket() throw(PacketExceptionIO*)
     }
 }
 
-dword InputPacketStream::getPacketDimension(byte* stream) {
+dword InputPacketStream::getPacketDimension(ByteStreamPtr stream) {
 		dword dimPre = 0;
 		if(prefix)
 			dimPre += dimPrefix;
@@ -168,18 +168,18 @@ dword InputPacketStream::getPacketDimension(byte* stream) {
 		dword dimHeader = headerReference->getDimension();
 		dim += dimHeader;
 		ByteStreamPtr tempHeader = ByteStreamPtr(new ByteStream());
-		tempHeader->setStream(stream+dimPre, dimHeader, bigendian);
+		tempHeader->setStream(stream->stream+dimPre, dimHeader, bigendian);
 		headerReference->setByteStream(tempHeader);
 		dim += headerReference->getPacketLength();
 		return dim;
 }
 
-Packet* PacketLib::InputPacketStream::decodePacket(byte* stream) {
+Packet* PacketLib::InputPacketStream::decodePacket(ByteStreamPtr stream) {
 
 	int index = detPacketType(stream);
 	if(index > 0) {
 		Packet* p = getPacketType(index);
-		p->setPacketValue(stream);
+		p->setPacketValue(stream->stream);
 		return p;
 	}
 	else
-- 
GitLab