2021-12-03 15:37:49 +01:00
|
|
|
#include "MetadataInfo.h"
|
|
|
|
|
2022-09-05 10:26:35 +02:00
|
|
|
MetadataInfo::MetadataInfo(bool closureRequested, cfdp::ChecksumTypes checksumType,
|
2022-08-23 19:37:30 +02:00
|
|
|
cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName,
|
|
|
|
cfdp::StringLv& destFileName)
|
|
|
|
: MetadataInfo(fileSize, sourceFileName, destFileName) {
|
|
|
|
this->closureRequested = closureRequested;
|
|
|
|
this->checksumType = checksumType;
|
|
|
|
}
|
|
|
|
|
|
|
|
MetadataInfo::MetadataInfo(cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName,
|
|
|
|
cfdp::StringLv& destFileName)
|
|
|
|
: fileSize(fileSize), sourceFileName(sourceFileName), destFileName(destFileName) {}
|
|
|
|
|
|
|
|
void MetadataInfo::setOptionsArray(cfdp::Tlv** optionsArray_, std::optional<size_t> optionsLen_,
|
|
|
|
std::optional<size_t> maxOptionsLen_) {
|
2022-08-08 17:53:42 +02:00
|
|
|
this->optionsArray = optionsArray_;
|
2022-08-23 19:37:30 +02:00
|
|
|
if (maxOptionsLen_) {
|
|
|
|
this->maxOptionsLen = maxOptionsLen_.value();
|
2022-02-02 10:29:30 +01:00
|
|
|
}
|
2022-08-23 19:37:30 +02:00
|
|
|
if (optionsLen_) {
|
|
|
|
this->optionsLen = optionsLen_.value();
|
2022-02-02 10:29:30 +01:00
|
|
|
}
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2022-09-05 10:26:35 +02:00
|
|
|
cfdp::ChecksumTypes MetadataInfo::getChecksumType() const { return checksumType; }
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-09-05 10:26:35 +02:00
|
|
|
void MetadataInfo::setChecksumType(cfdp::ChecksumTypes checksumType_) {
|
2022-08-08 17:53:42 +02:00
|
|
|
checksumType = checksumType_;
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
bool MetadataInfo::isClosureRequested() const { return closureRequested; }
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-08-08 17:53:42 +02:00
|
|
|
void MetadataInfo::setClosureRequested(bool closureRequested_) {
|
|
|
|
closureRequested = closureRequested_;
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2022-08-23 19:37:30 +02:00
|
|
|
cfdp::StringLv& MetadataInfo::getDestFileName() { return destFileName; }
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
cfdp::FileSize& MetadataInfo::getFileSize() { return fileSize; }
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-08-08 17:53:42 +02:00
|
|
|
ReturnValue_t MetadataInfo::getOptions(cfdp::Tlv*** optionsArray_, size_t* optionsLen_,
|
2022-02-02 10:29:30 +01:00
|
|
|
size_t* maxOptsLen) {
|
2022-08-08 17:53:42 +02:00
|
|
|
if (optionsArray_ == nullptr or optionsArray == nullptr) {
|
2022-08-16 01:08:26 +02:00
|
|
|
return returnvalue::FAILED;
|
2022-02-02 10:29:30 +01:00
|
|
|
}
|
2022-08-08 17:53:42 +02:00
|
|
|
*optionsArray_ = optionsArray;
|
|
|
|
if (optionsLen_ != nullptr) {
|
|
|
|
*optionsLen_ = this->optionsLen;
|
2022-02-02 10:29:30 +01:00
|
|
|
}
|
|
|
|
if (maxOptsLen != nullptr) {
|
|
|
|
*maxOptsLen = this->maxOptionsLen;
|
|
|
|
}
|
2022-08-16 01:08:26 +02:00
|
|
|
return returnvalue::OK;
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MetadataInfo::hasOptions() const {
|
2022-02-02 10:29:30 +01:00
|
|
|
if (optionsArray != nullptr and optionsLen > 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MetadataInfo::canHoldOptions() const {
|
2022-02-02 10:29:30 +01:00
|
|
|
if (optionsArray != nullptr and maxOptionsLen > 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t MetadataInfo::getSerializedSize(bool fssLarge) {
|
2022-02-02 10:29:30 +01:00
|
|
|
// 1 byte + minimal FSS 4 bytes
|
|
|
|
size_t size = 5;
|
|
|
|
if (fssLarge) {
|
|
|
|
size += 4;
|
|
|
|
}
|
|
|
|
size += sourceFileName.getSerializedSize();
|
|
|
|
size += destFileName.getSerializedSize();
|
|
|
|
if (hasOptions()) {
|
|
|
|
for (size_t idx = 0; idx < optionsLen; idx++) {
|
|
|
|
size += optionsArray[idx]->getSerializedSize();
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
2022-02-02 10:29:30 +01:00
|
|
|
}
|
|
|
|
return size;
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2022-08-23 19:37:30 +02:00
|
|
|
void MetadataInfo::setDestFileName(cfdp::StringLv& destFileName_) {
|
|
|
|
this->destFileName = destFileName_;
|
|
|
|
}
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-08-23 19:37:30 +02:00
|
|
|
void MetadataInfo::setSourceFileName(cfdp::StringLv& sourceFileName_) {
|
2022-08-08 17:53:42 +02:00
|
|
|
this->sourceFileName = sourceFileName_;
|
2021-12-03 15:37:49 +01:00
|
|
|
}
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
size_t MetadataInfo::getMaxOptionsLen() const { return maxOptionsLen; }
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-08-08 17:53:42 +02:00
|
|
|
void MetadataInfo::setMaxOptionsLen(size_t maxOptionsLen_) { this->maxOptionsLen = maxOptionsLen_; }
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
size_t MetadataInfo::getOptionsLen() const { return optionsLen; }
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-08-08 17:53:42 +02:00
|
|
|
void MetadataInfo::setOptionsLen(size_t optionsLen_) { this->optionsLen = optionsLen_; }
|
2021-12-03 15:37:49 +01:00
|
|
|
|
2022-08-23 19:37:30 +02:00
|
|
|
cfdp::StringLv& MetadataInfo::getSourceFileName() { return sourceFileName; }
|