summaryrefslogtreecommitdiffstats
path: root/libtransport/src/protocols/indexer.cc
diff options
context:
space:
mode:
authorMauro <you@example.com>2021-06-30 07:57:22 +0000
committerMauro Sardara <msardara@cisco.com>2021-07-06 16:16:04 +0000
commit08233d44a6cfde878d7e10bca38ae935ed1c8fd5 (patch)
tree7ecc534d55bdc7e8dd15ecab084720910bcdf4d9 /libtransport/src/protocols/indexer.cc
parent147ba39bed26887f5eba84757e2463ab8e370a9a (diff)
[HICN-713] Transport Library Major Refactoring 2
Co-authored-by: Luca Muscariello <muscariello@ieee.org> Co-authored-by: Michele Papalini <micpapal@cisco.com> Co-authored-by: Olivier Roques <oroques+fdio@cisco.com> Co-authored-by: Giulio Grassi <gigrassi@cisco.com> Signed-off-by: Mauro Sardara <msardara@cisco.com> Change-Id: I5b2c667bad66feb45abdb5effe22ed0f6c85d1c2
Diffstat (limited to 'libtransport/src/protocols/indexer.cc')
-rw-r--r--libtransport/src/protocols/indexer.cc60
1 files changed, 14 insertions, 46 deletions
diff --git a/libtransport/src/protocols/indexer.cc b/libtransport/src/protocols/indexer.cc
index 1379a609c..8d4cf04d7 100644
--- a/libtransport/src/protocols/indexer.cc
+++ b/libtransport/src/protocols/indexer.cc
@@ -13,61 +13,29 @@
* limitations under the License.
*/
-#include <hicn/transport/utils/branch_prediction.h>
-#include <protocols/incremental_indexer.h>
+#include <implementation/socket_consumer.h>
#include <protocols/indexer.h>
-#include <protocols/manifest_incremental_indexer.h>
namespace transport {
-namespace protocol {
-IndexManager::IndexManager(implementation::ConsumerSocket *icn_socket,
- TransportProtocol *transport, Reassembly *reassembly)
- : indexer_(std::make_unique<IncrementalIndexer>(icn_socket, transport,
- reassembly)),
- first_segment_received_(false),
- icn_socket_(icn_socket),
- transport_(transport),
- reassembly_(reassembly) {}
+namespace protocol {
-void IndexManager::onContentObject(core::Interest &interest,
- core::ContentObject &content_object) {
- if (first_segment_received_) {
- indexer_->onContentObject(interest, content_object);
- } else {
- std::uint32_t segment_number = interest.getName().getSuffix();
+using namespace interface;
- if (segment_number == 0) {
- // Check if manifest
- if (content_object.getPayloadType() == core::PayloadType::MANIFEST) {
- IncrementalIndexer *indexer =
- static_cast<IncrementalIndexer *>(indexer_.release());
- indexer_ =
- std::make_unique<ManifestIncrementalIndexer>(std::move(*indexer));
- delete indexer;
- }
+const constexpr uint32_t Indexer::invalid_index;
- indexer_->onContentObject(interest, content_object);
- auto it = interest_data_set_.begin();
- while (it != interest_data_set_.end()) {
- indexer_->onContentObject(*it->first, *it->second);
- it = interest_data_set_.erase(it);
- }
+Indexer::Indexer(implementation::ConsumerSocket *socket,
+ TransportProtocol *transport)
+ : socket_(socket), transport_(transport) {
+ setVerifier();
+}
- first_segment_received_ = true;
- } else {
- interest_data_set_.emplace(interest.shared_from_this(),
- content_object.shared_from_this());
- }
+void Indexer::setVerifier() {
+ if (socket_) {
+ socket_->getSocketOption(GeneralTransportOptions::VERIFIER, verifier_);
}
}
-void IndexManager::reset(std::uint32_t offset) {
- indexer_ = std::make_unique<IncrementalIndexer>(icn_socket_, transport_,
- reassembly_);
- first_segment_received_ = false;
- interest_data_set_.clear();
-}
+} // end namespace protocol
-} // namespace protocol
-} // namespace transport
+} // end namespace transport