getRefs on objects

This commit is contained in:
2024-03-17 23:08:57 +01:00
parent 476904b5aa
commit 0b2040603e
6 changed files with 31 additions and 0 deletions

View File

@@ -17,3 +17,7 @@ void Object::serialize(std::vector<char> &out) const {
}
Object::~Object() = default;
static std::vector<Object::idType> emptyRef{};
const std::vector<Object::idType> &Object::getRefs() const { return emptyRef; }

View File

@@ -28,3 +28,5 @@ void Archive::serialize(std::vector<char> &out) const {
}
std::string Archive::getKey() const { return name; }
const std::vector<Object::idType> &Archive::getRefs() const { return files; }

View File

@@ -83,3 +83,16 @@ unsigned long long File::getFileSize(const std::filesystem::path &p) {
else
return getFileContents(p).size();
}
void File::makeChunksList() const {
if (chunksList) return;
chunksList.emplace();
chunksList->reserve(chunks.size());
for (auto const &c: chunks) chunksList->emplace_back(c.second);
}
const std::vector<Object::idType> &File::getRefs() const {
if (!chunksList) makeChunksList();
return *chunksList;
}