18 #include <core/manifest.h>
19 #include <core/manifest_format.h>
20 #include <hicn/transport/portability/portability.h>
28 template <
typename Base,
typename FormatTraits>
30 :
public Manifest<Base, FormatTraits, ManifestInline<Base, FormatTraits>> {
34 using Hash =
typename FormatTraits::Hash;
35 using HashType =
typename FormatTraits::HashType;
36 using Suffix =
typename FormatTraits::Suffix;
37 using SuffixList =
typename FormatTraits::SuffixList;
38 using HashEntry = std::pair<auth::CryptoHashType, std::vector<uint8_t>>;
50 const core::Name &manifest_name, ManifestVersion version,
51 ManifestType type, HashType algorithm,
bool is_last,
52 const Name &base_name, NextSegmentCalculationStrategy strategy,
53 std::size_t signature_size) {
55 manifest->setVersion(version);
56 manifest->setManifestType(type);
57 manifest->setHashAlgorithm(algorithm);
58 manifest->setFinalManifest(is_last);
59 manifest->setBaseName(base_name);
60 manifest->setNextSegmentCalculationStrategy(strategy);
66 ManifestBase::encoder_.encode();
71 base_name_ = ManifestBase::decoder_.getBaseName();
72 next_segment_strategy_ =
73 ManifestBase::decoder_.getNextSegmentCalculationStrategy();
74 suffix_hash_map_ = ManifestBase::decoder_.getSuffixHashList();
79 std::size_t estimateManifestSizeImpl(std::size_t additional_entries = 0) {
80 return ManifestBase::encoder_.estimateSerializedLength(additional_entries);
85 ManifestBase::encoder_.setBaseName(base_name_);
89 const Name &getBaseName() {
return base_name_; }
92 ManifestBase::encoder_.addSuffixAndHash(suffix,
hash);
97 const SuffixList &getSuffixList() {
return suffix_hash_map_; }
100 NextSegmentCalculationStrategy strategy) {
101 next_segment_strategy_ = strategy;
102 ManifestBase::encoder_.setNextSegmentCalculationStrategy(
103 next_segment_strategy_);
107 NextSegmentCalculationStrategy getNextSegmentCalculationStrategy() {
108 return next_segment_strategy_;
113 static std::unordered_map<Suffix, Hash> getSuffixMap(
114 const std::vector<ManifestInline *> &manifests) {
115 std::unordered_map<Suffix, Hash> suffix_map;
117 for (
auto manifest_ptr : manifests) {
118 HashType hash_type = manifest_ptr->getHashAlgorithm();
119 SuffixList suffix_list = manifest_ptr->getSuffixList();
121 for (
auto it = suffix_list.begin(); it != suffix_list.end(); ++it) {
122 Hash
hash(it->second, Hash::getSize(hash_type), hash_type);
123 suffix_map[it->first] =
hash;
130 static std::unordered_map<Suffix, Hash> getSuffixMap(
132 return getSuffixMap(std::vector<ManifestInline *>{manifest});
137 NextSegmentCalculationStrategy next_segment_strategy_;
138 SuffixList suffix_hash_map_;