summaryrefslogtreecommitdiffstats
path: root/libtransport/src/protocols/index_manager_bytestream.h
blob: 7ea31dfa5178b796375ef2708d188b91813043bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 * Copyright (c) 2021 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <protocols/incremental_indexer_bytestream.h>

#include <list>

namespace transport {

namespace implementation {
class ConsumerSocket;
}

namespace protocol {

class TransportProtocol;

class IndexManager : public IncrementalIndexer {
 public:
  IndexManager(implementation::ConsumerSocket *icn_socket,
               TransportProtocol *transport);

  uint32_t getNextSuffix() override { return indexer_->getNextSuffix(); }

  void setFirstSuffix(uint32_t suffix) override {
    indexer_->setFirstSuffix(suffix);
  }

  uint32_t getFirstSuffix() const override {
    return indexer_->getFirstSuffix();
  }

  uint32_t getNextReassemblySegment() override {
    return indexer_->getNextReassemblySegment();
  }

  bool isFinalSuffixDiscovered() override {
    return indexer_->isFinalSuffixDiscovered();
  }

  uint32_t getFinalSuffix() const override {
    return indexer_->getFinalSuffix();
  }

  uint32_t jumpToIndex(uint32_t index) override {
    return indexer_->jumpToIndex(index);
  }

  void setNFec(uint32_t n_fec) override { return indexer_->setNFec(n_fec); }
  uint32_t getNFec() const override { return indexer_->getNFec(); }

  void enableFec(fec::FECType fec_type) override {
    return indexer_->enableFec(fec_type);
  }

  double getFecOverhead() const override { return indexer_->getFecOverhead(); }

  double getMaxFecOverhead() const override {
    return indexer_->getMaxFecOverhead();
  }

  void disableFec() override { return indexer_->disableFec(); }

  void reset() override;

  void setReassembly(Reassembly *reassembly) override {
    Indexer::setReassembly(reassembly);
    indexer_->setReassembly(reassembly);
  }

  void onContentObject(core::Interest &interest,
                       core::ContentObject &content_object,
                       bool reassembly) override;

 private:
  std::unique_ptr<Indexer> indexer_;
  bool first_segment_received_;
  std::set<std::pair<core::Interest::Ptr, core::ContentObject::Ptr>>
      interest_data_set_;
};

}  // namespace protocol
}  // namespace transport