| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title StartPacket.cpp | ||
| 3 | // \author bocchino | ||
| 4 | // \brief cpp file for FilePacket::StartPacket | ||
| 5 | // | ||
| 6 | // \copyright | ||
| 7 | // Copyright 2009-2016, by the California Institute of Technology. | ||
| 8 | // ALL RIGHTS RESERVED. United States Government Sponsorship | ||
| 9 | // acknowledged. | ||
| 10 | // | ||
| 11 | // ====================================================================== | ||
| 12 | |||
| 13 | #include <Fw/FilePacket/FilePacket.hpp> | ||
| 14 | #include <Fw/Types/Assert.hpp> | ||
| 15 | |||
| 16 | namespace Fw { | ||
| 17 | |||
| 18 | 17 | void FilePacket::StartPacket ::initialize(const U32 fileSize, | |
| 19 | const char* const sourcePath, | ||
| 20 | const char* const destinationPath) { | ||
| 21 | 17 | this->m_header.initialize(FilePacket::T_START, 0); | |
| 22 | 17 | this->m_fileSize = fileSize; | |
| 23 | 17 | this->m_sourcePath.initialize(sourcePath); | |
| 24 | 17 | this->m_destinationPath.initialize(destinationPath); | |
| 25 | 17 | } | |
| 26 | |||
| 27 | 17 | U32 FilePacket::StartPacket ::bufferSize() const { | |
| 28 | 17 | return static_cast<U32>(this->m_header.bufferSize() + sizeof(this->m_fileSize) + this->m_sourcePath.bufferSize() + | |
| 29 | 17 | this->m_destinationPath.bufferSize()); | |
| 30 | } | ||
| 31 | |||
| 32 | 17 | SerializeStatus FilePacket::StartPacket ::toBuffer(Buffer& buffer) const { | |
| 33 |
3/3✓ Branch 5 taken 17 times.
✓ Branch 11 taken 17 times.
✓ Branch 14 taken 17 times.
|
17 | SerialBuffer serialBuffer(buffer.getData(), buffer.getSize()); |
| 34 |
1/1✓ Branch 2 taken 17 times.
|
34 | return this->toSerialBuffer(serialBuffer); |
| 35 | 17 | } | |
| 36 | |||
| 37 | 16 | SerializeStatus FilePacket::StartPacket ::fromSerialBuffer(SerialBuffer& serialBuffer) { | |
| 38 | 16 | FW_ASSERT(this->m_header.m_type == T_START); | |
| 39 | |||
| 40 | { | ||
| 41 | 16 | const SerializeStatus status = serialBuffer.deserializeTo(this->m_fileSize); | |
| 42 | |||
| 43 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
|
16 | if (status != FW_SERIALIZE_OK) { |
| 44 | ✗ | return status; | |
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | { | ||
| 49 | 16 | const SerializeStatus status = this->m_sourcePath.fromSerialBuffer(serialBuffer); | |
| 50 | |||
| 51 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
|
16 | if (status != FW_SERIALIZE_OK) { |
| 52 | ✗ | return status; | |
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | { | ||
| 57 | 16 | const SerializeStatus status = this->m_destinationPath.fromSerialBuffer(serialBuffer); | |
| 58 | |||
| 59 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
|
16 | if (status != FW_SERIALIZE_OK) { |
| 60 | ✗ | return status; | |
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 |
1/2✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
|
16 | if (serialBuffer.getDeserializeSizeLeft() != 0) { |
| 65 | ✗ | return FW_DESERIALIZE_SIZE_MISMATCH; | |
| 66 | } | ||
| 67 | |||
| 68 | 16 | return FW_SERIALIZE_OK; | |
| 69 | } | ||
| 70 | |||
| 71 | 17 | SerializeStatus FilePacket::StartPacket ::toSerialBuffer(SerialBuffer& serialBuffer) const { | |
| 72 | 17 | FW_ASSERT(this->m_header.m_type == T_START); | |
| 73 | |||
| 74 | { | ||
| 75 | 17 | const SerializeStatus status = this->m_header.toSerialBuffer(serialBuffer); | |
| 76 | |||
| 77 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
|
17 | if (status != FW_SERIALIZE_OK) { |
| 78 | ✗ | return status; | |
| 79 | } | ||
| 80 | } | ||
| 81 | |||
| 82 | { | ||
| 83 | 17 | const SerializeStatus status = serialBuffer.serializeFrom(this->m_fileSize); | |
| 84 | |||
| 85 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
|
17 | if (status != FW_SERIALIZE_OK) { |
| 86 | ✗ | return status; | |
| 87 | } | ||
| 88 | } | ||
| 89 | |||
| 90 | { | ||
| 91 | 17 | const SerializeStatus status = this->m_sourcePath.toSerialBuffer(serialBuffer); | |
| 92 | |||
| 93 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
|
17 | if (status != FW_SERIALIZE_OK) { |
| 94 | ✗ | return status; | |
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | { | ||
| 99 | 17 | const SerializeStatus status = this->m_destinationPath.toSerialBuffer(serialBuffer); | |
| 100 | |||
| 101 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
|
17 | if (status != FW_SERIALIZE_OK) { |
| 102 | ✗ | return status; | |
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | 17 | return FW_SERIALIZE_OK; | |
| 107 | } | ||
| 108 | |||
| 109 | } // namespace Fw | ||
| 110 |