Vince Woo 48e4720419
Created new SerialBufferBase as a parent of SerializeBufferBase (now renamed LinearBufferBase). (#4288)
* Created new SerialBufferBase as a parent of SerializeBufferBase. Renaming interface functions to be less confusing.

* Deprecating copyRawOffset. No direct use-cases in F' core.

* Make SerialBufferBase a true pure virtual interface.

* Changing Serializable to work with SerialBufferBase parent interface.

* Changing copyRaw and copyRawOffset to work with SerialBufferBase

* Updating documentation for SerialBufferBase usage

* Adding some documentation. Adding missing ASSERT in copyRaw. Fixing some bugs that new ASSERT uncovered.

* Renaming SerializeBufferBase to LinearBufferBase. Add a using declaration to maintain backwards compatability. Properly mark LinearBufferBase functions as override.

* Filling in the rest of the docstrings for the classes in Serializable

* Removing redundant virtual keyword on override function

* Applying clang formatting

* Incorporating PR comments

* Fix compile issues

* Bump version to alpha

* Format

* v

---------

Co-authored-by: M Starch <LeStarch@googlemail.com>
2025-11-06 16:23:20 -08:00

54 lines
1.4 KiB
C++

// ======================================================================
// \title Buffers.cpp
// \author Rob Bocchino
// \brief F Prime sequence file headers
//
// \copyright
// Copyright (C) 2009-2018 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
// ======================================================================
#include "Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.hpp"
#include "Os/File.hpp"
#include "gtest/gtest.h"
namespace Svc {
namespace SequenceFiles {
namespace Buffers {
FwSizeType FileBuffer ::getCapacity() const {
return sizeof(m_buff);
}
FwSizeType FileBuffer ::getBuffCapacity() const {
return this->getCapacity();
}
U8* FileBuffer ::getBuffAddr() {
return m_buff;
}
const U8* FileBuffer ::getBuffAddr() const {
return m_buff;
}
void write(const Fw::SerializeBufferBase& buffer, const char* fileName) {
Os::File file;
ASSERT_EQ(file.open(fileName, Os::File::OPEN_WRITE), Os::File::OP_OK);
FwSizeType size = buffer.getSize();
const U32 expectedSize = size;
const U8* const buffAddr = buffer.getBuffAddr();
ASSERT_EQ(file.write(buffAddr, size, Os::File::WaitType::WAIT), Os::File::OP_OK);
ASSERT_EQ(expectedSize, static_cast<U32>(size));
file.close();
}
} // namespace Buffers
} // namespace SequenceFiles
} // namespace Svc